Application Center - Maplesoft

App Preview:

Power series expansions

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

Learn about Maple
Download Application


 

L23-powerSeriesExpansions.mws

Calculus II

Lesson 23: Power Series Expansions

In this lesson, we explore methods of expanding functions into power series. The basic idea hinges on the geometric series expansion of 1/(1-x) . However, using differentiation and integration we can expand many more functions into power series also. In addition, we will examine the interval of convergence and how it is affected by the location of the expansion and features of the function such as vertical asymptotes. In general, this module will reinforce methods one might use by hand and not rely on the automated expansions Maple can generate.

___________________________________________________________________________________

A. Expand A Function As A Series

___________________________________________________________________________________

An infinite geometric series can be simplified.

> Sum( a*r^k, k = 0..infinity): % = value(%);

Sum(a*r^k,k = 0 .. infinity) = -a/(r-1)

We can turn this process around. Staring with an expression, we can expand it into a series.

> a/(1 - r): % = series( %, r);

a/(1-r) = series(a+a*r+a*r^2+a*r^3+a*r^4+a*r^5+O(r^...

Given an expression in x, we can compute the series expansion. You can also do these by hand.

> series( 1/(1-x), x);

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

> series( 1/(1-x), x, 15);

series(1+1*x+1*x^2+1*x^3+1*x^4+1*x^5+1*x^6+1*x^7+1*...

Maple will expand to a certain number of terms as a default. We can also specify to what power of x we want to expand. Maple then uses the "big Oh" notation to indicate the order of the error or remainder.

All of the previous examples expanded the power series about x = 0. We can also expand about other values.

> series( 1/(1-x), x = 3, 12);

series(-1/2+1/4*(x-3)-1/8*(x-3)^2+1/16*(x-3)^3-1/32...
series(-1/2+1/4*(x-3)-1/8*(x-3)^2+1/16*(x-3)^3-1/32...

> series( 1/(2 + x^2), x = -1,12);

series(1/3+2/9*(x+1)+1/27*(x+1)^2-4/81*(x+1)^3-11/2...
series(1/3+2/9*(x+1)+1/27*(x+1)^2-4/81*(x+1)^3-11/2...

___________________________________________________________________________________

B. Integrate / Series / Differentiate

___________________________________________________________________________________

The method we used above to expand a series into a geometric series works only in certain cases. If an expression does not lend itself readily to this method, there are other tricks. One is to intergrate the function, expand the anti-derivative into a series, then differentiate the result. In this indirect way we find the series.

Lets consider an example.

We start with a function, integrate it, expand it into a power series, then differentiate to get back to the original function.

> f := x -> 3/(x-5)^2;

f := proc (x) options operator, arrow; 3*1/((x-5)^2...

> F := int( f(x), x);

F := -3*1/(x-5)

> series( %, x, 10);

series(3/5+3/25*x+3/125*x^2+3/625*x^3+3/3125*x^4+3/...

> diff( %, x);

series(3/25+6/125*x+9/625*x^2+12/3125*x^3+3/3125*x^...

We can convert the new found series into a polynomial and evaluate it to demonstrate that it take values close to the original function. The reason for the slight error is that we are only taking a finite number of terms here.

> g := unapply(convert( %, polynom), x);

g := proc (x) options operator, arrow; 3/25+6/125*x...

> f(1); g(1); f(1) - g(1);

3/16

1831047/9765625

123/156250000

___________________________________________________________________________________

C. Differentiate / Series / Integrate

___________________________________________________________________________________

We can use the same trick in reverse too. Take a function, differentiate it, expand into a power series, and integrate. When we integrate, the constant of integration will become the constant term of the series.

Lets consider an example.

We start with a funciton, integrate it, expand it into a power series, then differentiate to get back to the original function.

> f := x -> arctan(x);

f := arctan

> diff( f(x), x);

1/(1+x^2)

> series( %, x, 14);

series(1-1*x^2+1*x^4-1*x^6+1*x^8-1*x^10+1*x^12+O(x^...

> Int( %, x) : % = int( %%, x);

Int(series(1-1*x^2+1*x^4-1*x^6+1*x^8-1*x^10+1*x^12+...

Every indefinite integral has a constant of integration. In particular, when we integrate the series, we can't disregard the constant of integration. It turns out to be constant term of the series. Lets look at an example. We start with a function , and compute its series expansion by the method described above. Then we convert the series to a polynomial so we can graph it along with f(x).

> f := x -> 1/(1-x); c := -1;

f := proc (x) options operator, arrow; 1/(1-x) end ...

c := -1

> series( D(f)(x), x=c, 6);

series(1/4+1/4*(x+1)+3/16*(x+1)^2+1/8*(x+1)^3+5/64*...

> g := unapply( convert( int(%, x), polynom), x);

g := proc (x) options operator, arrow; 1/4*x+1/4+1/...

> plot( [f(x), g(x)], x = -5..1, y = -2..5, thickness=[3,2], color=[red,coral]);

[Maple Plot]

The thick red curve is the original function, and the thinner yellow curve is our series - which is supposed to represent our function. However, as you can see, it doesn't look like it's too good of a representation.

The one thing we forgot was to add the constant term, which is f(-1). We will now define a function h(x) = g(x) + f(-1)

> h := unapply( g(x) + f(c), x);

h := proc (x) options operator, arrow; 1/4*x+3/4+1/...

> plot( [f(x), g(x), h(x), [[c,0],[c,f(c)]] ], x= -5..1, y = -2..5, thickness= [3,1,2,2], color = [red, coral, blue, green]);

[Maple Plot]

The thick red curve is the original function, and the thinner yellow curve is our original series. The blue curve is h(x), which is the series plus the constant of integration. Then green segment is precisely the length of f(-1). This is difference in altitudes of g(x) and h(x). By adding this additional term, the series becomes a fairly good representation of the original function within certain bounds.

___________________________________________________________________________________

D. Interval of Convergence

___________________________________________________________________________________

Here is another example using the method described above. However, when we look at the graph of the function and its series, we see that it's a good representation only for a particular interval. Outside of that interval the series and function are quite different.

> f := x -> ln(1+x);

f := proc (x) options operator, arrow; ln(x+1) end ...

> diff( f(x), x);

1/(x+1)

> series( %, x, 7);

series(1-1*x+1*x^2-1*x^3+1*x^4-1*x^5+1*x^6+O(x^7),x...

> g := unapply( int(convert( %, polynom), x), x);

g := proc (x) options operator, arrow; x-1/2*x^2+1/...

> plot( [f(x), g(x), [[-1,0],[-1, g(-1)]], [[1,0],[1,g(1)]] ], x = -3..3, y = -7..3, color = [red, blue, coral, coral], thickness = [3,1,2,2] );

[Maple Plot]

A power series does not necessarily represent the function for all values of x. For example, xk = 1/(1-x) only for | x | < 1. Every power series has an interval of convergence - although in some cases it is all real numbers or just a single number. In the process we underwent to find his series, one of the steps included expanding a power series. Thus that interval of convergence effects the final series outcome.

We can examine this concept in further detail using a customized plot function.

> restart; with(plots):

Warning, the name changecoords has been redefined

> conv_plot := proc( f, g1,g2, a,b, c1, c2, eps)
local x1,x2,y1,y2,delta, m, M, A, B, i, n, CL;
n := 1: delta := (b-a)/n: x2 := a:
M := maximize( f(x), x = a..b): m := minimize(f(x), x = a..b):

for i from 1 to n do
x1 := x2: x2:= x1 + delta: y1 := evalf( f(x1)): y2 := evalf( f(x2)):
if( abs(evalf( y1 - g1(x1))) < eps ) then
CL := maroon:
else
CL := black:
fi:
#print ( [[x1, m],[x1,y1],[x2,y2],[x2,m]]);
A[i] := polygonplot( [[x1, m],[x1,y1],[x2,y2],[x2,m]], color = CL, style = patchnogrid):
if( abs(evalf( y1 - g2(x1))) < eps ) then
CL := coral:
else
CL := black:
fi:
B[i] := polygonplot( [[x1, M],[x1,y1],[x2,y2],[x2,M]], color = CL, style = patchnogrid):
od:

display( [plot([f(x), g1(x), g2(x)], x = a..b, y = n..M, thickness = [4,2,2], color = [red, blue, green] ),
plot( [[[c1, m],[c1,g1(c1)]], [[c2, g2(c2)],[c2,M]] ] , x =a..b, color = [blue, green], linestyle = 3),
seq( A[i], i = 1..n), seq( B[i], i = 1..n)], axes = framed );
end:

This special plot funcion will show where the series is within a small tolerance of the original function. This will provide us a convenient way to see where the series converges to the function and where it doesn't. It allows us to compare two approximate functions to an original function.

> f := x -> ln( 1+x);

f := proc (x) options operator, arrow; ln(1+x) end ...

> g := unapply( convert(series( f(x), x, 7), polynom), x);

g := proc (x) options operator, arrow; x-1/2*x^2+1/...

> h := unapply( convert(series( f(x), x, 12), polynom), x);

h := proc (x) options operator, arrow; x-1/2*x^2+1/...

> plot( {f(x), g(x)}, x = -3..3, y = -6..3);

[Maple Plot]

original function centers of series expansions

The original function, f(x0 = ln(1+x) is the thick red curve. The value curve is g(x) which is the series taken out to 7 terms. The interval where g differs from f by less than epsilon = .05 is indicated by the purple shading on the bottom of the screen, The dashed blue line indicates the center of the expansion. In a similar way, the green curve is the graph of h(x), which is the series taken out to 12 terms. The interval where it is close to f(x) is indicated by the yellow bar above the graph. What this diagram shows is that the series with more terms is a better fit to the function.Also, both series seem to converge within the same region between - 1 and +1.

Lets look at another example. We'll consider tan-1(x), and look at series expansions of 3 and 15 terms.

> f := x -> arctan(x); c := 0;

f := arctan

c := 0

> series( D(f)(x), x = c, 3); convert(int(%, x), polynom); g := unapply( %,x);

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

x-1/3*x^3

g := proc (x) options operator, arrow; x-1/3*x^3 en...

> series( D(f)(x), x = c, 15); convert(int(%, x), polynom); h := unapply( %,x);

series(1-1*x^2+1*x^4-1*x^6+1*x^8-1*x^10+1*x^12-1*x^...

x-1/3*x^3+1/5*x^5-1/7*x^7+1/9*x^9-1/11*x^11+1/13*x^...

h := proc (x) options operator, arrow; x-1/3*x^3+1/...

> plot( [f(x),g(x), h(x) ], x = -5..5, y = -4..4, color = [red, blue, green], thickness = [3,1,2] );

[Maple Plot]

At first glance, the blue graph ( the series with 3 terms ) might seem to mimize the function. However, on closer inspection, we see that within the interval [-1, 1], the green curve ( the series with 15 terms) stays with the curve better. We can see this even better using the special plot command.

> conv_plot( f, g, h, -3, 3, c, c, .1);

[Maple Plot]

In this example we have been using c = 0 as the center for our series expansion. We cal also do the same thing for a different center value. Here is an example with c = Pi/3. Notice how the entire convergence region moves along with the center to the right.

> f := x -> arctan(x); c := Pi/3;

f := arctan

c := 1/3*Pi

> series( f(x) , x = c, 3): convert( %, polynom): g := unapply( %, x):

> series( f(x) , x = c, 15): convert( %, polynom): h := unapply( %, x):

> conv_plot( f, g, h, -4, 4, c, c, .1);

[Maple Plot]

There is another interesting aspect to this investigation. The function we studied above, f(x) = ln( 1 + x ), has a vertical asymptote at x = -1. When we expanded a series about x = 0, ouir interval of convergence was (-1,1). But what happens when we expand around other values of x, farther from the singularity?

> f := x -> ln(1+x); c1 := 0; c2 := 2;

f := proc (x) options operator, arrow; ln(1+x) end ...

c1 := 0

c2 := 2

> g := unapply(convert(series( f(x), x = c1,12), polynom), x);

g := proc (x) options operator, arrow; x-1/2*x^2+1/...

> h := unapply(convert(series( f(x), x = c2, 12), polynom), x);

h := proc (x) options operator, arrow; ln(3)+1/3*x-...
h := proc (x) options operator, arrow; ln(3)+1/3*x-...

> plot( [ f(x), g(x), h(x) ], x = -0.85..7, y = -2..3, color = [red, blue, green], thickness = [3,1,2]);

[Maple Plot]

> conv_plot( f, g, h, -0.8, 7, c1, c2, .15);

[Maple Plot]

The red curve is the original function. the blue graph is the series expanded around x = 0, and the purple bar indicates the interval of convergence. The green graph is the series expanded about x = 2, and the yellow bar indicates its interval of convergence. From this diagram, it appears the expansion about 2, has interval of convergence approaching (-1, 5), instead of (-1,1) for the other. Lets look at another expansion value.

> c1 := 0; c2 := 4;

c1 := 0

c2 := 4

> g := unapply( convert(series( f(x), x = c1, 12), polynom), x);

g := proc (x) options operator, arrow; x-1/2*x^2+1/...

> h := unapply( convert(series( f(x), x = c2, 12), polynom), x);

h := proc (x) options operator, arrow; ln(5)+1/5*x-...
h := proc (x) options operator, arrow; ln(5)+1/5*x-...

> conv_plot(f, g, h, -0.8, 12, c1, c2, .15.2 );

[Maple Plot]

The expansion about x = 4 seems to have an interval of convergence approaching (-1, 9 ). Its a little hard to see where it cuts off on the right. The following plot helps to demonstrate this.

> plot( {f(x), g(x), h(x), [[9,0], [9,h(9)]] }, x = -.5..12, y = -1..3);

[Maple Plot]

From this example, it appears that a vertical asymptote is a like a brick wall which limits the convergence of a power series. Also, the interval of convergence must be symmetrical on either side of the center of the expansion. These two factors work together to make the convergence intervals smaller as we choose expansion points closer to the vertical asymptote.