Understanding the polynomial evaluator — concept and principle
This calculator evaluates a polynomial p(x) = a₀xⁿ + a₁xⁿ⁻¹ + … + aₙ and its first derivative p′(x) at a chosen x. Enter the coefficients from the highest power down to the constant. Evaluating polynomials is a basic step in checking roots, plotting curves, interpolation, Taylor approximations and Newton's method, where both p(x) and p′(x) are needed at each step.
How it is calculated
Horner's method rewrites the polynomial as nested multiplication:
p(x) = (…((a₀x + a₁)x + a₂)x + …)x + aₙ
Start with s = 0; for each coefficient in order, set s ← s·x + coefficient. The final s is p(x).
Derivative: the power rule turns aₖxᵐ into m·aₖxᵐ⁻¹. The calculator multiplies each coefficient (except the constant) by its power to get the coefficients of p′, then evaluates them with Horner's method as well.
The principle
Written the usual way, a degree-n polynomial needs many separate powers of x. Horner's nesting reuses each partial result, so it needs only n multiplications and n additions, which is the minimum for a general polynomial and also reduces rounding error. Each intermediate value of s is itself useful: the sequence of s values gives the coefficients of the quotient when p(x) is divided by (x − x₀), the same numbers you get in synthetic division. The final value is the remainder, which equals p(x₀) by the remainder theorem.
Worked example
- Inputs: coefficients 2 −3 0 5, so p(x) = 2x³ − 3x² + 5, at x = 2.
- Horner for p: s = 2; s = 2·2 − 3 = 1; s = 1·2 + 0 = 2; s = 2·2 + 5 = 9. So p(2) = 9.
- Direct check: 2·8 − 3·4 + 5 = 16 − 12 + 5 = 9.
- Derivative coefficients: 2·3 = 6, −3·2 = −6, 0·1 = 0, so p′(x) = 6x² − 6x.
- Horner for p′: s = 6; s = 6·2 − 6 = 6; s = 6·2 + 0 = 12. So p′(2) = 12.
| x | p(x) |
|---|---|
| 0.5 | 4.5 |
| 1 | 4 |
| 1.5 | 5 |
| 2 | 9 |
| 2.5 | 17.5 |
| 3 | 32 |
| 4 | 85 |
How to read the result
p(x) is the height of the curve at x. p′(x) is the slope of the tangent there: positive means the polynomial is increasing, negative means decreasing, and zero marks a possible maximum, minimum or flat point. In the example the curve passes through (2, 9) and rises with slope 12. If p(x) = 0, x is a root. The quotient from step 2 (2, 1, 2) also shows p(x) = (x − 2)(2x² + x + 2) + 9.
Common mistakes
- Leaving out zero coefficients. 2x³ − 3x² + 5 has no x term, so a 0 must be entered for it.
- Entering coefficients from the constant upward.
- Forgetting that the derivative of the constant term is zero.
Frequently asked questions
Why use Horner's method instead of computing powers?
It is faster (n multiplications instead of about 2n) and usually more accurate.
How do I get the tangent line at x?
Use y = p(x₀) + p′(x₀)(x − x₀). In the example: y = 9 + 12(x − 2) = 12x − 15.
Can it do the second derivative?
Not directly. Enter the derivative's coefficients (6 −6 0 in the example) as a new polynomial; its p′ is the second derivative.
Sources: D. E. Knuth, The Art of Computer Programming, Vol. 2: Seminumerical Algorithms, §4.6.4 · W. G. Horner, A new method of solving numerical equations of all orders, Philosophical Transactions of the Royal Society, 1819