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
. 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(%);**

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

`> `
**a/(1 - r): % = series( %, 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), x, 15);**

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 + x^2), x = -1,12);**

**___________________________________________________________________________________**

**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 := int( f(x), x);**

`> `
**series( %, x, 10);**

`> `
**diff( %, 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);**

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

**___________________________________________________________________________________**

**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);**

`> `
**diff( f(x), x);**

`> `
**series( %, x, 14);**

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

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;**

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

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

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

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);**

`> `
**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]);**

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);**

`> `
**diff( f(x), x);**

`> `
**series( %, x, 7);**

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

`> `
**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] );**

A power series does not necessarily represent the function for all values of x. For example,
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);**

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

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

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

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;**

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

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

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

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);**

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;**

`> `
**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);**

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;**

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

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

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

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

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;**

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

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

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

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);**

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.