Whether it is the three major mathematical software Matlab (communication, control and other engineering exceptions), Maple, Mathematica, or the three major statistical software Spass, Stata, SAS, these visual software itself is a manifestation of programming, they lower the threshold of our use of mathematics to a certain extent. On the other hand, the functions behind them can be replaced by programming, and Python’s popularity in mathematics and data science is part of that process.

In terms of occupations, actuary, financial engineering, business analysis, data analyst, data mining, data modeling, quantitative engineer, algorithm engineer, data product manager, data operation, digital marketing, big data, game development, artificial intelligence and many other occupations require mathematics. However, we will find that the application of mathematics in these positions requires the use of mathematical software and the combination with programming. It can be said that if we want to apply mathematics, it should be organically combined with programming. In the field of mathematics and data, Python has become the most recommended programming language for learning mathematics due to the glue nature of the Python programming language and the abundance of third-party libraries.

The Technical column on Learning Math in Python is an attempt to combine mathematics with programming and return mathematics learning to basic concepts and practical applications. (Of course, the purpose of this column is primarily to serve the basics of data science and machine learning.)

Why is math so difficult and useless?

The so-called organic combination of mathematics and programming, one is in the direction of mathematics learning to the practical application of mathematics as the focus; Second, mathematics in the symbol, graphics and other forms of expression should be seamlessly combined with programming language.

There are many disadvantages in mathematics teaching in our student days:

  • A previous education too much emphasis on the specific capacity, a lot of good at maths, but is a master of problem solving, some extremely complex differential equation and matrix still stays on the manual computation technique and manual computation ability, and the application of mathematics need to memorize a large number of complex mathematical formula, this no doubt even more difficult for mathematics study, also deviate from the direction of the mathematics originally; In the algebraic notation section, we have mentioned that the CAS tool Sympy can be used to deliver complex mathematical operations, so the memorization and written calculation of mathematical formulas will no longer be the focus of learning.
  • Second, a really good mathematics teaching should simplify complex mathematical theoretical knowledge. Compared with foreign universities, there are many shortcomings in domestic university courses, so we will recommend some good mathematics courses next. A lot of people learn not well, learn not to a great extent with the tutorial on mathematical concepts have a certain relationship;
  • Three is combined with the Python programming can be on the problem of some mathematical modeling, mathematical modeling through programming in front we mentioned so many careers, their requirements of mathematics foundation is mostly calculus, probability and statistics, linear algebra related knowledge, only in the previous study, we can’t see how mathematics is applied to these professional; Fourth, with Python and some mathematical software, we can make some dynamic graphics to deepen our understanding of mathematical formulas

Selected Mathematics Course

After I got to college, the difficulty of linear algebra, probability statistics, calculus and other mathematical knowledge was higher than in middle school. The painting style of the whole mathematics changed too much, and many concepts became difficult to understand. I don’t know how to pop up suddenly, and I don’t know what the use of learning. In fact, part of the reason for our textbooks is that the editors of Chinese university textbooks do not have the thinking of product managers, and do not stand in the perspective of students and do not take students as the center to write textbooks. Here are some of the best textbooks:

Linear algebra

One is William Gilbert Strang’s video on Linear Algebra. MIT Open Course: Linear Algebra, which comes with an introduction to Linear Algebra. The price is a little sexy, but you can do it without reading the book. Strang is a professor at MIT and has written many classic math textbooks. He also has a reputation for teaching linear algebra himself. You can also find out more about this course on MIT opencourseware: MIT Linear Algebra. This course also has an accompanying problem set, as well as the MIT Linear Algebra problem set, available on NetEase Cloud

The second is the essence of 3Blue1Brown’s linear algebra. 3Blue1Brown is a Stanford-educated Youtube channel that uses intuitive ways to explain difficult concepts. It’s highly recommended.

Differential and integral calculus

We also recommend MIT and 3Blue1Brown for calculus. Calculus in MIT is divided into single-variable calculus and multi-variable calculus, and both of them have matching exercise videos, which can be seen in NetEase cloud class. Single-variable calculus, single-variable calculus recitation, multivariable calculus, multivariable calculus recitation. If you want to see more videos, you can also go to the MIT website, univariate calculus, multivariable calculus.

3Blue1Brown’s calculus is as good as it’s ever been, and you can read it before you take the MIT course.

statistical

Statistics is a very important subject. Here we recommend the statistics course of Khan Academy. Although there are also MIT statistics courses, unfortunately there are no subtitles. There is also a Stanford Introduction to Learning Statistics (with English subtitles) which is quite good. The above tutorials may use R or MATLAB, which can be replaced by Python.

Mathematical formula and image presentation

Interesting mathematical graphics

In order to deepen our understanding of mathematical formulas, we usually need to supplement them with some figures, such as function figures, geometric figures, spatial figures, etc. In the past, we used to draw graphs by hand drawing some graphs on paper, which is not only troublesome, but also very inaccurate, and can not make graphs adjust graphs intuitively according to the changes in variable values. Take the following formula:


In order to draw the graph by hand, we not only need to study the characteristics of the mathematical formula (such as highest point, lowest point, inflection point, concavity), but also determine the contour of the graph by assigning values. Of course, due to the limited value assignment, the graph naturally cannot be accurate. This is still the case with only one variable. Sometimes we may have multiple variables to study mathematical formulas. For example, the following formula may have variable B in addition to x:


Because the formulas are too complicated, it takes us a lot of time to draw the mathematical formulas. But graphics are necessary because they can deepen our understanding of mathematical formulas. In fact, we can use computer software to achieve the formula of the graph.

Mathematical graph drawing software

You can use Desmos or Geogebra’s online version of Mathematica, although the almighty Wolfram Alpha (which also owns Mathematica) can do it for a fee. Desmos, Geogebra, Wolfram Alpha (for a fee) all have excellent apps that are well worth using if you are studying mathematics to improve your understanding of mathematical formulas, concepts, etc.

Desmos and Geogebra can input formulas via a virtual keyboard, which is very convenient. Moreover, the formulas in the formula input box are in LaTex format. You can directly copy the formulas into VS Code Markdown and add?? Children who are not familiar with LaTex can read “Outputting LaTex Mathematical Formulas with Markdown” in this column, Learning Math in Python. You can also paste LaTex formulas directly into the Desmos and Geogebra formulas input boxes. For example, paste the following LaTex formula into the input box, using b as a variable:

X ^ {\ frac {2} {3}} + 0.9 \ SQRT {3.3 x ^ 2} \ sin \ left (b \ \ x PI right)Copy the code

Desmos and Geogebra can add variables to math formulas. You can use Slider to adjust the value of variables. The graphics will be drawn and displayed in real time

Other math-related software (including App)

Now that is the age of the Internet, with the aid of PC to the online version of the software and mobile phone App to learn mathematics is granted, in the United States and other countries, these mathematical software has been came into the classroom (interested in primary and secondary school mathematics software friend to search about, will not covered here).

Symbolab: Mathematical software that tells you the steps of an operation

Symbolab: This is a calculator, higher mathematics support Online version (there is also a good apps), can then be used to calculate some basic algebra, function, triangle, calculus and other mathematical formula and the operation of chemical formula, it’s most distinctive function can be given more detailed operation steps, if you want to calculate the value of the mathematical formula of the following:


Using Symbolab, except for the following result:


It will also show you the details of the whole operation steps, very suitable for students to do math exercises, to check whether their operation steps are wrong, also suitable for teachers to learn the number of problems.

Other math apps like MathPapa (which is worse than Symbolab overall), Photomath (which has a mobile App, but is not as good as Symbolab, except for taking photos to identify the formulas), and Mathway (which is also mediocre, but the mobile App is good). There are other Math apps you can search for “Math” in the App store, but they all do similar things.

Python is versatile

We have always emphasized that all of the math software mentioned above can be replaced by Python (GUI click operation is ok, but more complex, not recommended), and math software is difficult to combine with programming, and there are some APIS that can be used to connect data to production. If it cannot be combined with programming, mathematical formulas are dead, and data cannot be effectively applied to production practices, the commercial value of data will be greatly reduced. So, in addition to drawing mathematical graphics, learning mathematics should be completely integrated with programming.

So how does Python draw mathematical graphics? We can draw mathematical graphs using the most commonly used data visualization library Matplotlib and Sympy, which is capable of algebraic notation.

Draw using MatplotlibMathematical graph of:

import numpy as np  
import matplotlib.pyplot as plt  
def graph(formula, x_range):  
    x = np.array(x_range)  
    y = eval(formula)
    plt.plot(x, y)  
    plt.show()
    
graph('x**3+2*x-4', range(-10, 11))
Copy the code

Sympy was usedandIntersecting mathematical figures:

from sympy import symbols
from sympy.plotting import plot
x = symbols('x')
p1 = plot(x*x, show=False)
p2 = plot(x, show=False)
p1.append(p2[0])
p1.show()
Copy the code

The Sympy Gamma in Python provides the same Sympy steps, but the experience is not as good as Symbolab