TExcelTAD
Home › Pre-Calculus, Geometry & Trigonometry › Polynomial Functions

Polynomial Functions

Polynomials are the simplest functions beyond lines and parabolas: only additions and multiplications by xx. That makes them cheap to compute, easy to differentiate and good at approximating almost anything. This lesson is about reading a polynomial's graph from its formula: end behaviour, zeros, multiplicities and turning points.

Vocabulary

A polynomial function has the form

p(x)=anxn+an−1xn−1+⋯+a1x+a0,an≠0p(x) = a_n x^n + a_{n-1} x^{n-1} + \cdots + a_1 x + a_0, \qquad a_n \ne 0
  • nn is the degree, ana_n the leading coefficient, a0a_0 the constant term (the y-intercept, p(0)=a0p(0) = a_0).
  • Degree 0: constant, 1: linear, 2: quadratic, 3: cubic, 4: quartic, 5: quintic.
  • The domain is always all of R\mathbb{R}, and the graph is a smooth unbroken curve with no corners or gaps.

The algebra of polynomials (adding, multiplying, dividing, factoring) is covered in the Algebra course, from polynomial definitions to dividing polynomials. Here we look at them as functions.

End behaviour

For large ∣x∣\lvert x \rvert the leading term anxna_n x^n dominates all the others, so the ends of the graph depend only on the degree's parity and the leading coefficient's sign:

an>0a_n > 0 an<0a_n < 0
nn even up on both ends (like x2x^2) down on both ends (like −x2-x^2)
nn odd down on the left, up on the right (like x3x^3) up on the left, down on the right (like −x3-x^3)
python · try it yourself
p = lambda x: 2 * x**3 - 40 * x**2 + 5 * x + 100
for x in [10, 100, 1000, 10_000]:
    print(f"x = {x:>6}: p(x) = {p(x):>16}, 2x³ = {2 * x**3:>16}, ratio = {p(x) / (2 * x**3):.4f}")
x =     10: p(x) =            -1850, 2x³ =             2000, ratio = -0.9250
x =    100: p(x) =          1600600, 2x³ =          2000000, ratio = 0.8003
x =   1000: p(x) =       1960005100, 2x³ =       2000000000, ratio = 0.9800
x =  10000: p(x) =    1996000050100, 2x³ =    2000000000000, ratio = 0.9980

Near x=10x = 10 the other terms still matter, but further out p(x)p(x) behaves like 2x32x^3.

Zeros, factors and multiplicity

The factor theorem: rr is a zero of pp (p(r)=0p(r) = 0) exactly when (x−r)(x - r) is a factor of pp. A polynomial of degree nn has at most nn real zeros. (Counting complex zeros with multiplicity, it has exactly nn: the fundamental theorem of algebra.)

If (x−r)(x - r) appears kk times in the factorisation, rr has multiplicity kk, and the graph's behaviour at rr tells you whether kk is odd or even:

Multiplicity Graph at x=rx = r
1 crosses the axis like a line
even (2, 4, …) touches the axis and turns back
odd ≥3\ge 3 crosses, flattening out like x3x^3

Between consecutive zeros the sign of pp cannot change, because the graph has no gaps (this is the intermediate value theorem). So the zeros split the line into intervals with a constant sign, which is how you solve polynomial inequalities.

A degree-nn polynomial has at most n−1n - 1 turning points (local peaks and valleys).

Example. p(x)=−(x+2)(x−1)2(x−3)p(x) = -(x + 2)(x - 1)^2(x - 3). Degree 4, leading coefficient −1-1: both ends go down. Zeros: −2-2 (crosses), 1 (touches, multiplicity 2), 3 (crosses). y-intercept: p(0)=−(2)(1)(−3)=6p(0) = -(2)(1)(-3) = 6.

python · try it yourself
import numpy as np
import sympy as sp
import matplotlib.pyplot as plt

x = sp.Symbol("x")
p = -(x + 2) * (x - 1)**2 * (x - 3)
print("expanded:", sp.expand(p))
print("zeros with multiplicity:", sp.roots(sp.Poly(p, x)))
print("p(0) =", p.subs(x, 0))
crit = sp.Poly(sp.diff(p, x), x).nroots()
print("turning points at x ≈", [round(float(c), 4) for c in crit])

f = sp.lambdify(x, p, "numpy")
xs = np.linspace(-2.6, 3.6, 400)
plt.figure(figsize=(6, 4))
plt.plot(xs, f(xs), color="purple")
plt.plot([-2, 1, 3], [0, 0, 0], "ko")
plt.axhline(0, color="gray", lw=0.7); plt.ylim(-25, 20); plt.grid(alpha=0.3)
plt.title("p(x) = −(x + 2)(x − 1)²(x − 3)")
expanded: -x**4 + 3*x**3 + 3*x**2 - 11*x + 6
zeros with multiplicity: {3: 1, -2: 1, 1: 2}
p(0) = 6
turning points at x ≈ [-1.1472, 1.0, 2.3972]

Three turning points, the maximum possible for degree 4. One of them is the touch point at x=1x = 1.

Finding zeros

  • Factoring works for small, nice examples.
  • Rational root theorem: if pp has integer coefficients, any rational zero p/qp/q in lowest terms has pp dividing a0a_0 and qq dividing ana_n. For x3−2x2−5x+6x^3 - 2x^2 - 5x + 6 the candidates are ±1,±2,±3,±6\pm 1, \pm 2, \pm 3, \pm 6; testing finds 1, −2-2 and 3.
  • Numerically: numpy.roots finds all complex roots from the coefficient list (it computes the eigenvalues of the companion matrix); for a single root in a bracket, use bisection or Newton's method (Newton's method).
python · try it yourself
import numpy as np

coeffs = [1, -2, -5, 6]                        # x³ − 2x² − 5x + 6
candidates = [s * d for d in (1, 2, 3, 6) for s in (1, -1)]
print("rational roots:", sorted(r for r in candidates if np.polyval(coeffs, r) == 0))
print("numpy.roots   :", sorted(round(float(r.real), 6) for r in np.roots(coeffs)))

q = [1, 0, 0, 0, -16]                          # x⁴ − 16
print("roots of x⁴ − 16:", [complex(round(r.real, 6), round(r.imag, 6)) for r in np.roots(q)])
rational roots: [-2, 1, 3]
numpy.roots   : [-2.0, 1.0, 3.0]
roots of x⁴ − 16: [(-2+0j), 2j, -2j, (2+0j)]

x4−16=(x−2)(x+2)(x2+4)x^4 - 16 = (x - 2)(x + 2)(x^2 + 4) has two real zeros and two complex ones, ±2i\pm 2i.

In software

  • Fast evaluation with Horner's rule. p(x)=((anx+an−1)x+…)x+a0p(x) = ((a_n x + a_{n-1})x + \ldots)x + a_0 needs nn multiplications and no powers. numpy.polyval and most math libraries do this (Horner).
  • Approximating other functions. math.sin and math.exp are implemented with carefully chosen polynomials on a small interval (Taylor series).
  • Animation curves. smoothstep s(t)=3t2−2t3s(t) = 3t^2 - 2t^3 eases from 0 to 1 with zero slope at both ends; cubic Bézier curves in CSS cubic-bezier() and vector graphics are polynomial in tt (easing, Bézier curves).
  • Fitting data. numpy.polyfit finds the polynomial that best fits points; a high degree overfits, wiggling wildly between the points, a lesson that carries straight into machine learning.

Exercises

Exercise 1: End behaviour

Describe the end behaviour of p(x)=−3x5+4x2−1p(x) = -3x^5 + 4x^2 - 1 and of q(x)=0.5x4−100x3q(x) = 0.5x^4 - 100x^3.

Answer

pp: up on the left, down on the right. qq: up on both ends.

Solution

pp has odd degree and negative leading coefficient (like −x5-x^5). qq has even degree and positive leading coefficient (like x4x^4); the −100x3-100x^3 term only matters for moderate xx.

Exercise 2: Read the graph from the factors

For p(x)=x(x−2)2(x+3)3p(x) = x(x - 2)^2(x + 3)^3, give the degree, the zeros with multiplicities, and whether the graph crosses or touches at each.

Answer

Degree 6. 0 (mult. 1, crosses), 2 (mult. 2, touches), −3-3 (mult. 3, crosses with a flattening).

Solution

Degree=1+2+3=6\text{Degree} = 1 + 2 + 3 = 6, leading coefficient +1+1, so both ends go up.

python · try it yourself
import sympy as sp
x = sp.Symbol("x")
print(sp.roots(sp.Poly(x * (x - 2)**2 * (x + 3)**3, x)))
{2: 2, -3: 3, 0: 1}

Exercise 3: Build a polynomial

Find the cubic with zeros −1-1, 2 and 4 whose y-intercept is 16.

Answer

p(x)=2(x+1)(x−2)(x−4)=2x3−10x2+4x+16p(x) = 2(x + 1)(x - 2)(x - 4) = 2x^3 - 10x^2 + 4x + 16.

Solution
p(x)=a(x+1)(x−2)(x−4)p(0)=a(1)(−2)(−4)=8a=16⇒a=2\begin{aligned} p(x) &= a(x + 1)(x - 2)(x - 4) \\ p(0) &= a(1)(-2)(-4) = 8a = 16 \quad\Rightarrow\quad a = 2 \end{aligned}
python · try it yourself
import sympy as sp
x = sp.Symbol("x")
p = 2 * (x + 1) * (x - 2) * (x - 4)
print(sp.expand(p), "| p(0) =", p.subs(x, 0))
2*x**3 - 10*x**2 + 4*x + 16 | p(0) = 16

Exercise 4: Solve an inequality

Solve (x+1)(x−2)(x−5)>0(x + 1)(x - 2)(x - 5) > 0.

Answer

(−1,2)∪(5,∞)(-1, 2) \cup (5, \infty).

Solution

The zeros −1,2,5-1, 2, 5 split R\mathbb{R} into four intervals. Test one point in each:

x=−2:(−)(−)(−)<0x=0:(+)(−)(−)>0✓x=3:(+)(+)(−)<0x=6:(+)(+)(+)>0✓\begin{aligned} x = -2{:} &\quad (-)(-)(-) < 0 \\ x = 0{:} &\quad (+)(-)(-) > 0 && \checkmark \\ x = 3{:} &\quad (+)(+)(-) < 0 \\ x = 6{:} &\quad (+)(+)(+) > 0 && \checkmark \end{aligned}

Exercise 5: Horner's rule

Write horner(coeffs, x) (coefficients from highest degree down) and evaluate 2x4−3x3+x−72x^4 - 3x^3 + x - 7 at x=3x = 3. Check against numpy.polyval.

Answer

p(3)=77p(3) = 77.

Solution
python · try it yourself
import numpy as np

def horner(coeffs, x):
    acc = 0
    for c in coeffs:
        acc = acc * x + c
    return acc

c = [2, -3, 0, 1, -7]
print(horner(c, 3), int(np.polyval(c, 3)))
77 77

By hand: 2⋅81−3⋅27+0⋅9+3−7=162−81+0+3−7=772 \cdot 81 - 3 \cdot 27 + 0 \cdot 9 + 3 - 7 = 162 - 81 + 0 + 3 - 7 = 77. Note the 0 in the coefficient list for the missing x2x^2 term; leaving it out is a classic bug.

Test yourself

At most how many turning points can a degree-5 polynomial have?

  1. 3
  2. 4
  3. 5
  4. 6

p(x)=(x−4)2(x+1)p(x) = (x - 4)^2 (x + 1). What does the graph do at x=4x = 4?

  1. Crosses the axis
  2. Touches the axis and turns back
  3. Has a vertical asymptote
  4. Has a gap

Which polynomial falls on both ends?

  1. x3−xx^3 - x
  2. −x4+10x3-x^4 + 10x^3
  3. x4−10x3x^4 - 10x^3
  4. −x3+x-x^3 + x