pint.utils.taylor_horner
- pint.utils.taylor_horner(x, coeffs)[source]
Evaluate a Taylor series of coefficients at x via the Horner scheme.
For example, if we want: 10 + 3*x/1! + 4*x^2/2! + 12*x^3/3! with x evaluated at 2.0, we would do:
In [1]: taylor_horner(2.0, [10, 3, 4, 12]) Out[1]: 40.0
- Parameters:
x (float or numpy.ndarray or astropy.units.Quantity) – Input value; may be an array.
coeffs (list of astropy.units.Quantity or uncertainties.ufloat) – Coefficient array; must have length at least one. The coefficient in position
i
is multiplied byx**i
. Each coefficient should just be a number, not an array. The units should be compatible once multiplied by an appropriate power of x.
- Returns:
Output value; same shape as input. Units as inferred from inputs.
- Return type: