What a polynomial is
A polynomial adds up whole-number powers of , each multiplied by a fixed number:
The fixed numbers are the coefficients. The highest power with a nonzero coefficient, , is the degree. The last coefficient, , is the constant term: it is the value at zero, .
| polynomial | degree | name |
|---|---|---|
| 0 | constant | |
| 1 | linear: a line, lesson 1.2.1 | |
| 2 | quadratic, lesson 1.2.2 | |
| 3 | cubic | |
| 4 | quartic |
The powers must be 0, 1, 2, 3 and so on. So and are not polynomials, and neither is , where sits in the power.
Evaluating a polynomial
To evaluate at a number, put that number in place of every . The running example in this lesson is the cubic . At its terms are , so .
Here is at more inputs. At 0 it is , its constant term.
| 0.5 | 1 | 1.5 | 2 | 2.5 | 3 | |
|---|---|---|---|---|---|---|
| 0 | 0.375 | 0 | 0 |
Try it
NumPy stores a polynomial as its list of coefficients, highest power first, with a 0 for each missing power. np.polyval evaluates it at one input or at a whole list.
The second line is the table. The cubic has no term, so its list is [1, 0, -7, 6].
Roots and factors
A root of is an input with . On the graph, the roots are where the curve meets the -axis: the zeros of lesson 1.1.1. The table shows three roots of the cubic: 1, 2 and 3.
Those roots come from factors. Multiply out , two brackets at a time:
A product is zero exactly when one of its factors is zero. So the factored form shows the roots at a glance.
Rule: Factor theorem
If is a root, then is times a polynomial one degree lower. If is a factor, then is a root. A negative root gives the factor .
The cubic crosses the axis at its three roots, one for each factor. Its sign flips at each root.
Finding the other roots from one
Once you know one root, the rest come from a polynomial of lower degree. Take .
When the coefficients are whole numbers, a whole-number root must divide the constant term, so try . The first try works: .
So for some numbers and . Multiply out the right side, then match each power with :
The terms give , so . The constants give , so . The terms check the answer: , as it should be.
The quadratic factor is , by factoring or by the quadratic formula of lesson 1.2.2. So , with roots 1, 2 and .
Try it
np.polydiv(q, [1, -1]) divides by . It returns the quotient's coefficients, for , and a remainder of 0, which confirms the factor.
np.roots finds every root from the coefficients. Its answers are decimals, in no fixed order.
Double roots
The quadratic is . Its discriminant is 0 (lesson 1.2.2), and its only root is 2. The factor appears twice, so 2 is a double root.
At a double root the graph touches the axis and turns back without crossing. On both sides of 2 the value is positive: 0.01 at 1.9 and 0.01 at 2.1. The sign does not change.
A cubic can have one too: multiplies out to . It is at 0.5, 0 at 1 and at 1.5, so it touches the axis at 1; at 3 it crosses.
In general, a factor repeated an even number of times touches the axis, and one repeated an odd number of times crosses it.
How many roots
The factor theorem limits the count. Each root takes a factor of degree 1, and a polynomial of degree has room for only of them.
Rule: Counting roots
A polynomial of degree has at most real roots, counting a double root twice. It may have fewer.
The cubic has the full three: , 0 and 2. Its constant term is 0, so 0 is a root. Fewer is common: has two different roots, and has just one, 2.
Three cubics with three, two and one real roots. None can have more than three.
An odd degree always gives at least one real root. Far from 0 the highest power outweighs the rest: at , is 1,000,000 while the other terms of add up to . So a cubic ends far below the axis on one side and far above it on the other, and must cross in between.
An even degree can miss the axis altogether. is never below 1, so it has no real root.
Try it
np.roots always returns roots for degree . For it gives 2 and two complex roots, written with j; for , only complex ones. They are not real numbers and do not appear on the graph; lesson 1.7.2 introduces them.
For the double root, rounding error pulls the two copies of 1 slightly apart: each gets a tiny j part, about . Rounding to six places shows 1 twice.
Sign changes
Between two neighbouring roots a polynomial keeps one sign, and at a single root the sign flips. The cubic shows it: at 0.5, then 0.375 at 1.5, then at 2.5.
The graph of a polynomial has no gaps or jumps. So it cannot get from below the axis to above it without crossing, and two values are enough to prove a root exists.
Rule: A sign change brackets a root
Opposite signs give a negative product, and then at least one root lies between and . Lesson 1.3.2 uses this to trap a root and close in on it.
The test only works one way.
- A sign change means at least one root, not exactly one. and , and all three roots lie between.
- No sign change does not mean no root. and are both negative, yet the roots 1 and 2 lie between them. A double root gives no sign change either.
A graph with no gaps or jumps is called continuous; lesson 2.1.2 makes the idea exact. Case study 1.3.5 meets a polynomial whose roots are interest rates.
Try it
brackets applies the rule to two inputs. It gives True for 0.5 and 1.5, and for 0 and 4.
It gives False for 0.5 and 2.5, although two roots lie between them.
Common mistakes
- A root gives the factor , not . The root gives .
- The degree is the highest power, not the number of terms. has degree 5.
- Give NumPy every power, highest first. is
[1, 0, -7, 6];[1, -7, 6]would mean . - At most roots, not exactly . The
janswers ofnp.rootsare not real roots, and a tinyjpart on a real number is rounding. - No sign change does not mean no root. Two roots, or a double root, leave the sign unchanged.
- A sign change means at least one root. There may be three, or any odd number.
Polynomials and roots
0 of 12 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Summary card
- A polynomial of degree adds powers of up to , each with a coefficient; its constant term is .
- is a root when , and then is a factor. Knowing one root leaves a polynomial one degree lower.
- A double root, from a squared factor, touches the axis without crossing.
- Degree means at most real roots. An odd degree has at least one.
- If and have opposite signs, at least one root lies between them. No sign change does not rule a root out.
np.polyval(coeffs, x)evaluates,np.polydivdivides out a factor, andnp.roots(coeffs)finds every root. List the coefficients highest power first, with 0 for missing powers.