Quadratic Integral¶
- quadratic_integral(first_constant, second_constant, third_constant, precision=4)¶
Generates the integral of a quadratic function
- Parameters
first_constant (int or float) – Coefficient of the quadratic term of the original quadratic function; if zero, it will be converted to a small, non-zero decimal value (e.g., 0.0001)
second_constant (int or float) – Coefficient of the linear term of the original quadratic function; if zero, it will be converted to a small, non-zero decimal value (e.g., 0.0001)
third_constant (int or float) – Coefficient of the constant term of the original quadratic function; if zero, it will be converted to a small, non-zero decimal value (e.g., 0.0001)
precision (int, default=4) – Maximum number of digits that can appear after the decimal place of the resultant roots
- Raises
TypeError – First three arguments must be integers or floats
ValueError – Last argument must be a positive integer
- Returns
integral[‘constants’] (list of float) – Coefficients of the resultant integral
integral[‘evaluation’] (func) – Function for evaluating the resultant integral at any float or integer argument
Notes
Standard form of a quadratic function: \(f(x) = a\cdot{x^2} + b\cdot{x} + c\)
Integral of a quadratic function: \(F(x) = \frac{a}{3}\cdot{x^3} + \frac{b}{2}\cdot{x^2} + c\cdot{x}\)
Examples
- Import quadratic_integral function from regressions library
>>> from regressions.analyses.integrals.quadratic import quadratic_integral
- Generate the integral of a quadratic function with coefficients 2, 3, and 5, then display its coefficients
>>> integral_constants = quadratic_integral(2, 3, 5) >>> print(integral_constants['constants']) [0.6667, 1.5, 5.0]
- Generate the integral of a quadratic function with coefficients 7, -5, and 3, then evaluate its integral at 10
>>> integral_evaluation = quadratic_integral(7, -5, 3) >>> print(integral_evaluation['evaluation'](10)) 2113.3
- Generate the integral of a quadratic function with all inputs set to 0, then display its coefficients
>>> integral_zeroes = quadratic_integral(0, 0, 0) >>> print(integral_zeroes['constants']) [0.0001, 0.0001, 0.0001]