Accumulation of Function¶
- accumulated_area(equation_type, coefficients, start, end, precision=4)¶
Evaluates the definite integral between two points for a specific function
- Parameters
equation_type (str) – Name of the type of function for which the definite integral must be evaluated (e.g., ‘linear’, ‘quadratic’)
coefficients (list of int or float) – Coefficients of the original function to integrate
start (int or float) – Value of the x-coordinate of the first point to use for evaluating the definite integral
end (int or float) – Value of the x-coordinate of the second point to use for evaluating the definite integral
precision (int, default=4) – Maximum number of digits that can appear after the decimal place of the result
- Raises
ValueError – First argument must be either ‘linear’, ‘quadratic’, ‘cubic’, ‘hyperbolic’, ‘exponential’, ‘logarithmic’, ‘logistic’, or ‘sinusoidal’
TypeError – Second argument must be a 1-dimensional list containing elements that are integers or floats
TypeError – Third and fourth arguments must be integers or floats
ValueError – Third argument must be less than or equal to fourth argument
ValueError – Last argument must be a positive integer
- Returns
area – Definite integral of the original equation, evaluated between two points; if start and end values are identical, then definite integral will be zero
- Return type
float
See also
linear_integral(),quadratic_integral(),cubic_integral(),hyperbolic_integral(),exponential_integral(),logarithmic_integral(),logistic_integral(),sinusoidal_integral()Notes
Definite integral of a function: \(\int_{a}^{b} f(x) \,dx = F(b) - F(a)\)
Examples
- Import accumulated_area function from regressions library
>>> from regressions.analyses.accumulation import accumulated_area
- Evaluate the definite integral of a linear function with coefficients 2 and 3 between the end points 10 and 20
>>> area_linear = accumulated_area('linear', [2, 3], 10, 20) >>> print(area_linear) 330.0
- Evaluate the definite integral of a cubic function with coefficients 8, 6, -10, and 7 between the end points 10 and 20
>>> area_cubic = accumulated_area('cubic', [8, 6, -10, 7], 10, 20) >>> print(area_cubic) 312570.0