Sinusoidal Roots¶
- sinusoidal_roots(first_constant, second_constant, third_constant, fourth_constant, precision=4)¶
Calculates the roots of a sinusoidal function
- Parameters
first_constant (int or float) – Vertical stretch factor of the original sine function; if zero, it will be converted to a small, non-zero decimal value (e.g., 0.0001)
second_constant (int or float) – Horizontal stretch factor of the original sine function; if zero, it will be converted to a small, non-zero decimal value (e.g., 0.0001)
third_constant (int or float) – Horizontal shift of the original sine function; if zero, it will be converted to a small, non-zero decimal value (e.g., 0.0001)
fourth_constant (int or float) – Vertical shift of the original sine 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 four arguments must be integers or floats
ValueError – Last argument must be a positive integer
- Returns
roots – List of the x-coordinates of the initial x-intercepts within two periods of the original function in float format, along with the general forms in string format that can be used to determine all other x-intercepts by plugging in any integer value for ‘k’ and evaluating; if the function never crosses the x-axis, then it will return a list of None
- Return type
list of float or str
Notes
Standard form of a sinusoidal function: \(f(x) = a\cdot{\sin(b\cdot(x - c))} + d\)
Sinusoidal formula: \(x_0 = c + \frac{1}{b}\cdot{\sin^{-1}(-\frac{d}{a})} + \frac{2\pi}{b}\cdot{k}\)
\(\text{if} -1 < -\frac{d}{a} < 0 \text{ or } 0 < -\frac{d}{a} < 1, x_1 = c + \frac{\pi}{b} - \frac{1}{b}\cdot{\sin^{-1}(-\frac{d}{a})} + \frac{2\pi}{b}\cdot{k}\)
\(\text{if} -\frac{d}{a} = 0, x_1 = c - \frac{\pi}{b} + \frac{2\pi}{b}\cdot{k}\)
\(k \in \mathbb{Z}\)
Examples
- Import sinusoidal_roots function from regressions library
>>> from regressions.analyses.roots.sinusoidal import sinusoidal_roots
- Calculate the roots of a sinusoidal function with coefficients 2, 3, 5, and 7
>>> roots_first = sinusoidal_roots(2, 3, 5, 7) >>> print(roots_first) [None]
- Calculate the roots of a sinusoidal function with coefficients 7, -5, -3, and 2
>>> roots_second = sinusoidal_roots(7, -5, -3, 2) >>> print(roots_second) [-8.7128, -7.9686, -7.4562, -6.712, -6.1995, -5.4553, -4.9429, -4.1987, -3.6863, -2.942, '-3.6863 + 1.2566k', '-2.942 + 1.2566k']
- Calculate the roots of a sinusoidal function with all inputs set to 0
>>> roots_zeroes = sinusoidal_roots(0, 0, 0, 0) >>> print(roots_zeroes) [-15707.9632, 47123.8899, 109955.743, 172787.596, 235619.4491, '-15707.9632 + 62831.8531k']