A Taylor series approximates a function by a sum of powers of x. The Taylor series calculator takes a function (e^x, sin x, cos x or ln(1 + x)), a value of x and a number of terms and gives the approximation, the exact value, the absolute error, the relative error and the highest power used.
How the calculation works
- e^x = 1 + x + x²/2! + x³/3! + …, which converges for every x.
- sin x = x − x³/3! + x⁵/5! − …, and cos x = 1 − x²/2! + x⁴/4! − …, with x in radians. Both converge for every x.
- ln(1 + x) = x − x²/2 + x³/3 − …, which converges only for x between −1 and 1 (and x = 1).
- The calculator adds the first n terms, compares the sum with the exact value, and gives the absolute error and the relative error in percent.
Example
The function is e^x with x = 1 and 6 terms: 1 + 1 + 0.5 + 0.16667 + 0.04167 + 0.00833 = 2.716667. The exact value is e = 2.718282, so the absolute error is 0.001615 and the relative error is 0.0594 percent. The highest power of x used is 5. Adding a seventh term brings the sum to 2.718056, and the error to under 0.01 percent.
Why it matters
Seeing the error shrink as terms are added is the best way to understand convergence. The calculator helps students to check homework, to decide how many terms an approximation needs, and to compare how fast different series converge for the same x.
Good to know
The sums use ten terms at most. Sine and cosine take x in radians, so convert degrees first. The exact value is computed in double precision. The series of ln(1 + x) needs x between −1 and 1, and it converges slowly near the ends. The approximations are not the way real computers evaluate functions near large x, which first reduce the argument.
Related tools
The arithmetic-geometric series calculator sums progressions, and the definite integral calculator finds the area under a curve with numerical methods.