MathsCalculus

Taylor Series
calculator.

Taylor polynomials copy a function near one point, using its derivatives at that point.

How it's worked out

Pick a center a. A polynomial has one free number per power, so you can force it to match the function's value and its first n derivatives at a. OpenStax gives the result: each coefficient is a derivative at the center divided by a factorial. With a center of 0, the same polynomial is called a Maclaurin polynomial.

Pn(x)\displaystyle P_n(x)=∑k=0nf(k)(a)k!(x−a)k\displaystyle {}= \sum_{k=0}^{n} \frac{f^{(k)}(a)}{k!}\,(x - a)^k

The factorial is there because differentiating a power k times stacks up that same factor. Dividing by it cancels the factor, so the k-th derivative of P at a comes out equal to that of f.

The error has an exact form called the Lagrange remainder. It uses the next derivative at some point c between a and x. You rarely know c, so you bound the derivative by a number M on that stretch and get a limit on the miss.

|Rn(x)|\displaystyle |R_n(x)|≤M(n+1)!|x−a|n+1\displaystyle {}\le \frac{M}{(n + 1)!}\,|x - a|^{n + 1}

The remainder figure here takes M from the largest next derivative at 41 points between a and x. That is sampling and not a proof, so read it as an estimate of the bound. The derivatives themselves come from automatic differentiation, which pushes whole power series through your formula. It stays reliable to order 20, where small-step differences would drown in rounding.

Worked examples

Nadia estimates e with six terms after the constant

Every derivative of exe^x is exe^x, so each one equals 1 at the center. The coefficients are then just one over a factorial.

P6(x)\displaystyle P_6(x)=1\displaystyle {}= 1+x\displaystyle {}+ x+x22\displaystyle {}+ \frac{x^2}{2}+x36\displaystyle {}+ \frac{x^3}{6}+x424\displaystyle {}+ \frac{x^4}{24}+x5120\displaystyle {}+ \frac{x^5}{120}+x6720\displaystyle {}+ \frac{x^6}{720}

At x=1x = 1 this gives 2.718056, and e is 2.718282, so she misses by 0.000226. The remainder estimate is 0.000539, which is larger than the real miss, as a bound should be.

If her target is an error under 0.001, order 6 is the first that gets there. Order 5 misses by 0.001615.

Open this example in the tool

Omar checks a sine table at 10 degrees

The series uses radians, so 10 degrees becomes π18\frac{\pi}{18}. Sine has no even powers, so order 6 adds nothing to order 5. The polynomial gives 0.17364818, and the miss is 9.78 × 10⁻¹⁰.

The bound comes to 9.79 × 10⁻¹⁰, because the next derivative is a cosine, which never goes past 1. OpenStax reaches the same figure for this angle.

Omar also wants to know how far this polynomial can be trusted. It stays within 0.0001 of the sine out to about 0.908 radians, on either side of 0. OpenStax gets |x|<0.907|x| < 0.907 from the bound, which runs slightly above the real miss.

Open this example in the tool

Priya sees a series stop working

Priya builds the series for ln⁡(1+x)\ln(1 + x) and compares two points with the same terms. At 0.5, order 6 is already within 0.001 of the true value. At 1.5, the misses grow as the order rises.

Error at each order
OrderAt x = 0.5At x = 1.5
23.05 × 10⁻²0.54
44.42 × 10⁻³0.68
81.5 × 10⁻⁴1.82
163.05 × 10⁻⁷24.01

The polynomial is fine; the point is the problem. This series only converges for x above −1 and up to 1, so past that the powers of x outrun the shrinking fractions. She gets a better result by moving the center closer to 1.5.

Open this example in the tool

Reading your result

Actual error compares P with the true value of f at your x. Trust this one when f can be evaluated. Remainder estimate is what you would quote when it cannot.

A bound can be far above the real miss. For 11−x\frac{1}{1 - x} at order 5 and x=0.5x = 0.5, the actual error is 0.03125 and the estimate is 2. The bound takes the worst case on the whole stretch, and this function grows fast near its pole at 1.

A coefficient of 0 means that power is missing. Odd functions such as sin⁡x\sin x have only odd powers, and even functions such as cos⁡x\cos x have only even ones.

The range of a series does not depend on your order. Some converge for every x and others only on a short stretch, as the table shows. OpenStax lists these in its table of common series.

Common Maclaurin series
FunctionFirst termsConverges for
exe^x1+x+x22+⋯1 + x + \frac{x^{2}}{2} + \cdotsAll x
sin⁡x\sin xx−x36+x5120+⋯x - \frac{x^{3}}{6} + \frac{x^{5}}{120} + \cdotsAll x
cos⁡x\cos x1−x22+x424+⋯1 - \frac{x^{2}}{2} + \frac{x^{4}}{24} + \cdotsAll x
ln⁡(1+x)\ln(1 + x)x−x22+x33+⋯x - \frac{x^{2}}{2} + \frac{x^{3}}{3} + \cdots−1<x≤1-1 < x \le 1
11−x\frac{1}{1 - x}1+x+x2+⋯1 + x + x^{2} + \cdots−1<x<1-1 < x < 1
arctan⁡x\arctan xx−x33+x55+⋯x - \frac{x^{3}}{3} + \frac{x^{5}}{5} + \cdots−1≤x≤1-1 \le x \le 1

Common mistakes

  • Leaving out the factorial. The coefficient is the derivative over the factorial of k, not the derivative alone. Without it, the series for exe^x turns into the one for 11−x\frac{1}{1 - x}.
  • Writing powers of x with a nonzero center. Away from 0, each power must be of x−ax - a. The terms expand into a different-looking polynomial, but you should not mix the two forms.
  • Counting terms as the order. Order 7 for sin⁡x\sin x has only 4 terms that are not 0. When a question says "first four terms", check which it means.
  • Using the n-th derivative in the bound. The remainder for order n uses derivative n + 1, one step higher than the last term you kept.
  • Using degrees. The series for sine and cosine assume radians. Convert the angle first, or the sum answers a different question.

Questions people ask

A Maclaurin series is a Taylor series with its center at 0. The rule is the same, and the powers of x minus a just become powers of x. Many tables list Maclaurin series because 0 often makes the derivatives easy to find.

Sources