It is good to choose python for mathematical modeling. Python is open source. Open source things are full of vitality, and everyone is adding fuel to the fire. Programming experts all over the world are adding bricks and mortar to Python. Currently, the official (pypi.org) shows that there are more than 100,000 third-party libraries, and It seems that hundreds of new libraries are being added every day. Such a huge third-party library covers almost all walks of life and fields. If you want to do something, just look for it. There is usually a basic library suitable for you that others have already done. Okay, you can use it directly to get twice the result with half the effort
Here are some problems in mathematical modeling using python, using python3.x, scipy, numpy and matplotlib.
First add some basic data knowledge
1. numpy.array()
In basic operations, array and list are not distinguished (in indexing and deletion some There will be differences in operation and running time), and Python does not have the data structure array. Array is defined by numpy, a numerical calculation tool package. Because many operations must be performed on arrays (lists will cause errors), they need to be mastered. Refer to the official documentation below.
import numpy as np
##1. Linear programmingSelect scipy.optimize.linprog to solve the problem of maximizing and minimizing linear programming problems. Learning materials: Official documentation. We will not discuss specific issues here, but only involve the process of converting mathematical equations into functional language for solution. Reference book: Mathematical Modeling Algorithms and Applications. 2. Polynomial least squares curve fittingUse numpy.polyfit.
The above is the detailed content of How to build a mathematical model using python. For more information, please follow other related articles on the PHP Chinese website!