The tangent is the degree-1 copy
A Taylor polynomial copies a function near one point with a polynomial, which needs only adding and multiplying. The simplest copy is the tangent line of lesson 2.2.1.
Rule: Degree-1 copy: the tangent
It copies two facts about at : the value, since , and the slope, since the slope of is everywhere.
For at , both the value and the slope are (lesson 2.3.4), so . Lesson 2.4.2 measured the gaps: 0.3679 at , 0.1487 at 0.5 and 0.7183 at 1. The curve bends away from the line.
Case studies 2.2.4 and 2.3.7 used this line for a bond price: minus its slope, per unit of price, is the duration.
The quadratic copy, from
To follow the bend, add a term . At it is 0, and so is its slope . So it leaves the value and the slope of the copy alone.
Its second derivative is everywhere. To match the bend of at , set , so . That is where the comes from.
Rule: Degree-2 copy
The best quadratic copy of near : it matches the value, the slope and the second derivative. Without the its second derivative would be , twice the bend.
This is the copy lesson 2.4.2 promised, built from . Case study 2.4.5's duration–convexity estimate has the same , because it is this copy of a bond price (case study 2.7.4).
Example 1: at 0. Every derivative of is , so and .
| 0.5 | 1 | |||
|---|---|---|---|---|
| 0.3679 | 0.6065 | 1.6487 | 2.7183 | |
| gap to | 0.3679 | 0.1065 | 0.1487 | 0.7183 |
| gap to | 0.0237 | 0.2183 |
The bend term cuts the gap at 0.5 from 0.1487 to 0.0237. Left of 0 the gap turns negative: there is slightly above the curve. A later section explains the sign.
Example 2: at 1. Here , and (lessons 2.3.4 and 2.4.2). So
The bend term is negative, because is concave down. At 1.1, against : a gap of 0.0003, where the tangent's gap is . At 1.5 the gap is 0.0305, against the tangent's .
Try it
quadratic_copy takes the value, slope and second derivative at from SymPy and builds . SymPy writes the terms in its own order.
The first loop prints the gaps to and for , as in the table. The second does the same for at 1.1 and 1.5.
Where Newton's constant comes from
Lesson 2.4.3 found that near a root , each Newton error is about times the square of the last. Newton's step follows the tangent at the guess . The quadratic copy about shows what that leaves out.
At the root, . Write the quadratic copy about and evaluate it at :
Divide by . Newton's step is , so the first two terms become . With errors , this leaves
As closes in on , the constant becomes : 0.819 for and 0.354 for , as in lesson 2.4.3. For the quadratic copy is exact, since is a quadratic. So holds exactly: from , and .
Try it
errors runs 12 Newton steps, takes the last guess as the root, and returns the first five errors. Each line prints for four steps, then .
For , and (lesson 2.4.3), so cancels. Both lines settle on the constant: 0.819 and 0.354.
Degree about any point
Keep going: add a cube term , then a fourth power, and so on. Each new term is chosen to match one more derivative of at . Write for the -th derivative, so , , and itself.
Why each term has a
Differentiate three times with the power rule (lesson 2.3.1):
The power rule brings down 3, then 2, then 1, so the third derivative is . At , the lower derivatives are 0, because a factor is left. Higher derivatives are 0, because the 6 is a constant.
So the -th derivative of at is , read " factorial": . To match , divide by it: .
| 0 | 1 | 2 | 3 | 4 | 5 | |
|---|---|---|---|---|---|---|
| 1 | 1 | 2 | 6 | 24 | 120 |
By convention , so the same formula gives the constant term . The factorials grow fast, which is why later terms are often small.
Rule: Taylor polynomial of degree n about a
It matches and its first derivatives at . Each term has the units of . With a step , the same copy reads .
The coefficients are numbers: the derivatives are taken at , not at . The step form is the one case study 2.7.4 and lesson 2.8.1 use.
Example 1: about 0. Every derivative is , which is 1 at 0, so
At , against : a gap of 0.0029. The figure shows each degree hugging the curve over a wider stretch.
and its Taylor polynomials of degree 1, 2 and 3 about 0. Each extra term matches one more derivative at 0; at the gap falls from 0.72 to 0.22 to 0.05.
Example 2: about 2. The derivatives are , and 6, then 0. At 2 they are 12, 12 and 6.
| 0 | 1 | 2 | 3 | 4 | |
|---|---|---|---|---|---|
| 8 | 12 | 12 | 6 | 0 | |
| 1 | 1 | 2 | 6 | 24 | |
| coefficient | 8 | 12 | 6 | 1 | 0 |
So . With this is , the expansion of in lesson 2.2.1. A polynomial of degree 3 is its own Taylor polynomial of degree 3, with no error at all.
Try it below. Raise the degree from 1 to 5 and watch the copy of hug the curve further from the centre. Then move the centre to 1 and slide towards it: the error shrinks fast as nears .
Explore
Raise the degree and watch the polynomial hug the curve further from its centre. Move the centre, then the point, and compare the error with the first term left out.
y = eˣits Taylor polynomial p1The large dot is the centre; the dashed line at x is the error.
- Polynomial
- At x = 1
- = 2.71828, = 2
- Error
- 0.71828
- First term left out
- 0.5
- Reach
- The series reaches every x: with enough terms the error shrinks to zero.
Try it
taylor builds about from SymPy's derivatives and sp.factorial. The first line prints to .
SymPy multiplies out as . For about 2, sp.expand of prints 0: the copy is exact.
How fast the error falls
Near , the error behaves like a constant times : the first power the copy leaves out. Halve the distance to and the error shrinks about times.
| 0.4 | 0.2 | 0.1 | shrinks by | |
|---|---|---|---|---|
| error of | 0.0918 | 0.0214 | 0.00517 | about 4 |
| error of | 0.0118 | 0.0014 | 0.000171 | about 8 |
| error of | 0.00116 | 0.0000694 | 0.00000425 | about 16 |
These are the errors for about 0. The tangent's error falls like , as in lesson 2.2.1; one more term makes it fall like , then .
Rule: Error near a
For near , with a constant that depends on and . Lesson 2.7.2 shows how to find , and how big the error can be further out.
On log scales a power of is a straight line whose slope is the power. So each error is a line of slope .
The error of , and for against the distance from 0, on log scales. The slopes are 2, 3 and 4: one more term adds one to the power.
Both sides of
The sign of the error follows . An even power is positive on both sides of ; an odd power changes sign at .
For the tangent's error, like , is positive both ways: lies above its tangent (lesson 2.4.2). The quadratic copy's error, like , is negative left of 0.
That is why overshoots at : 0.625 against 0.6065. Its size still shrinks about 8 times per halving: 0.00968, 0.00127 and 0.000163 at , and .
When a term is missing
If a coefficient is 0, the copy gains nothing from that degree. At an inflection point (lesson 2.4.2), so the quadratic copy is just the tangent.
Take at 0. Its derivatives there are 0, , 0 and 6, so . The error is exactly: it falls like the next power that is actually present.
Far from , and where there is no copy
Far from the rule says nothing. At , for gives , against . Lesson 2.7.2 asks how many terms fix that, and finds functions where no number of terms will.
A Taylor polynomial needs the derivatives at . A corner, such as at 0, has no slope (lesson 2.2.2), and neither has a vertical tangent, such as at 0. At such a point there is no copy of degree 1 or more.
Try it
The first loop prints the errors of , and at 0.4, 0.2 and 0.1, then each error divided by the next. 6.94e-05 is Python's way of writing 0.0000694.
The last lines check the negative side for , and at 3.
Common mistakes
- Keep the . The cube term of about 0 is , not ; the quadratic term is , not .
- Take the derivatives at . The coefficients are numbers such as , not functions of .
- Use powers of . About , the copy of is , not .
- The error rule holds near . Far away, more degree may still leave a large error.
- Mind the sign on the left. An odd power makes the error change sign at .
- A zero coefficient adds nothing. At an inflection point .
Taylor polynomials
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
- The tangent is the degree-1 copy of near : same value and slope.
- The quadratic copy adds ; the makes its second derivative equal .
- Degree : . The undoes the factors the power rule brings down; .
- Near the error behaves like : halve the distance and it shrinks times. Odd powers change sign at ; a zero coefficient skips a power.
- The quadratic copy about a Newton guess gives .