maths.numerical_analysis.simpson_rule ===================================== .. py:module:: maths.numerical_analysis.simpson_rule .. autoapi-nested-parse:: Numerical integration or quadrature for a smooth function f with known values at x_i This method is the classical approach of summing 'Equally Spaced Abscissas' method 2: "Simpson Rule" Functions --------- .. autoapisummary:: maths.numerical_analysis.simpson_rule.f maths.numerical_analysis.simpson_rule.main maths.numerical_analysis.simpson_rule.make_points maths.numerical_analysis.simpson_rule.method_2 Module Contents --------------- .. py:function:: f(x) .. py:function:: main() .. py:function:: make_points(a, b, h) .. py:function:: method_2(boundary: list[int], steps: int) -> float Calculate the definite integral of a function using Simpson's Rule. :param boundary: A list containing the lower and upper bounds of integration. :param steps: The number of steps or resolution for the integration. :return: The approximate integral value. >>> round(method_2([0, 2, 4], 10), 10) 2.6666666667 >>> round(method_2([2, 0], 10), 10) -0.2666666667 >>> round(method_2([-2, -1], 10), 10) 2.172 >>> round(method_2([0, 1], 10), 10) 0.3333333333 >>> round(method_2([0, 2], 10), 10) 2.6666666667 >>> round(method_2([0, 2], 100), 10) 2.5621226667 >>> round(method_2([0, 1], 1000), 10) 0.3320026653 >>> round(method_2([0, 2], 0), 10) Traceback (most recent call last): ... ZeroDivisionError: Number of steps must be greater than zero >>> round(method_2([0, 2], -10), 10) Traceback (most recent call last): ... ZeroDivisionError: Number of steps must be greater than zero