← SciSim / Mathematics

Taylor & Maclaurin Series

Partial sums converging to $e^x$, $\sin x$, $\cos x$, $\ln(1+x)$ — with radius of convergence and Lagrange error bounds.
🎓 Tier: Standard Undergraduate — Single-Variable Calculus

📊 Section 1 — Interactive Simulation

Tₙ(x)
f(x) exact
|Error|
n terms
Next term
Radius R

Controls

Function

Display

🪜 Section 2 — The Idea, Step by Step

Start Here — the everyday picture

Your phone has no secret "sine gear" spinning inside it. Deep down, a chip can really only add and multiply — so how does it ever show you $\sin(0.5)$ or $e^x$? It cheats with a polynomial: a plain sum of powers of $x$, tuned to hug the real curve right around one chosen point. Get the height right there, then the slope, then how that slope bends, and the polynomial clings to the true graph more and more tightly. That clinging is the whole idea of a Taylor series.

Build — from height and slope to a polynomial

The point you build around is the center $a$. When $a=0$ we give it a special name — a Maclaurin series. The crudest guess is a flat line at the curve's height, $T_0(x)=f(a)$. Add the slope and you get the tangent line, $T_1(x)=f(a)+f'(a)(x-a)$. Each new piece comes from one more derivative, divided by a factorial: the coefficient of $(x-a)^k$ is $f^{(k)}(a)/k!$, so $T_n(x)=\sum_{k=0}^{n}\dfrac{f^{(k)}(a)}{k!}(x-a)^k$. Worked number: for $e^x$ at $a=0$ every derivative at $0$ is $1$, so $T_2(x)=1+x+\tfrac{x^2}{2}$. At $x=0.5$ that gives $1+0.5+0.125=1.625$, while the true $e^{0.5}=1.6487\ldots$ — already within about $1.5\%$. Add the $x^3/6$ term and you land on $1.6458$, closer still.

Deepen — the remainder and the radius

How wrong you can be is pinned down by the Lagrange remainder $R_n(x)=\dfrac{f^{(n+1)}(c)}{(n+1)!}(x-a)^{n+1}$ for some $c$ between $a$ and $x$. That fast-growing factorial in the denominator is the hero: for $e^x$, $\sin x$, and $\cos x$ it crushes the powers so completely that the series converges for every $x$. But for $\ln(1+x)$ or $\tfrac{1}{1-x}$ there is a wall — the radius of convergence $R=1$: inside $|x-a|Terms $n$ slider sets how many derivatives you match, Center $a$ slides the point you build from, and Evaluate at $x$ marks where the exact $f$ and your polynomial are compared (the $|$Error$|$ readout shows the gap).

Try This in the Sim Above

1 · Watch it wrap. Pick $e^x$ and drag Terms $n$ upward — the partial-sum curves hug the gold curve over a wider and wider stretch while $|$Error$|$ drops fast. 2 · Hit the wall. Pick $1/(1-x)$, set Evaluate at $x$ near $1$, and crank $n$: the approximation refuses to settle — you have reached the radius $R=1$. 3 · Few terms, big payoff. Switch to $\sin(x)$ and compare how few terms nail the curve near $x=0$ against how many you need out near $x=\pm3$ — far from the center always costs more terms.

📐 Section 3 — Taylor Series: Theorem & Convergence

Taylor's Theorem with Lagrange Remainder

If $f$ is $(n+1)$ times differentiable on an interval containing $a$ and $x$, then:

$$f(x) = \sum_{k=0}^{n}\frac{f^{(k)}(a)}{k!}(x-a)^k + R_n(x), \quad R_n(x)=\frac{f^{(n+1)}(c)}{(n+1)!}(x-a)^{n+1}$$

for some $c$ between $a$ and $x$. The series converges to $f(x)$ iff $R_n(x)\to0$.

SeriesMaclaurin expansionRadius $R$
$e^x$$\displaystyle\sum_{n=0}^\infty \frac{x^n}{n!}$$\infty$
$\sin x$$\displaystyle\sum_{n=0}^\infty \frac{(-1)^n x^{2n+1}}{(2n+1)!}$$\infty$
$\cos x$$\displaystyle\sum_{n=0}^\infty \frac{(-1)^n x^{2n}}{(2n)!}$$\infty$
$\ln(1+x)$$\displaystyle\sum_{n=1}^\infty \frac{(-1)^{n+1}x^n}{n}$$1$ (conv. on $(-1,1]$)
$\frac{1}{1-x}$$\displaystyle\sum_{n=0}^\infty x^n$$1$ (strict)
Step 1 — Where Do Taylor Coefficients Come From?

If $f(x)=\sum_{k=0}^\infty c_k(x-a)^k$, differentiate $k$ times and evaluate at $x=a$: $f^{(k)}(a)=k!\,c_k$, so $c_k=f^{(k)}(a)/k!$. The Taylor series is uniquely determined by all derivatives at $a$.

Step 2 — Radius of Convergence via Ratio Test

$R=\lim_{n\to\infty}|c_n/c_{n+1}|$. For $e^x$: $c_n=1/n!$, so $R=\lim(1/n!)/(1/(n+1)!)=\lim(n+1)=\infty$. For $\ln(1+x)$: $c_n=(-1)^{n+1}/n$, so $R=\lim n/(n+1)=1$. The radius equals the distance to the nearest singularity in $\mathbb{C}$.

Step 3 — Alternating Series Error Bound

For alternating series $\sum(-1)^n b_n$ with $b_n\searrow0$: $|L-S_n|\leq b_{n+1}$ (first omitted term). For $\sin(0.5)$ with 3 terms: error $\leq 0.5^7/7!\approx1.6\times10^{-6}$.

Step 4 — $e^x$ Convergence Proof

$|R_n(x)|=|e^c|/((n+1)!)|x|^{n+1}\leq e^{|x|}|x|^{n+1}/(n+1)!\to0$ as $n\to\infty$ for any fixed $x$, since $x^n/n!\to0$ for all $x$ (factorial growth beats exponential). So $e^x=\sum x^n/n!$ for all $x\in\mathbb{R}$.

Step 5 — Euler's Formula

Apply the Maclaurin series to $e^{ix}$: $e^{ix}=\sum(ix)^n/n!=\cos x+i\sin x$. This is Euler's formula, connecting the five most important constants: $e^{i\pi}+1=0$.

Step 6 — Worked Example: $\cos(0.1)$ to 10 digits

$\cos(0.1)=1-0.01/2+0.0001/24-\cdots$ Error after $n$ terms (alternating): $\leq(0.1)^{2n+2}/(2n+2)!$. For $n=2$: $\leq(0.1)^6/720\approx1.4\times10^{-9}$ — about 8 correct digits from just 3 non-zero terms ($1-0.005+0.0000042$). Adding the $n=3$ term ($\leq(0.1)^8/8!\approx2.5\times10^{-13}$) carries you well past 10-digit accuracy ✓.

Reference: Stewart, J. — Calculus, 8th ed., §11.10–11.11; Spivak, M. — Calculus, 4th ed., Ch. 20; Abbott, S. — Understanding Analysis, §6.5; MIT OCW 18.01.

❓ Section 4 — FAQ

🧮Conceptual  Is every smooth ($C^\infty$) function equal to its Taylor series?

No. The function $f(x)=e^{-1/x^2}$ (with $f(0)=0$) has $f^{(n)}(0)=0$ for all $n$, so its Maclaurin series is identically 0 — yet $f(x)\neq0$ for $x\neq0$. Such functions are smooth but not analytic. A function equals its Taylor series only when the remainder $R_n(x)\to0$. This requires more than just smoothness.

Key takeaway: smooth ≠ analytic. $e^{-1/x^2}$ is $C^\infty$ but its Taylor series is 0 everywhere — they disagree everywhere except $x=0$.
🔬Simulation  What does the "Partial Sums" mode show?

Each "Add Terms" press adds one more term to $T_n(x)$. The gold curve is the exact function; purple curves of increasing brightness show $T_1, T_2,\ldots,T_n$. Within the radius of convergence the curves converge to gold. Outside the radius they diverge — most dramatically for $1/(1-x)$ near $|x|=1$. The error graph (bottom) shows $|T_n(x)-f(x)|$ decreasing geometrically on a log scale.

Key takeaway: inside the radius each term helps; outside, adding terms makes things worse — watch the curves diverge.
🌍Applied  Where are Taylor series used in practice?

Hardware: CPUs compute $e^x$, $\sin x$, $\cos x$ using truncated Taylor or Chebyshev polynomial approximations — a few dozen operations give full double-precision accuracy. Physics: small-angle $\sin\theta\approx\theta$ (pendulum, optics), relativistic $\gamma\approx1+v^2/(2c^2)$. Error propagation in measurements (first-order Taylor). Numerical ODEs: Taylor series method. Quantum mechanics: perturbation theory expands the Hamiltonian in powers of a small parameter.

Key takeaway: CPU math functions, small-angle approximations, perturbation theory, error propagation — all Taylor series in disguise.
💡Non-Obvious  Why does $\ln(1+x)$ converge only for $|x|\leq1$ while $e^x$ converges everywhere?

The radius of convergence equals the distance to the nearest singularity in the complex plane $\mathbb{C}$. $e^z$ has no singularities anywhere, so $R=\infty$. $\ln(1+z)$ has a branch point singularity at $z=-1$, which is distance 1 from the expansion point $z=0$, giving $R=1$. Even though the real function $\ln(1+x)$ looks smooth for $x>-1$, the complex singularity at $z=-1$ limits convergence on the real line too.

Key takeaway: complex singularities control real convergence. $\ln(1+z)$ has a branch cut at $z=-1$, distance 1 from origin → $R=1$.
📐Computational  How many terms of $\sin x$ give 10-digit accuracy at $x=\pi$?

Alternating series error bound: $|R_n|\leq\pi^{2n+3}/(2n+3)!$. Testing $n=10$ ($T_{21}$): $\pi^{23}/23!\approx1.1\times10^{-11}<10^{-10}$ ✓, while $n=9$ ($T_{19}$) gives $\pi^{21}/21!\approx5.5\times10^{-10}$ — not quite enough. So 11 non-zero terms (degree-21 polynomial) suffice. Check: factorial $23!\approx2.6\times10^{22}$ completely dominates $\pi^{23}\approx2.7\times10^{11}$. At $x=100$: well over a hundred terms — and catastrophic cancellation makes direct summation impractical, so real libraries first reduce $x$ modulo $2\pi$.

Key takeaway: about 11 terms give 10 digits of $\sin(\pi)$ — factorials in the denominator eventually outrun the powers in the numerator.
🎓Deep  How does Taylor series connect to complex analysis and the Cauchy integral formula?

In complex analysis, a function is analytic (holomorphic) if and only if it equals its Taylor series locally. The Cauchy integral formula gives: $f^{(n)}(a)/n!=\frac{1}{2\pi i}\oint_C f(z)/(z-a)^{n+1}dz$, so the Taylor coefficients are contour integrals. The radius of convergence equals the distance to the nearest singularity (pole, branch point) in $\mathbb{C}$. This is why real Taylor series convergence is governed by complex analysis — even when the function looks perfectly smooth on the real line.

Key takeaway: in $\mathbb{C}$, holomorphic $\iff$ analytic $\iff$ Taylor series converges; Cauchy integral formula gives coefficients as contour integrals.
Best resources: 3Blue1Brown — Taylor series video; Paul's Online Math Notes (https://tutorial.math.lamar.edu); MIT OCW 18.01; Spivak — Calculus Ch. 20.

⚠️ Section 5 — Misconceptions & Common Errors

A · Conceptual Misconceptions
❌ Misconception: "Every infinitely differentiable function equals its Taylor series." ✅ Correction: $f(x)=e^{-1/x^2}$ is $C^\infty$ at $x=0$ but all its Maclaurin coefficients are 0 — the series is 0 everywhere, not $f$. A function must be analytic (remainder $R_n\to0$), not just smooth, to equal its Taylor series. 📖 Spivak — Calculus, Ch. 20 (explicit counterexample).
❌ Misconception: "The Taylor series always converges for all $x$." ✅ Correction: $\ln(1+x)$ diverges for $|x|>1$; $1/(1-x)$ diverges for $|x|\geq1$. Always compute $R$ using the ratio/root test. Even within $|x| 📖 Stewart — §11.9 (radius and interval of convergence).
❌ Misconception: "The Lagrange remainder gives the exact error." ✅ Correction: $|R_n(x)|\leq M|x-a|^{n+1}/(n+1)!$ where $M=\max|f^{(n+1)}|$ — this is an upper bound. The actual error is usually much smaller. For alternating series, the tighter bound is just the first omitted term $|a_{n+1}|$. 📖 Stewart — §11.11 (error bounds for Taylor series).
B · Common Procedural Errors
❌ Error: Writing $\cos x = 1-x^2/2+x^4/4-\cdots$ (missing factorials in denominators). ✅ Correct: $\cos x=\sum(-1)^n x^{2n}/(2n)!=1-x^2/2!+x^4/4!-\cdots$ The denominators are $2!=2$, $4!=24$, $6!=720$ — factorials, not just even numbers. 🔍 Why: students write the pattern $x^{2n}/(2n)$ instead of $x^{2n}/(2n)!$, forgetting the factorial.
❌ Error: $e^{x^2}=\sum x^{2n}/n!$ — is this correct? ✅ Correct: Yes, by substituting $u=x^2$ into $e^u=\sum u^n/n!$: $e^{x^2}=\sum(x^2)^n/n!=\sum x^{2n}/n!$. Common wrong attempt: $\sum x^{2n}/(2n)!$ — which is actually $\cosh x=(e^x+e^{-x})/2$, not $e^{x^2}$. 🔍 Why: students confuse $e^{x^2}$ with $\cosh x$; the substitution $u=x^2$ must be applied carefully.
❌ Error: Forgetting to check endpoints for $\ln(1+x)=\sum(-1)^{n+1}x^n/n$: stating "converges for $|x|<1$" without testing $x=\pm1$. ✅ Correct: The series converges on $(-1,1]$: at $x=1$, alternating harmonic $\sum(-1)^{n+1}/n=\ln2$ (Leibniz test ✓); at $x=-1$, harmonic $-\sum1/n$ diverges ✗. Always test endpoints separately after finding $R$. 🔍 Why: students state $|x|<1$ without checking the boundary points $x=\pm1$ separately.
Education research: Tall, D. & Vinner, S. — ESM 12(2) (1981); Cornu, B. — "Limits" in Tall (ed.) Advanced Mathematical Thinking (1991); Mamona-Downs, J. — MERJ (2001).