maths.numerical_analysis.numerical_integration¶
Approximates the area under the curve using the trapezoidal rule
Functions¶
|
|
|
Treats curve as a collection of linear lines and sums the area of the |
Module Contents¶
- maths.numerical_analysis.numerical_integration.f(x)¶
- maths.numerical_analysis.numerical_integration.trapezoidal_area(fnc: collections.abc.Callable[[float], float], x_start: float, x_end: float, steps: int = 100) float ¶
Treats curve as a collection of linear lines and sums the area of the trapezium shape they form :param fnc: a function which defines a curve :param x_start: left end point to indicate the start of line segment :param x_end: right end point to indicate end of line segment :param steps: an accuracy gauge; more steps increases the accuracy :return: a float representing the length of the curve
>>> def f(x): ... return 5 >>> '%.3f' % trapezoidal_area(f, 12.0, 14.0, 1000) '10.000'
>>> def f(x): ... return 9*x**2 >>> '%.4f' % trapezoidal_area(f, -4.0, 0, 10000) '192.0000'
>>> '%.4f' % trapezoidal_area(f, -4.0, 4.0, 10000) '384.0000'