Calculators and computer processors cannot directly compute functions like $\sin(x)$ or $e^x$. Instead, they use polynomial approximations!
In 1715, English mathematician Brook Taylor discovered that any smooth function can be represented near $x = 0$ as an infinite polynomial series:
$$\sin(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \dots$$
where $3! = 6$, $5! = 120$, and $7! = 5040$.
The first few partial sums are called Taylor polynomials:
$P_1(x) = x$ (linear approximation)
$P_3(x) = x - \frac{x^3}{6}$ (cubic approximation)
$P_5(x) = x - \frac{x^3}{6} + \frac{x^5}{120}$ (quintic approximation)
Using the new plot2() function, we can plot $\sin(x)$ and its Taylor polynomial on the exact same chart to watch how closely the polynomial hugs the true curve!
plot2(x,y1,y2,label1,label2)
Move the mouse over a dotted box for more information.
Now you try. Add the next Taylor term (x^5 / 120) to see how much farther the approximation stays accurate!
Type your code here:
See your results here:
The code has ???? for the Taylor polynomial formula. Replace ???? with x - (x^3) / 6 and click Run to compare $\sin(x)$ with its Taylor approximation!
Notes:
plot2(x, y1, y2, label1, label2, title, xtitle, ytitle) plots two continuous curves on the same chart with color-coded legend badges.
Notice that between $-1$ and $+1$ radians (about $-57^\circ$ to $+57^\circ$), the difference between $\sin(x)$ and $P_3(x)$ is almost completely invisible!
Higher degree polynomials hug the true curve over wider and wider intervals.
Share your code
Show a friend, family member, or teacher what you've done!