<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Integration
Step1:  Contents
1.Integral Calculus
2.Fundamental Theorem of Calculus
3.Basic Integration
- Integrating powers of x
- Integrating other basic terms
4.Definite Integrals
- Area under graph
- Area under graph for y axis
- Area between lines
- Area between lines on y axis
<a id='Integral_Calculus'></a>
Integral Calculus
How to find area under curve between a specified x
$\lim_{n\to\infty}\sum_{i=1}^n f(x_i)\Delta x_i = \int^b_a f(x)dx$
this is the area under the graph
the left side sums as many values of y in the specified x data set and weights it with the difference in x
the right side is the integral which is 1 function which takes the range of a to b
This is the Definite Integral
$\int f(x) dx$
This is the Indefinite Integral or anti-derivative
Step2:  <a id='Fundamental_Theorem_of_Calculus'></a>
Fundamental Theorem of Calculus
$f(x)$ is continuous in $[a,b]$
$F(x) = \int^x_af(t)dt$
- where $x$ is in $[a,b]$
$\frac{dF}{dx} = \frac{d}{dx}\int^x_af(t)dt = f(x)$
Example
<ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
Explanation: Integration
End of explanation
x = np.linspace(-10, 10, 201)
def f(x):
    return x**2
y = f(x)
fig, ax = plt.subplots(1, figsize=(8,4))
ax.plot(x,y, 'g', label='line')
ax.fill_between(x,y, color='blue', alpha=0.3, label='area under graph')
ax.grid(True)
ax.legend()
plt.show()
Explanation: Contents
1.Integral Calculus
2.Fundamental Theorem of Calculus
3.Basic Integration
- Integrating powers of x
- Integrating other basic terms
4.Definite Integrals
- Area under graph
- Area under graph for y axis
- Area between lines
- Area between lines on y axis
<a id='Integral_Calculus'></a>
Integral Calculus
How to find area under curve between a specified x
$\lim_{n\to\infty}\sum_{i=1}^n f(x_i)\Delta x_i = \int^b_a f(x)dx$
this is the area under the graph
the left side sums as many values of y in the specified x data set and weights it with the difference in x
the right side is the integral which is 1 function which takes the range of a to b
This is the Definite Integral
$\int f(x) dx$
This is the Indefinite Integral or anti-derivative
End of explanation
x = np.linspace(-5, 5, 201)
def f(x):
    return 6*x**2 - 20
def F(x):
    return 2*x**3 - 20*x
y = f(x)
start = 60
end = 160
section = x[start:end+1]
fig, ax = plt.subplots(1, figsize=(8,4))
ax.plot(x,y, 'g', label='y = 2x')
ax.fill_between(section,f(section), color='blue', alpha=0.3, label='area under graph')
ax.plot(x[start], 0, 'om', color='purple', label='a')
ax.plot(x[end], 0, 'om', color='r', label='b')
ax.grid(True)
ax.legend()
plt.show()
print 'shaded net area =', F(x[end]) - F(x[start])
Explanation: <a id='Fundamental_Theorem_of_Calculus'></a>
Fundamental Theorem of Calculus
$f(x)$ is continuous in $[a,b]$
$F(x) = \int^x_af(t)dt$
- where $x$ is in $[a,b]$
$\frac{dF}{dx} = \frac{d}{dx}\int^x_af(t)dt = f(x)$
Example:
$F(x) = \int^x_a\frac{\cos^2t}{-\sin t^2}dt$
$F\prime(x) = \frac{d}{dx}\int^x_a\frac{\cos^2t}{-\sin t^2}dt = \frac{\cos^2x}{-\sin x^2}$
Example 2:
$F(x) = \int^{x^2}_a\frac{\cos^2t}{-\sin t^2}dt$
$F\prime(x) = \frac{d}{dx}\int^{x^2}_a\frac{\cos^2t}{-\sin t^2}dt$
$= \frac{\cos^2x^2}{-\sin x^4}\times \frac{d}{dx}x^2$
$= 2\frac{\cos^2x^2}{-\sin x^4}$
<a id='Basic_Integration'></a>
Basic Integration
<a id='Integrating_powers_of_x'></a>
Integrating powers of x
$\int Ax^ndx = \frac{A}{n+1}x^{n+1} + C$
to find the derivative we use $\frac{d}{dx}ax^n = anx^{n-1}$
we do the opposite with $\int ax^ndx = a\frac{1}{n+1}x^{n+1}$
we add $C$ as we cant find out the constant of the original function
Example
$\int 2x^5dx = \frac{1}{3}x^{6} + C$
<a id='Integrating_other_basic_terms'></a>
Integrating other basic terms
Integrating $e^{kx}$
$\int Ae^{kx + b} dx = \frac{A}{k}e^{kx + b} + C$
the derivative is $\frac{d}{dx}e^x = e^x$
to differentiate, we would use the chain rule on the function of x and $\therefore$ multiply by k
Example
$\int 3e^{9x + 2} dx = \frac{1}{3}e^{9x + 2} + C$
Integrating $\frac{1}{x}$
$\int A\frac{n}{x} dx = An\ln x + C$
$\int A\frac{f\prime(x)}{f(x)} dx = A\ln|f(x)| + C$
in the second rule, the top is caused by the chain rule
Example
$\int 2\frac{6}{x} dx = 12\ln x + C$
Example 2
$\int 2\frac{10x}{5x^2 + 3} dx = 2\ln |5x^2 + 3| + C$
Integrating $\sin x$
$\int A\sin(kx) dx = -A\frac{1}{k}\cos(kx) + C$
Example
$\int 4\sin(2x) dx = -2\cos(2x) + C$
Integrating $\cos x$
$\int A\cos(kx) dx = A\frac{1}{k}\sin(kx) + C$
Example
$\int 11\cos(3x) dx = \frac{11}{3}\sin(3x) + C$
<a id='Definite_Integrals'></a>
Definite Integrals
This is where there are defined boundaries on the x or y axis
<a id='Area_under_graph'></a>
Area under graph
$F(x) = \int f(x)dx$
$\int_a^b f(x)dx = F(b) - F(a)$
if the graph is negative, the area can be negative
the definite integral gives the net area
to find area (not net area), split into positive and negative regions and find sum magnitudes of regions
Example
$f(x) = 6x^2$
$F(x) = 2x^3$
$\int_2^5 f(x)dx = F(5) - F(2)$
$= 2(5)^3 - 2(2)^3$
$= 234$
<a id='Area_under_graph_for_y_axis'></a>
Area under graph for y axis
$F(y) = \int f^{-1}(y)dy$
$\int_c^d f^{-1}(y)dy = F(d) - F(c)$
do the same but in terms of y
this includes taking the inverse of the line function to get a function in terms of y
Example
$f(x) = 6x^2$
$f^{-1}(y) = \left(\frac{1}{6}y\right)^{\frac{1}{2}}$
$F(y) = 4\left(\frac{1}{6}y\right)^{\frac{3}{2}}$
$\int_2^5 f^{-1}(y)dy = F(5) - F(2)$
$= 4\left(\frac{5}{6}\right)^{\frac{3}{2}} - 4\left(\frac{1}{3}\right)^{\frac{3}{2}}$
$= 2.273$
<a id='Area_between_lines'></a>
Area between lines
$\int_a^b(f(x) - g(x))dx = \int_a^bf(x)dx - \int_a^bg(x)dx$
Example
$= \int_0^1(\sqrt{x} -  x^2)dx$
$= \left(\frac{2}{3}x^{\frac{3}{2}} - \frac{x^3}{3}\right)\mid^1_0$
$= \left(\frac{2}{3}1^{\frac{3}{2}} - \frac{1^3}{3}\right) - \left(\frac{2}{3}0^{\frac{3}{2}} - \frac{0^3}{3}\right)$
$= \left(\frac{2}{3} - \frac{1}{3}\right)$
$= \left(\frac{1}{3}\right)$
if more lines, separate into sections on the x axis and sum
<a id='Area_between_lines_on_y_axis'></a>
Area between lines on y axis
This works the same as area under graph on y axis but combined with the area between lines method
End of explanation
<END_TASK>