Understanding the Taylor series calculator — concept and principle
A Taylor series writes a function as an infinite polynomial built from its derivatives at one point. This calculator uses the Maclaurin series (Taylor series around 0) of eˣ, sin x, cos x and ln(1 + x), adds the number of terms you choose, and compares the partial sum with the exact value. It shows how quickly a series converges and how computers can evaluate such functions.
How it is calculated
The calculator adds the first k non-zero terms of:
- eˣ = 1 + x + x²/2! + x³/3! + … = Σ xⁿ/n!
- sin x = x − x³/3! + x⁵/5! − … = Σ (−1)ⁿ x²ⁿ⁺¹/(2n + 1)!
- cos x = 1 − x²/2! + x⁴/4! − … = Σ (−1)ⁿ x²ⁿ/(2n)!
- ln(1 + x) = x − x²/2 + x³/3 − … = Σ (−1)ⁿ xⁿ⁺¹/(n + 1), valid only for −1 < x ≤ 1.
x for sin and cos is in radians. The error is |series value − exact value|.
The principle
A Taylor polynomial is the polynomial that matches the function's value and its first several derivatives at the centre point: the general term is f⁽ⁿ⁾(0)xⁿ/n!. For eˣ every derivative equals eˣ, which is 1 at 0, so all coefficients are 1/n!. For sin and cos the derivatives cycle through sin, cos, −sin, −cos, which is why only odd or only even powers appear with alternating signs. The more derivatives you match, the further from 0 the polynomial stays close to the curve.
Worked example
- Default inputs: function eˣ, x = 0.5, terms k = 6.
- Terms: 1, 0.5, 0.125, 0.0208333, 0.0026042, 0.0002604.
- Sum: 1.648697917.
- Exact: e^0.5 = 1.648721271.
- Error: 1.648721271 − 1.648697917 = 0.000023354. The first omitted term is 0.5⁶/720 ≈ 0.0000217, which is close to the actual error, as expected.
| x | Series value |
|---|---|
| 0.125 | 1.133148448 |
| 0.25 | 1.284025065 |
| 0.375 | 1.454987335 |
| 0.5 | 1.648697917 |
| 0.625 | 1.868155162 |
| 0.75 | 2.116723633 |
| 1 | 2.716666667 |
How to read the result
The error tells you how many correct digits the partial sum has; here about four decimal places. Small |x| gives very fast convergence; larger |x| needs more terms. For sin and cos with alternating terms, the error is smaller than the first omitted term once the terms are decreasing. For ln(1 + x) near x = 1 convergence is very slow, and for x > 1 or x ≤ −1 the series diverges, so the error grows instead of shrinking.
Common mistakes
- Entering degrees for sin or cos; 30 means 30 radians, not 30°.
- Using ln(1 + x) with x outside (−1, 1]; the partial sums do not approach the true value.
- Counting terms as powers: 6 terms of sin x reach x¹¹, not x⁶.
Frequently asked questions
What is the difference between a Taylor and a Maclaurin series?
A Maclaurin series is a Taylor series centred at 0. A Taylor series can be centred at any point a, using powers of (x − a).
Does every function have a Taylor series?
Only functions with all derivatives at the centre, and even then the series may not equal the function far from it.
Why does ln(1 + x) stop working at x = 1.5?
Its series has radius of convergence 1, because ln(1 + x) is undefined at x = −1, a distance 1 from the centre.
Sources: Stewart, J., Calculus: Early Transcendentals, §11.10 Taylor and Maclaurin Series · NIST Digital Library of Mathematical Functions, §4.6 and §4.19 (dlmf.nist.gov)