Application Center - Maplesoft

App Preview:

Taylor and Maclaurin Series

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application




Taylor and Maclaurin Series


Juergen Gerlach
Radford University
October 12th, 2017

formal

This tutorial was written using Maple 2017.

 

1. Evaluation of Power Series


restart

The evaluation of power series is straightforward, if the series converges for all x, i.e when R = infinity.  Here are some examples:

R = infinity

(1)

sum(x^k/factorial(k), k = 0 .. infinity)

exp(x)

(2)

sum((-1)^k*x^(2*k)/factorial(2*k+1), k = 0 .. infinity)

sin(x)/x

(3)

sum(k*x^(2*k)/factorial(2*k+1), k = 1 .. infinity)

(1/2)*cosh(x)-(1/2)*sinh(x)/x

(4)

If the power series does not converge everywhere, we have to make assumptions about the interval of convergence.  For instance,

sum(x^k/(k*(k-1)), k = 2 .. infinity)

sum(x^k/(k*(k-1)), k = 2 .. infinity)

(5)

does not yield a result.  However using

assume(abs(x) < 1)

leads to

sum(x^k/(k*(k-1)), k = 2 .. infinity)

-x*ln(-x+1)+ln(-x+1)+x

(6)

This is a little hard to read, but the tilde means that we made assumptions about the range of the variable.  Here are more examples, beginning with the geometric series (the assumption that abs(x) < 1is still active)

abs(x) < 1

(7)

sum(a*x^k, k = 0 .. infinity)

-a/(x-1)

(8)

assume(abs(x-3) < 5)

sum((-1)^k*k^2*(x-3)^k/5^k, k = 1 .. infinity)

5*(x-8)*(x-3)/(x+2)^3

(9)

assume(0 < x and x < 2)

sum((-1)^k*(x-1)^k, k = 0 .. infinity)

1/x

(10)

Previous versions of maple had the formulas, such as the geometric series,  built in - without the "assume" requirement.  This lead to absurd results when series that obviously did not converge by the Divergence Test all of a sudden had finite values.  

 

 

2. Formal Series Expansions

 

This is straightforward. Examples follow

 

convert(1/x, FormalPowerSeries, x = 1)

Sum((-1)^k*(-1+x)^k, k = 0 .. infinity)

(11)

convert(sin(x), FormalPowerSeries, x = 0)

Sum((-1)^k*x^(2*k+1)/factorial(2*k+1), k = 0 .. infinity)

(12)

convert(sqrt(x), FormalPowerSeries, x = 1)

Sum(-(-1)^k*4^(-k)*factorial(2*k)*(-1+x)^k/(factorial(k)^2*(-1+2*k)), k = 0 .. infinity)

(13)

 

 

3. The taylor and the series Commands

 

restart

3.a  We can display the first few terms of a taylor series with the taylor command.

 

Example:  We wish to find the Taylor expansion of  f(x) = 1/x at  x = 1.  

x = 1.

(14)

taylor(1/x, x = 1)

series(1-(x-1)+(x-1)^2-(x-1)^3+(x-1)^4-(x-1)^5+O((x-1)^6),x = 1,6)

(15)

The last expression means "terms of order (x-1)^6 ".  n = 6 is the default, and we have control over the order with an additional input argument.

n = 6

(16)

taylor(1/x, x = 1, 12)

series(1-(x-1)+(x-1)^2-(x-1)^3+(x-1)^4-(x-1)^5+(x-1)^6-(x-1)^7+(x-1)^8-(x-1)^9+(x-1)^10-(x-1)^11+O((x-1)^12),x = 1,12)

(17)

Now terms of order up to 11 are displayed, the remaining terms are hidden in O((x-1)^12) .  

O((x-1)^12)

(18)

 

Note, that the third input argument controls order of the expansion, and not the number of terms.  
Example:

taylor(cos(x), x = 0, 5)

series(1-(1/2)*x^2+(1/24)*x^4+O(x^6),x,6)

(19)

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

series(1-(1/2)*x^2+(1/24)*x^4+O(x^6),x,6)

(20)

We get the same response for 5 and 6 (why?), but using 7 in the last argument we have

taylor(cos(x), x = 0, 7)

series(1-(1/2)*x^2+(1/24)*x^4-(1/720)*x^6+O(x^8),x,8)

(21)

3.b  The series command works in a similar way, but it can also be used at singularities, when the taylor command fails.

 

Examples.

(a) The commands work the same when there are no singularities

series(sin(x), x = 0, 6)

series(x-(1/6)*x^3+(1/120)*x^5+O(x^7),x,7)

(22)

taylor(sin(x), x = 0, 6)

series(x-(1/6)*x^3+(1/120)*x^5+O(x^7),x,7)

(23)

(b) The taylor command fails for   f(x) = sin(x)/x^2, because we have a vertical asymptote at the origin,

f(x) = sin(x)/x^2

(24)

"taylor(  , x=0,6);"

Error, invalid function arguments

"taylor(  , x=0,6);"

 

but series works

series(sin(x)/x^2, x = 0, 6)

series(x^(-1)-(1/6)*x+(1/120)*x^3+O(x^5),x,5)

(25)

(c) Another example with a vertical asymptote:

series(cot(x), x = 0, 6)

series(x^(-1)-(1/3)*x-(1/45)*x^3-(2/945)*x^5+O(x^7),x,7)

(26)

``

4. Direct Construction of Taylor Polynomials

 

restart

The Taylor polynomial of order N for a function  f(x) taken at  x = a is given by p[n](x) = sum((((D@@k)(f))(a))(x-a)^k/factorial(k), k = 0 .. N) .  The coeftayl command has the formula for the coefficient built in.

p[n](x) = sum((((D@@k)(f))(a))(x-a)^k/factorial(k), k = 0 .. N)

(27)

 

Example:  We use f(x) = sqrt(x)   with a = 25 and compute the coefficient for (x-25)^4.

(x-25)^4

(28)

 

f := proc (x) options operator, arrow; sqrt(x) end proc

proc (x) options operator, arrow; sqrt(x) end proc

(29)

 

coeftayl(f(x), x = 25, 4); simplify(%)

-1/2000000

(30)

Direct calculation

((D@@4)(f))(25)/factorial(4); simplify(%)

-1/2000000

(31)


In the construction we proceed without the coeftayl command (it's a matter of preference).

The following steps yield the Taylor polynomial.  The example finds the 10th degree polynomial for f(x) = exp(-(1/2)*x^2)*sin(x) expanded at the origin.

x^(1/2) = exp(-(1/2)*x^2)*sin(x)

(32)

 

f := proc (x) options operator, arrow; exp(-(1/2)*x^2)*sin(x) end proc; a := 0; N := 10; p := proc (x) options operator, arrow; sum(((D@@k)(f))(a)*(x-a)^k/factorial(k), k = 0 .. N) end proc; p(x)

x-(2/3)*x^3+(13/60)*x^5-(29/630)*x^7+(131/18144)*x^9

(33)

Graphical illustration:

plot([f, p], -3 .. 3, view = [-3 .. 3, -1 .. 1], color = [blue, red], thickness = [2, 1], gridlines)

 


Example: One more for variety.

f := proc (x) options operator, arrow; ln(x) end proc; a := exp(1); N := 5; p := proc (x) options operator, arrow; sum(((D@@k)(f))(a)*(x-a)^k/factorial(k), k = 0 .. N) end proc; p(x)

1+(x-exp(1))/exp(1)-(1/2)*(x-exp(1))^2/(exp(1))^2+(1/3)*(x-exp(1))^3/(exp(1))^3-(1/4)*(x-exp(1))^4/(exp(1))^4+(1/5)*(x-exp(1))^5/(exp(1))^5

(34)

Graphical illustration:

plot([f, p], 0 .. 8, view = [0 .. 8, -4 .. 3], color = [blue, red], thickness = [2, 1], gridlines)

 

 

``