Calculus wth Sympy¶
In this section, we will be covering basic calculus theory and using sympy to solve the related equations.
Calculus: Differentiation (Theory)¶
Basic Rules¶
Sum Difference Rule¶
Given
Then
Product Rule¶
Given a function with two parts
First derivative
Given three parts, we always use the product rule to keep it to 2 parts
Quotient Rule¶
Given
Then
Logarithmic Rule¶
Given
Then
Exponential Rule¶
Given
Then
Partial Derivative¶
Given
When computing the partial derivative of \(x_i\) with respect to (w.r.t.) the multivariable function \(f(x_i \dots x_n)\), treat the rest of the variables as constant.
Calculus: Integration (Theory)¶
Basic Rules¶
Given function \(f(x)\) and integral of that function \(F(x)\), then basic rules include
Sum Difference Rule¶
Given
Then
Integration by Parts¶
Definite Integral Rules¶
Zero integral when not moving integration point¶
Definite integral's interval switching becomes negative¶
Definite integral decomposed into parts¶
Substitution method for solving definite integrals¶
Substitution Example 1¶
Given $$ f(x) = x \cos(x^2 + 1) $$
Then definite integral from -1 to 1 is $$ F(x)_{-1}^1 = \int _{-1} ^ 1 x \cos(x^2 + 1) dx $$
Modifying the equation to make \(du\) and \(u\) substitution method results in $$ F(x)_{-1}^1 = \frac{1}{2} \int _{-1} ^ 1 2x \cos(x^2 + 1) dx $$
Let \(u\) be $$ u = x^2 +1 $$
Let \(du\) be $$ du = 2x $$
New limits given -1 and 1 $$ u = (-1)^2 + 1 = 2 $$ $$ u = (1)^2 + 1 = 2 $$
Then by zero integral rule $$ F(x)_{-1}^1 = \int _2 ^2 cos(u) du = 0 $$
Substitution Example 2¶
Given $$ h(x) = x(x+3)^{\frac{1}{2}} $$
Then definite integral from -1 to 1 is $$ H(x)_{-1}^1 = \int _{-1} ^ 1 x(x+3)^{\frac{1}{2}} $$
Let \(u\) be $$ u = x + 3 $$ $$ x = u - 3 $$
Let \(du\) be $$ du = 1 $$
New limits given -1 and 1 $$ u = -1 + 3 = 2 $$ $$ u = 1 + 3 = 4 $$
Then
Substitution Example 3¶
Keep on substituting!
You can keep running the substitution rule multiple times, where you can go from \(u\) to \(z\) to etc. to solve the definite integral. It is important to take note that your limits change every time you run the substitution rule once!
Multiple Integrals¶
This is used for functions with multiple variables. Hence, instead of the usual single variable where the definite integral represents the area under the curve, multiple integrals calculate hypervolumes with multiple dimensional functions.
The key is in integrating step by step, when integrating with respect to each variable, the rest of the variables act as constants.
Double Integral¶
Triple Integral¶
Calculus: Taylor Expansion (Theory)¶
Taylor Expansion: Single Variable¶
Given a function that has continuous derivatives up to \((n+1)\) order, the function can be expanded with the following equation:
If not expanded till \(\infty\) then there will be a remainder of \(R_n(x)\)
Taylor Expansion: Multiple Variables¶
In the case of 2 variables \((x, y)\), we can expand the multivariate equation with the generalized Taylor expansion equation:
Maclaurin Expansion¶
It is simply a Taylor expansion about the point 0.