Sinusoidal Derivatives¶
- sinusoidal_derivatives(first_constant, second_constant, third_constant, fourth_constant, precision=4)¶
Calculates the first and second derivatives 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
derivatives[‘first’][‘constants’] (list of float) – Coefficients of the resultant first derivative
derivatives[‘first’][‘evaluation’] (func) – Function for evaluating the resultant first derivative at any float or integer argument
derivatives[‘second’][‘constants’] (list of float) – Coefficients of the resultant second derivative
derivatives[‘second’][‘evaluation’] (func) – Function for evaluating the resultant second derivative at any float or integer argument
Notes
Standard form of a sinusoidal function: \(f(x) = a\cdot{\sin(b\cdot(x - c))} + d\)
First derivative of a sinusoidal function: \(f'(x) = ab\cdot{\cos(b\cdot(x - c))}\)
Second derivative of a sinusoidal function: \(f''(x) = -ab^2\cdot{\sin(b\cdot(x - c))}\)
Examples
- Import sinusoidal_derivatives function from regressions library
>>> from regressions.analyses.derivatives.sinusoidal import sinusoidal_derivatives
- Generate the derivatives of a sinusoidal function with coefficients 2, 3, 5, and 7, then display the coefficients of its first and second derivatives
>>> derivatives_constants = sinusoidal_derivatives(2, 3, 5, 7) >>> print(derivatives_constants['first']['constants']) [6.0, 3.0, 5.0] >>> print(derivatives_constants['second']['constants']) [-18.0, 3.0, 5.0]
- Generate the derivatives of a sinusoidal function with coefficients 7, -5, -3, and 2, then evaluate its first and second derivatives at 10
>>> derivatives_evaluation = sinusoidal_derivatives(7, -5, -3, 2) >>> print(derivatives_evaluation['first']['evaluation'](10)) 19.6859 >>> print(derivatives_evaluation['second']['evaluation'](10)) 144.695
- Generate the derivatives of a sinusoidal function with all inputs set to 0, then display the coefficients of its first and second derivatives
>>> derivatives_zeroes = sinusoidal_derivatives(0, 0, 0, 0) >>> print(derivatives_zeroes['first']['constants']) [0.0001, 0.0001, 0.0001] >>> print(derivatives_zeroes['second']['constants']) [-0.0001, 0.0001, 0.0001]