6
Lecture 3 Let's use Mathematica to study the 4 power series discussed in the Lecture. In[54]:= S1@x_D := Sum@H- xL ^n 2^n, 8n, 0, Infinity<D In[55]:= S2@x_D := Sum@- H- xL ^n n, 8n, 1, Infinity<D In[56]:= S3@x_D := Sum@H- 1L ^n x^ H2n + 1LH2n + 1L !, 8n, 0, Infinity<D Note the fairly standard expression for the factorial. In[57]:= S4@x_D := Sum@Hx + 2L ^n Sqrt@n + 1D, 8n, 0, Infinity<D We see that the first sum is just a geometric series with relative factor (-x/2), which, when it is conver- gent, sums to In[58]:= S1@xD Out[58]= 2 2 + x In[59]:= Plot@S1@xD, 8x, - 4, 4<, AxesLabel 8x, S1<D Sum::div : Sum does not converge. Sum::div : Sum does not converge. Sum::div : Sum does not converge. General::stop : Further output of Sum::div will be suppressed during this calculation. Out[59]= -4 -2 0 2 4 x 1 2 3 4 5 6 S1 So Mathematica has correctly concluded that the series does converge for |x| > 2. At the end points we have

Lec3 227 08 - University of Washingtonstaff.washington.edu/sdellis/Phys2278/Lec3_227_08.pdf · 2 Lec3_227_08.nb. So, as in the Lecture, the series only converges for -1 < x £ 1

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lec3 227 08 - University of Washingtonstaff.washington.edu/sdellis/Phys2278/Lec3_227_08.pdf · 2 Lec3_227_08.nb. So, as in the Lecture, the series only converges for -1 < x £ 1

Lecture 3

Let's use Mathematica to study the 4 power series discussed in the Lecture.

In[54]:= S1@x_D := Sum@H-xL^n � 2^n, 8n, 0, Infinity<D

In[55]:= S2@x_D := Sum@-H-xL^n � n, 8n, 1, Infinity<D

In[56]:= S3@x_D := Sum@H-1L^n x^H2 n + 1L � H2 n + 1L!, 8n, 0, Infinity<D

Note the fairly standard expression for the factorial.

In[57]:= S4@x_D := Sum@Hx + 2L^n � Sqrt@n + 1D, 8n, 0, Infinity<D

We see that the first sum is just a geometric series with relative factor (-x/2), which, when it is conver-

gent, sums to

In[58]:= S1@xD

Out[58]=

2

2 + x

In[59]:= Plot@S1@xD, 8x, -4, 4<, AxesLabel ® 8x, S1<D

Sum::div : Sum does not converge. �

Sum::div : Sum does not converge. �

Sum::div : Sum does not converge. �

General::stop : Further output of Sum::div will be suppressed during this calculation. �

Out[59]=

-4 -2 0 2 4

x

1

2

3

4

5

6

S1

So Mathematica has correctly concluded that the series does converge for |x| > 2. At the end points we

have

Page 2: Lec3 227 08 - University of Washingtonstaff.washington.edu/sdellis/Phys2278/Lec3_227_08.pdf · 2 Lec3_227_08.nb. So, as in the Lecture, the series only converges for -1 < x £ 1

In[60]:= S1@2D

Sum::div : Sum does not converge. �

Out[60]= ân=0

¥ H-1Ln

In[61]:= S1@-2D

Sum::div : Sum does not converge. �

Out[61]= ân=0

¥

1

The correct info about the divergence, ill-defined at one end (limit cycle) and infinite value at the other.

Now the second series

In[62]:= S2@xDOut[62]= Log@1 + xDIn[63]:= Plot@S2@xD, 8x, -4, 4<, AxesLabel ® 8x, S2<D

Sum::div : Sum does not converge. �

Sum::div : Sum does not converge. �

Sum::div : Sum does not converge. �

General::stop : Further output of Sum::div will be suppressed during this calculation. �

Out[63]=

-4 -2 2 4

x

-3

-2

-1

S2

Again we see that problems occur at |x| = 1. We have

In[64]:= S2@1DOut[64]= Log@2DIn[65]:= S2@-1D

Sum::div : Sum does not converge. �

Out[65]= ân=1

¥

-1

n

2 Lec3_227_08.nb

Page 3: Lec3 227 08 - University of Washingtonstaff.washington.edu/sdellis/Phys2278/Lec3_227_08.pdf · 2 Lec3_227_08.nb. So, as in the Lecture, the series only converges for -1 < x £ 1

So, as in the Lecture, the series only converges for -1 < x £ 1.

In[66]:= S3@xDOut[66]= Sin@xD

Mathematica sees this is the well behaved function everywhere!

In[67]:= Plot@S3@xD, 8x, -4, 4<, AxesLabel ® 8x, S3<D

Out[67]=

-4 -2 2 4

x

-1.0

-0.5

0.5

1.0

S3

So the interesting point here is that this plot takes enormous computing, because the software is trying

to evaluate S3[x] at a large number of x values, at each of which it redoes the inifinite sum. The lesson

is that, if you know the series can be summed to a know function (or functions) and you want to use it in

plots or calculations, then redefine it first.

In[68]:= S3@x_D := Sin@xD

In[69]:= Plot@S3@xD, 8x, -4, 4<, AxesLabel ® 8x, S3<D

Out[69]=

-4 -2 2 4

x

-1.0

-0.5

0.5

1.0

S3

The final function is

In[70]:= S4@xD

Out[70]=

PolyLogA 1

2, 2 + xE

2 + x

So the series defines a known (named) function but it is probably not one that you are familiar with.

Lec3_227_08.nb 3

Page 4: Lec3 227 08 - University of Washingtonstaff.washington.edu/sdellis/Phys2278/Lec3_227_08.pdf · 2 Lec3_227_08.nb. So, as in the Lecture, the series only converges for -1 < x £ 1

In[71]:= Plot@S4@xD, 8x, -4, 4<, AxesLabel ® 8x, S4<D

Sum::div : Sum does not converge. �

Sum::div : Sum does not converge. �

Sum::div : Sum does not converge. �

General::stop : Further output of Sum::div will be suppressed during this calculation. �

Out[71]=

-4 -2 2 4

x

1.0

1.5

2.0

2.5

3.0

3.5

4.0

S4

Suggesting issues at -3 and -1 where

In[72]:= S4@-1D

Sum::div : Sum does not converge. �

Out[72]= ân=0

¥ 1

1 + n

In[73]:= S4@-3D

Out[73]= -I-1 + 2 M ZetaB 1

2

F

In[74]:= N@%DOut[74]= 0.604899

As in the Lecture the series diverges at x = -1 but converges conditionally at x = -3. (Note the use of

the N[%] to obtain a numerical value for the previous expression.) Outside of this (semi-open) interval

the series diverges.

A similar behavior is exhibited by the function our series defines when it converges.

4 Lec3_227_08.nb

Page 5: Lec3 227 08 - University of Washingtonstaff.washington.edu/sdellis/Phys2278/Lec3_227_08.pdf · 2 Lec3_227_08.nb. So, as in the Lecture, the series only converges for -1 < x £ 1

In[75]:= PlotBPolyLogB 1

2, 2 + xF

2 + x

, 8x, -4, 4<, AxesLabel ® 8x, S4<F

Out[75]=

-4 -2 2 4

x

0.5

1.0

1.5

2.0

2.5

3.0

S4

Interestingly this function does have a definition elsewhere, but it is comples! A subject we will get to

shortly.

In[76]:= f@x_D :=

PolyLogB 1

2, 2 + xF

2 + x

In[77]:= N@[email protected]

Out[77]= 1.77237 ´ 106

In[78]:= N@[email protected][78]= -0.805031 - 1.06447 ä

Note that Mathematica is capable of generating many of the series expansions discussed in the notes

via the Series function. For example, Eq. (3.18)

In[79]:= Series@H1 + xL^p, 8x, 0, 4<D

Out[79]= 1 + p x +1

2

H-1 + pL p x2

+1

6

H-2 + pL H-1 + pL p x3

+1

24

H-3 + pL H-2 + pL H-1 + pL p x4

+ O@xD5

Or Eq. (3.20)

In[80]:= Series @Log@xD, 8x, 1, 4<D

Out[80]= Hx - 1L -1

2

Hx - 1L2+

1

3

Hx - 1L3-

1

4

Hx - 1L4+ O@x - 1D5

Here the {} has 3 arguments, the expansion variable, the point to expand about and the number of

terms in the expansion.

Mathematica also has the analytic skills to evalute sums as discussed in the Lecture. Examples are

In[81]:= f1@x_D := Sum@n x^Hn - 1L, 8n, 1, Infinity<D

Lec3_227_08.nb 5

Page 6: Lec3 227 08 - University of Washingtonstaff.washington.edu/sdellis/Phys2278/Lec3_227_08.pdf · 2 Lec3_227_08.nb. So, as in the Lecture, the series only converges for -1 < x £ 1

In[82]:= f1@xD

Out[82]=

1

H-1 + xL2

In[83]:= f2@x_D := Sum@x^Hn - 1L � n � Hn + 1L, 8n, 1, Infinity<D

In[84]:= f2@xD

Out[84]=

x + Log@1 - xD - x Log@1 - xDx2

Also the integral

Indefinite

In[85]:= Integrate@Exp@xD Cos@xD, xD

Out[85]=

1

2

ãx HCos@xD + Sin@xDL

Definite

In[86]:= Integrate@Exp@xD Cos@xD, 8x, 0, 1<D

Out[86]=

1

2

H-1 + ã HCos@1D + Sin@1DLL

In[87]:= N@%DOut[87]= 1.37802

Or directly numerically

In[88]:= NIntegrate@Exp@xD Cos@xD, 8x, 0, 1<DOut[88]= 1.37802

6 Lec3_227_08.nb