TME 310 - Computational Physical Modeling
University of Washington Tacoma
An integral is a function or value that describes:



In numerical integration approximate the integral of a function, \(f(x)\) by finding the integral of a simpler function \(f_n(x)\).
If we assume that the simpler function is a straight line (which we’ll call \(f_1(x)\)), we can approximate the integral using the trapezoid rule.
\[\int_{a}^{b} f(x)\,dx \approx \int_{a}^{b} f_1(x)\,dx\]
where
\[f_1(x) = \frac{f(b) - f(a)}{b-a}(x-a)+f(a)\]
\(f_1(x)\) is just the equation of a straight line that intersects \(f(x)\) at the points \(a\) and \(b\).
The integral of \(f_1(x)\) is simple to calculate:
\[\int_{a}^{b} f_1(x)\,dx = (b-a)\frac{f(a) + f(b)}{2}\]
It’s composed of two parts:







With \(n\) points, our approximate integral gives us \(n-1\) trapezoids…
Think of each trapezoid as areas corresponding to \(x_1\) through \(x_n\).
If we want \(n\) points for our integral, assign \(x_0 = 0\) and then add the integration constant, \(C\) to the entire integral array
Scipy has a function for discrete integration: scipy.integrate.cumulative_trapezoid
Length of x: 126
Length of y: 126
Length of I: 125
Scipy has a function for discrete integration: scipy.integrate.cumulative_trapezoid
The length of x, y, and I:
Length of x: 126
Length of y: 126
Length of I: 126
Scipy has a function for discrete integration: scipy.integrate.cumulative_trapezoid

Scipy has a function for discrete integration: scipy.integrate.cumulative_trapezoid
