Intercepts of Graph¶
- intercept_points(equation_type, coefficients, precision=4)¶
Calculates the roots of a specific function
- Parameters
equation_type (str) – Name of the type of function for which intercepts must be determined (e.g., ‘linear’, ‘quadratic’)
coefficients (list of int or float) – Coefficients to use to generate the equation to investigate
precision (int, default=4) – Maximum number of digits that can appear after the decimal place of the results
- 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
ValueError – Last argument must be a positive integer
- Returns
points – Values of the x-coordinates at which the original function crosses the x-axis; if the function is sinusoidal, then only the initial results within a four-period interval will be listed, but general forms will also be included; if the function has no x-intercepts, then it will return a list of None
- Return type
list of float or str
See also
Roots for key functions:
linear_roots(),quadratic_roots(),cubic_roots(),hyperbolic_roots(),exponential_roots(),logarithmic_roots(),logistic_roots(),sinusoidal_roots()Graphical analysis:
critical_points(),sign_chart(),key_coordinates()
Notes
Domain of a function: \(x_i = \{ x_1, x_2, \cdots, x_n \}\)
X-intercepts (roots) of the function: \(x_r = \{ r \mid r \in x_i, f(r) = 0 \}\)
Examples
- Import intercept_points function from regressions library
>>> from regressions.analyses.intercepts import intercept_points
- Calculate the roots of a cubic function with coefficients 1, -15, 66, and -80
>>> points_cubic = intercept_points('cubic', [1, -15, 66, -80]) >>> print(points_cubic) [2.0, 5.0, 8.0]
- Calculate the roots of a sinusoidal function with coefficients 3, 1, -2, and 3
>>> points_sinusoidal = intercept_points('sinusoidal', [3, 1, -2, 3]) >>> print(points_sinusoidal) [-3.5708, 2.7124, 8.9956, 15.2788, 21.5619, '-3.5708 + 6.2832k']