DGS Studio

Taylor & Maclaurin

Taylor and Maclaurin Polynomials

Expand taylor(f, x, a, n) from derivatives and factorials. A center of 0 is the Maclaurin polynomial, and maclaurin(f, x, n) is accepted.

Solve Equation expands taylor(sin(x),x,0,5) by T_n(x) = sum f^(k)(a)/k! * (x-a)^k. The derivatives of sin at 0 are 0, 1, 0, -1, 0, and 1, so the degree-5 Maclaurin polynomial is x-x^3/6+x^5/120.

taylor(exp(x),x,0,4) is 1+x+x^2/2+x^3/6+x^4/24. taylor(log(x),x,1,3) is (x-1)-(x-1)^2/2+(x-1)^3/3, with the original function restricted to x > 0 and convergence claimed only on the open interval 0 < x < 2. taylor(cos(x),x,0,6) is 1-x^2/2+x^4/24-x^6/720. taylor(1/x,x,1,3) is 1-(x-1)+(x-1)^2-(x-1)^3, and 1/x is undefined at 0. taylor(x^3+2*x^2+x+1,x,0,4) equals x^3+2*x^2+x+1, so the remainder is 0. A center of 0 is the Maclaurin case, and maclaurin(f, x, n) uses the same routine.

Equation

taylor(sin(x),x,0,5)

Graph preview

Graph preview of taylor(sin(x),x,0,5)
A static sample of this expression. The studio draws the full interactive result.

How the Taylor polynomial is built

A Taylor polynomial of degree n at a center a is the unique polynomial of degree at most n that matches the function value and the first n derivatives at that center. Each coefficient is f^(k)(a)/k!. When the center is 0 the same polynomial is called a Maclaurin polynomial. DGS computes those derivatives with the existing differentiation routine and divides by factorial(k). It does not replace that calculation with a series shortcut, and a step is written only after the value has been computed.

The polynomial can exist on a larger set than the original function. log(x) is defined for x > 0, while its Taylor polynomial is defined for every real x. A finite radius, when one is established from singularities, guarantees convergence only on an open interval. Endpoint convergence is not claimed. If the center is outside the domain, or a derivative does not exist there, the result explains why the polynomial was not formed. A degree slider never asks for a higher order than the one that was computed.

Reading the input

Other versions of this example

These stay on this page so each version keeps the same explanation. Choose Try example to run a version in its Studio workflow, or copy it into the editable field below.

Sine at 0

The degree-5 Maclaurin polynomial is x-x^3/6+x^5/120.

taylor(sin(x),x,0,5)

Exponential at 0

The degree-4 Maclaurin polynomial is 1+x+x^2/2+x^3/6+x^4/24.

taylor(exp(x),x,0,4)

Logarithm at 1

The degree-3 polynomial at 1 is (x-1)-(x-1)^2/2+(x-1)^3/3. The original logarithm needs x > 0.

taylor(log(x),x,1,3)

Cosine at 0

The degree-6 Maclaurin polynomial is 1-x^2/2+x^4/24-x^6/720.

taylor(cos(x),x,0,6)

Reciprocal at 1

The degree-3 polynomial at 1 is 1-(x-1)+(x-1)^2-(x-1)^3. The original function is undefined at 0.

taylor(1/x,x,1,3)

Cubic polynomial

A polynomial of degree 3 expanded through degree 4 at 0 is x^3+2*x^2+x+1.

taylor(x^3+2*x^2+x+1,x,0,4)

Try a change

Solve Equation shows the original function, the expansion center, the degree, the derivative values at the center, the Taylor formula, the substituted coefficients, and the final polynomial. A domain restriction is listed only when it was computed.

Edit and generate

Solve Equation opens the studio homepage and runs this field. Open in DGS Studio loads the same text and waits for you to generate it. The equation is sent once, as a query parameter.

Related examples