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)
(poly: Sequence[float], x: float)
| 2 | |
| 3 | |
| 4 | def evaluate_poly(poly: Sequence[float], x: float) -> float: |
| 5 | """Evaluate a polynomial f(x) at specified point x and return the value. |
| 6 | |
| 7 | Arguments: |
| 8 | poly -- the coefficients of a polynomial as an iterable in order of |
| 9 | ascending degree |
| 10 | x -- the point at which to evaluate the polynomial |
| 11 | |
| 12 | >>> evaluate_poly((0.0, 0.0, 5.0, 9.3, 7.0), 10.0) |
| 13 | 79800.0 |
| 14 | """ |
| 15 | return sum(c * (x**i) for i, c in enumerate(poly)) |
| 16 | |
| 17 | |
| 18 | def horner(poly: Sequence[float], x: float) -> float: |
no outgoing calls
no test coverage detected