maths.polynomial_evaluation

Attributes

poly

Functions

evaluate_poly(→ float)

Evaluate a polynomial f(x) at specified point x and return the value.

horner(→ float)

Evaluate a polynomial at specified point using Horner's method.

Module Contents

maths.polynomial_evaluation.evaluate_poly(poly: collections.abc.Sequence[float], x: float) float

Evaluate a polynomial f(x) at specified point x and return the value.

Arguments: poly – the coefficients of a polynomial as an iterable in order of

ascending degree

x – the point at which to evaluate the polynomial

>>> evaluate_poly((0.0, 0.0, 5.0, 9.3, 7.0), 10.0)
79800.0
maths.polynomial_evaluation.horner(poly: collections.abc.Sequence[float], x: float) float

Evaluate a polynomial at specified point using Horner’s method.

In terms of computational complexity, Horner’s method is an efficient method of evaluating a polynomial. It avoids the use of expensive exponentiation, and instead uses only multiplication and addition to evaluate the polynomial in O(n), where n is the degree of the polynomial.

https://en.wikipedia.org/wiki/Horner’s_method

Arguments: poly – the coefficients of a polynomial as an iterable in order of

ascending degree

x – the point at which to evaluate the polynomial

>>> horner((0.0, 0.0, 5.0, 9.3, 7.0), 10.0)
79800.0
maths.polynomial_evaluation.poly = (0.0, 0.0, 5.0, 9.3, 7.0)