Taylor series calculator
Type a function and a center: get the Taylor polynomial, its coefficients and how close it is to f(x).
Use ^ for powers and write products as 2x or x*sin(x). Functions: sin, cos, tan, arcsin, arctan, sinh, cosh, ln, log, sqrt, exp; constants pi and e. Angles are in radians.
What is a Taylor polynomial?
The Taylor polynomial of degree N of a function f at the center a is p_N(x) = f(a) + f′(a)(x − a) + f″(a) ÷ 2! · (x − a)² + … + f⁽ᴺ⁾(a) ÷ N! · (x − a)ᴺ. It is the polynomial whose value and first N derivatives at a match those of f, so it hugs the graph near a. When a = 0 it is called a Maclaurin polynomial, and letting N grow without end gives the Taylor series (OpenStax Calculus Volume 2, section 6.3). The calculator finds each derivative symbolically, plugs in the center, divides by k! and keeps the result exact where it can: fractions, e, π, square roots and logarithms. For ln x at x = 1 it returns (x − 1) − (x − 1)²/2 + (x − 1)³/3, the polynomial of Example 6.11.
Worked example: estimating a cube root
OpenStax Example 6.13 approximates ∛11 from f(x) = ∛x at a = 8, where f(8) = 2, f′(8) = 1/12 and f″(8) = −1/144. The first-degree polynomial is 2 + (x − 8)/12, which gives 2.25 at x = 11; the second-degree one is 2 + (x − 8)/12 − (x − 8)²/288, which gives 2.21875. The true value is 2.2239801, so the errors are 0.02602 and 0.00523. The Lagrange bounds the calculator reports are 0.03125 and 0.0065104, the same 0.03125 and 0.0065104 the book finds. Both bounds are above the actual errors, as they must be.
What is the Lagrange remainder bound?
The error R_N(x) = f(x) − p_N(x) equals f⁽ᴺ⁺¹⁾(c) ÷ (N + 1)! · (x − a)ᴺ⁺¹ for some unknown c between a and x. If |f⁽ᴺ⁺¹⁾| never exceeds M on that stretch, then |R_N(x)| ≤ M · |x − a|ᴺ⁺¹ ÷ (N + 1)! (OpenStax Calculus Volume 2, section 6.3, Taylor’s theorem with remainder). The calculator finds M by interval arithmetic on the exact (N + 1)-th derivative, with a tiny safety margin for rounding, so the bound is guaranteed, though it can be generous when the derivative has several occurrences of x. Example 6.14 uses the sixth-degree Maclaurin polynomial of sin x (the same as the fifth) at x = π/18: the calculator gives p(x) = 0.173648179, an actual error of 9.78e-10 and a bound of 9.79e-10, in line with the book’s 9.8 × 10⁻¹⁰. For √(1 + x) with N = 3 at x = 0.5 (Example 6.17) the bound is 0.00244, the book’s 0.00244.
Why can a higher degree make things worse?
A Taylor polynomial is only good where the Taylor series converges, and that is usually near the center. The series of 1/(1 − x) at 0 is 1 + x + x² + …, which converges for −1 < x < 1 (OpenStax Calculus Volume 2, Table 6.1). Inside, at x = 0.5, the degree-12 polynomial is excellent. Outside, at x = 1.5, the true value is -2 but the degree-12 polynomial gives 387.239, and every extra degree makes it larger. When the point is outside the interval of convergence, the “bound” is no help either: the calculator will still compute one if it can, but the derivative is large and the number is huge. Compare the polynomial with f(x) before trusting it.
How do I type the function, center and degree?
Write f in the variable x with ^ for powers: e^x, sin(x), ln(1+x), 1/(1-x), (1+x)^(1/2), sqrt(x), arctan(x), x*e^x. Products can be written 2x or x*sin(x); constants are pi and e; angles are in radians. The center is a number or a constant expression such as 0, 1, 2.5, pi/4 or e, and the degree runs from 0 to 12. Give a value of x if you want to compare p(x) with f(x). A power with a variable exponent, such as (1 + x)^p with an unknown p, is not supported; use a number for p. If a derivative becomes too long for the calculator, the polynomial stops one degree earlier and says so.
Common mistakes and limits
Choosing a center where f or a derivative does not exist: ln x and √x cannot be expanded at 0, and sin(x)/x has a gap at 0 that must be removed first (use the series of sin x divided by x). Forgetting the factorial: the coefficient is f⁽ᵏ⁾(a) ÷ k!, not f⁽ᵏ⁾(a). Forgetting that the powers are of (x − a), not x. Expecting odd and even terms: sin x has only odd powers and cos x only even ones, so their degrees 5 and 6 give the same polynomial. Mixing degrees and radians. And using a polynomial far from its center, or outside the interval where the series converges, as in the previous answer. A bound based on a derivative that blows up between a and x cannot be built, and the calculator then says no bound is available instead of guessing.
Standard Maclaurin series
These are the series OpenStax lists in Table 6.1 of section 6.4, with the intervals of convergence exactly as printed there. Type any of them above to see its polynomial.
| Function | Maclaurin series | Interval of convergence |
|---|---|---|
| 1 ÷ (1 − x) | Σ xⁿ, n ≥ 0 | −1 < x < 1 |
| eˣ | Σ xⁿ ÷ n!, n ≥ 0 | −∞ < x < ∞ |
| sin x | Σ (−1)ⁿ x²ⁿ⁺¹ ÷ (2n + 1)!, n ≥ 0 | −∞ < x < ∞ |
| cos x | Σ (−1)ⁿ x²ⁿ ÷ (2n)!, n ≥ 0 | −∞ < x < ∞ |
| ln(1 + x) | Σ (−1)ⁿ⁺¹ xⁿ ÷ n, n ≥ 1 | −1 < x ≤ 1 |
| tan⁻¹ x | Σ (−1)ⁿ x²ⁿ⁺¹ ÷ (2n + 1), n ≥ 0 | −1 ≤ x ≤ 1 |
| (1 + x)ʳ | Σ C(r, n) xⁿ, n ≥ 0 | −1 < x < 1 |
For the binomial series the book adds that the behavior at the endpoints depends on r.
Sources: OpenStax, Calculus Volume 2, section 6.3 “Taylor and Maclaurin Series” (Examples 6.11–6.14, Taylor’s theorem with remainder) and section 6.4 “Working with Taylor Series” (Table 6.1, Example 6.17). Related: derivative calculator, sequence calculator, summation calculator, scientific calculator and integral calculator.