· 4 min read
How to Expand a Function as a Taylor Series
Heshan Fernando
Co-founder & COO
Your calculator has no exponential function built into the silicon. Neither does your processor, not really. When you ask for e^x, something evaluates a polynomial — because polynomials are the only thing arithmetic hardware can actually do.
Taylor series are how a function becomes a polynomial, and understanding where the approximation breaks is the useful part.
The construction
A Taylor series builds a polynomial that matches a function’s value and all its derivatives at a single point:
f(x) = Σ fⁿ(a)(x−a)ⁿ / n!
Expanded about zero it’s called a Maclaurin series, which is the common case.
For e^x about 0, every derivative is 1, so:
e^x ≈ 1 + x + x²/2 + x³/6 + x⁴/24 + x⁵/120 + …
At x = 0.5, six terms give an error around 2×10⁻⁵ — excellent. At x = 3 the same six terms are noticeably wrong. At x = 30 they’re useless.
The polynomial is built entirely from the function’s behaviour at one point, so it’s excellent near that point and progressively worse away from it.
Why the small-angle approximation works
sin x ≈ x for small x is the most-used Taylor truncation in physics and engineering.
The series is sin x = x − x³/6 + x⁵/120 − …. For small x, the cubic term is tiny — at x = 0.1 radians it’s about 0.00017, an error of under 0.2%.
That’s why pendulum equations, optics and structural analysis all use it, and why they all break down at larger angles. The approximation isn’t a simplification someone chose; it’s the first term of a series, and its error is exactly the terms you dropped.
Knowing that tells you when it fails: when x³/6 stops being negligible relative to x, which is around 0.3 radians for 1% accuracy.
| x (radians) | sin x | x | Error |
|---|---|---|---|
| 0.1 | 0.09983 | 0.1 | 0.17% |
| 0.3 | 0.29552 | 0.3 | 1.5% |
| 0.5 | 0.47943 | 0.5 | 4.3% |
| 1.0 | 0.84147 | 1.0 | 19% |
Radius of convergence
Some series converge everywhere. e^x, sin x and cos x converge for all x — the terms eventually shrink no matter how large x is, so more terms always improve the answer.
Others don’t. The geometric series 1/(1−x) = 1 + x + x² + x³ + … converges only for |x| < 1. At x = 2, the terms grow without bound and the series diverges — adding terms makes it worse, and the sum bears no relationship to the function’s actual value of −1.
That’s the radius of convergence, and checking it matters because outside it the series isn’t an approximation at all. It’s a divergent sum that happens to be built from the right derivatives.
Where they’re used
Numerical libraries. Standard library functions for exp, log, sin and cos are built on polynomial approximations, often refined variants rather than plain Taylor series.
Physics approximations. Small-angle, and relativistic corrections that reduce to Newtonian mechanics at low velocity.
Error propagation. Linearising a function around an operating point to estimate how input uncertainty propagates.
Control theory. Linearising nonlinear systems about an equilibrium.
Common mistakes to avoid
- Adding terms outside the radius of convergence, which makes things worse.
- Expanding about zero when the point of interest is far from it — expand about a nearby point instead.
- Using a small-angle approximation at an angle that isn’t small.
- Assuming more terms always helps; for a divergent series they don’t, and even for convergent ones floating-point cancellation can limit accuracy.
- Forgetting the factorial in the denominator, which is what makes higher terms shrink.
How to do it with Taylor Series Expander
The Taylor Series Expander expands to a chosen number of terms and reports convergence.
- Enter the function and the point to expand about — zero gives the Maclaurin series.
- Choose how many terms.
- Check the interval of convergence before trusting the result at any particular x.
- Evaluate at a specific point to see the actual error at that distance.
Other maths tools are in the tools directory.
Frequently asked questions
Why does accuracy fall off away from the expansion point?
Because the series is built from the function’s behaviour at one point. Near it, a few terms capture the function well; far away the truncation error grows, sometimes explosively.
What is the radius of convergence?
The distance from the expansion point within which the infinite series converges to the function. Outside it, the series diverges and adding terms makes things worse.
Where are Taylor series used in practice?
Numerical methods, physics approximations like small-angle sine, and inside the standard library functions your computer uses to evaluate exponentials and trigonometry.
Final thought
Expand about a point near where you’ll evaluate. A six-term series is excellent near its centre and worthless far from it, and moving the centre costs nothing.