ME 401 Legendre Polynomials

‡ 1. Introduction This notebook has three objectives: (1) to summarize some useful information about Legendre polynomi- als, (2) to show how to use Mathematica in calculations with Legendre polynomials, and (3) to present some examples of the use of Legendre polynomials in the solution of Laplace's equation in spherical coordinates. In our course, the Legendre polynomials arose from for the Laplace equation in spherical coordi- nates, so we begin there. The basic spherical coordinate system is shown below. The location of a point P is specified by the distance r of the point from the origin, the angle f between the position vector and the z-axis, and the angle q from the x-axis to the projection of the position vector onto the xy plane.

The Laplace equation for a function F(r, f, q) is given by

1 ∂ ∂F 1 ∂ ∂F 1 ∂2 F “2 F = ÅÅÅÅÅÅÅÅ ÅÅÅÅÅÅÅÅÅ r2 ÅÅÅÅÅÅÅÅÅÅÅ + ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ ÅÅÅÅÅÅÅÅÅÅ sinf ÅÅÅÅÅÅÅÅÅÅÅ + ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ ÅÅÅÅÅÅÅÅÅÅÅÅÅÅ = 0 . (1) r2 ∂r ∂r r2 sinf ∂f ∂f r2 sin2 f ∂q2

J N J N 2 legendre.nb

In this notebook, we will consider only axisymmetric solutions of (1) -- that is, solutions which depend on r and f but not on q. Then equation (1) reduces to

1 ∂ ∂F 1 ∂ ∂F ÅÅÅÅÅÅÅÅ ÅÅÅÅÅÅÅÅÅ r2 ÅÅÅÅÅÅÅÅÅÅÅ + ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ ÅÅÅÅÅÅÅÅÅÅ sinf ÅÅÅÅÅÅÅÅÅÅÅ = 0 . (2) r2 ∂r ∂r r2 sinf ∂f ∂f As we showed in class by a rather lengthy analysis, equation (2) has separated solutions of the form J N J N n - n+1 r Pn cosf and r Pn cosf , (3)

where n is a non-negative integer and Pn is the nth Legendre polynomial. These solutions can be used to solve H L axisymmetric problems inside a sphere, exterior to a sphere, or in the region between concentric spheres. We include one exampleH L of each type ofH problemL later in this notebook. Now we look in more detail at Legendre's equation and the Legendre polynomials.

‡ 2. Legendre Polynomials

ü 2.1

The first result in the search for separated solutions of equation (2), which ultimately leads to the formulas (3), is the pair of differential equations (4) for the r-dependent part F(r), and the f-dependent part P(f) of the separated solutions.

d2 F dF d dP r2 ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ + 2 r ÅÅÅÅÅÅÅÅÅÅ - lF = 0 , and ÅÅÅÅÅÅÅÅÅ sinf ÅÅÅÅÅÅÅÅÅÅ + lsinf P = 0 , (4) dr2 dr df df where l is the separation constant. The r-equation is equidimensional and thus has solutions, easily found, which are powers of r. The f-equation is Legendre's equation.J WeN begin by transforming it to a somewhat simpler form by a change of independent variable, namely

h = cosf . (5) Then equation (4) becomes

d dP ÅÅÅÅÅÅÅÅÅ 1 - h2 ÅÅÅÅÅÅÅÅÅÅ + l P = 0 , -1 < h < 1 . (6) dh dh The equation (6) has regular singular points at the endpoints h = ± 1. This equation plus the condition that the solutions be well-behavedAH L atE the endpoints constitute a singular Sturm-Liouville system. Those special values of l for which there are such well-behaved solutions are the eigenvalues of the problem.

As we showed in class, we may find solutions of (6) in the form of power series about h = 0: P(h) = ¶ n n=0 an h . By substitution of this into equation (6), we find the recurrence relation for the coefficients an :

n n + 1 - l a = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ a . (7) ⁄ n+2 n + 1 n + 2 n Because of the index increment of 2 in (7), the solutions fall naturally into even and odd functions of h, with the H L coefficient sequences of the two not mixing. For very large n, we may approximate the relation (7) by ignoring l H L H L compared with n(n + 1). The result is (n + 2)an+2 > nan -- that is, an > constant/n. From that result it is possible to show that any such solution is logarithmically singular at one or both endpoints. This result is suggested by (but not proved by) the two series legendre.nb 3

¶ ¶ hn -1 n+1 hn ln 1 - h = - ÅÅÅÅÅÅÅÅÅ , and ln 1 + h = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ . (8) n n n=1 n=1 The only way to avoid such singularities in the solution is forH theL series to terminate. We see immediately from H L ‚ H L „ the recurrence relation (7) that termination occurs if and only if l = k(k + 1) for k a non-negative integer. The terminating solution in that case is a polynomial of degree k. If k is even, the polynomial has only even powers and is then an even function of h. If k is odd, only odd powers appear and the function is odd. Such solutions are

called Legendre polynomials. The kth one is denoted by Pk (h), with the convention that the arbitrary multiplica- tive constant is fixed by the condition

Pk 1 = 1 . (9) Any of the polynomials can be constructed directly from the recurrence formula (7) and the normalization (9), although this is not necessarily the most efficient way to carry out the construction. There is a well-known formula, calledH L Rodrigues' formula, which gives the Legendre polynomials. Although it is not usually used to compute the polynomials, it is still of interest:

k 1 d 2 k Pk h = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ ÅÅÅÅÅÅÅÅÅÅÅÅ h - 1 . 2k k! dhk

The Legendre polynomials are built into Mathematica. Mathematica's notation for Pk (h) is Legendre- P[k,Hh].L We use MathemaH ticaL to obtain the formulas for the first 11 of these polynomials. We put them in a table.

TableForm Table i, i * i + 1 , LegendreP i, h , i, 0, 10 , TableHeadings Ø None, "k", "lk ", "Pk h " k l P h k@ @8k H L @ D< 8

legraph k_ :=

Plot LegendreP k, h , h, -1, 1 , AxesLabel Ø "h", "Pk h " , PlotRange Ø -1.1, 1.1 , -1.1, 1.1 , PlotLabel Ø SequenceForm@ D " k =", PaddedForm k, 3 @ @ D 8 < 8 H L < Do legraph i ,88 i, 0, 10 < 8 << @ @ DDD Pk h k = 0 @ @ D 8

h -1 -0.5 0.5 1

-0.5

-1

Pk h k = 1 1 H L 0.5

h -1 -0.5 0.5 1

-0.5

-1 legendre.nb 5

Pk h k = 2 1 H L 0.5

h -1 -0.5 0.5 1

-0.5

-1

Pk h k = 3 1 H L 0.5

h -1 -0.5 0.5 1

-0.5

-1

Pk h k = 4 1 H L 0.5

h -1 -0.5 0.5 1

-0.5

-1 6 legendre.nb

Pk h k = 5 1 H L 0.5

h -1 -0.5 0.5 1

-0.5

-1

Pk h k = 6 1 H L 0.5

h -1 -0.5 0.5 1

-0.5

-1

Pk h k = 7 1 H L 0.5

h -1 -0.5 0.5 1

-0.5

-1 legendre.nb 7

Pk h k = 8 1 H L 0.5

h -1 -0.5 0.5 1

-0.5

-1

Pk h k = 9 1 H L 0.5

h -1 -0.5 0.5 1

-0.5

-1

Pk h k = 10 1 H L 0.5

h -1 -0.5 0.5 1

-0.5

-1 We see the expected alternation between even and odd functions, and the expected number of zeros in each case.

There are a large number of formulas involving Legendre polynomials. We consider here only a few of the most useful. The following is a recursion formula that relates three consecutive Legendre polynomials: 8 legendre.nb

n + 1 Pn+1 h - 2 n + 1 hPn h + nPn-1 h = 0 . (10)

Although Pn-1 is not defined when n = 0, you can easily check that the formula (10) remains true in that case if we define P to be anything bounded. An interesting application of (10) is to compute P h , starting with the known -1H L H L H L H L H L n functions P0 h = 1 and P1 h = h. Then we get

2 n + 1 h Pn h - n Pn-1 h H L P h = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ nH+1L H L n + 1 2 3 h P1 h - P0 h 3 h - 1 so P2 h =H ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅL ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅH L ÅÅÅÅÅÅÅÅÅÅ = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅH L ÅÅÅÅÅÅÅÅÅÅ , H L 2 2 (11) 2 5 h P2 h - 2 P1 h 5 3 h - 1 2 5 3 3 and P3 h = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅH L ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅHÅÅÅÅÅÅÅÅL ÅÅÅÅÅÅÅ = ÅÅÅÅÅ h ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ - ÅÅÅÅÅ h = ÅÅÅÅÅ h - ÅÅÅÅÅ h . H L 3 3 2 3 2 2

H L H L This can be continuedH L to any order. A second useful recursion formula for three consecutive functions contains derivatives:

£ £ P n+1 h - P n-1 h = 2 n + 1 Pn h . (12) This formula is valid for n r 1.

Now weH lookL at valuesH L of theH polynomialsL H L for special values of h. Because of the way that the polynomi- als are defined, we have

Pn 1 = 1 . (13)

Pn is an even function for n even and an odd function for n odd, so

H L n Pn -1 = -1 . (14)

Now consider h = 0. When n is odd, Pn is odd, so that Pn (0) = 0. When n is even, we may apply (10) repeatedly, using h = 0, and starting with n = 1, to get H L H L -1 n 2 n ! P2 n 0 = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ . (15) 22 n n! 2 We use these results to calculate a few integrals involving Legendre polynomials. These integrals will be H L H L useful in constructingH L expansions in the next section. We first use (12) and (14) to construct an indefinite integral H L of Pn , starting from a lower limit of -1. We get

h è è Pn+1 h - Pn-1 h Pn h „ h = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ . (16) -1 2 n + 1 This is valid for n r 1. It follows immediately from (13) and (16) that H L H L ‡ H L 1 Pn h „ h = 0 , (17) -1

for n ≥ 1. This is a special case of the discussed in the next section. (Because P0 = 1, Pn = Pn P0 , and (17) then says‡ thatH PL 0 and Pn are orthogonal on[-1,1].) Another special case of (16) is h = 0, which gives

0 Pn+1 0 - Pn-1 0 Pn h „ h = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ . (18) -1 2 n + 1

H L H L ‡ H L legendre.nb 9

If n is even the right-hand side is zero. If n is odd, the values at 0 are given by (15). By subtracting (18) from (17) we get

1 Pn-1 0 - Pn+1 0 Pn h „ h = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ , (19) 0 2 n + 1 which again is zero for n even, and can be evaluated for n odd by using (15). H L H L ‡ H L We can also evaluate integrals of the form hPn h „h by using the recursion relations (10) and (12). The result of the somewhat tedious calculation is the formula below, valid for n r 2.

h è è è n + 1 2 n - 1 Pn+2 Ÿh +H L2 n + 1 Pn h - n 2 n + 3 Pn-2 h h Pn h „ h = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ . (20) -1 2 n - 1 2 n + 1 2 n + 3 For the special case h = 1, we get from (13) and (20) H L H L H L H L H L H L H L ‡ H L 1 H L H L H L

hPn h „ h = 0 , (21) -1

valid for n ≥ 2, again a special case of orthogonality, because P1 h = h. Another special case of (20) is h = 0, which gives‡ H L

0 n + 1 2 n - 1 Pn+2 0 + 2 n + 1 H PLn 0 - n 2 n + 3 Pn-2 0 hPn h „ h = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ , (22) -1 2 n - 1 2 n + 1 2 n + 3 which is zero for n odd, and may be evaluted from (15) for n even. Finally, by subtracting (22) from (21), we get H L H L H L H L H L H L H L ‡ H L 1 H L H L H L n 2 n + 3 Pn-2 0 - 2 n + 1 Pn 0 - n + 1 2 n - 1 Pn+2 0 hPn h „ h = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ . (23) 0 2 n - 1 2 n + 1 2 n + 3 We will use some of these integrals in the examples of expansions in the next section, and in the Laplace equation H L H L H L H L H L H L H L examples in the lastH section.L ‡ H L H L H L

ü 2.3 Expansions in Legendre Polynomials

As we showed in class from the differential equation (6), the Legendre polynomials are orthogonal on the interval [-1,1]:

1 Pm h Pn h „ h = 0 for m ≠ n . (24) -1 It may be shown that the normalization integral is given by ‡ H L H L 1 2 Pn h Pn h „ h = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ . (25) -1 2 n + 1 The polynomials form a complete set on the interval [-1,1], and any piecewise smooth function may be expanded in a series‡ of the Hpolynomials.L H L The series will converge at each point to the usual mean of the right and left-hand limits. The coefficients are easily calculated using the orthogonality properties (24) and the normalization integral (25), and we have

¶ 2 n + 1 1 f h = Cn Pn h , where Cn = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ f h Pn h „ h . (26) 2 n=0 -1

H L ‚ H L ‡ H L H L 10 legendre.nb

As an example, we expand the function given below in such a series.

f h = -1 for - 1 b h b 0, and f h = 1 for 0 < h § 1. (27) Because f is odd, the even coefficients will all vanish. The odd coefficients are given by

H L 1 H L Cn = 2 n + 1 Pn h „ h . (28) 0 By using equation (19) we get H L ‡ H L Cn = Pn-1 0 - Pn+1 0 , (29) where the values at h = 0 needed in (29) are given by equation (15). We now use Mathematica to calculate the coefficients up to n = 51, starting with n = 1. @ H L H LD Module i , Co = ; Do Co = Append Co, LegendreP i - 1, 0 - LegendreP i + 1, 0 , i, 1, 51 The kth coefficient is then given by Co[[k]]. We sample a few values: @8 < 8< @ @ H @ D @ DLD 8

3 ÅÅÅÅ 2 @@ DD

Co 2

0 @@ DD Co 9

133 ÅÅÅÅÅÅÅÅÅÅ 256 @@ DD All the even coefficients are zero.

Now we define the kth partial sum, and then a graph of the kth partial sum, along with the original func-

tion. Because the coefficient of P0 is zero, we may start the sum over i with the i = 1 term. The given function f(h) is shown in blue and the partial sums in red.

legsum h_, k_ := Module i , Sum N Co i * LegendreP i, h , i, 1, k

f h_ :@= If hD< 0 , -1 , 1 @8 < @ @ @@ DDD @ D 8

F a,f 99 = =E 6

H4 L

2

f p p 3 p p 4 2 4 -2

-4

-6 We see that the trend is correct, but that many more terms would be needed for an accurate representation of the boundary condition. Fortunately, when we evaluate the solution away from the boundary, we have the factor (r/a i in the ith term and this greatly accelerates the convergence. To show this, we look at the solution on an interior sphere, namely r = 1. We plot a short sequence of partial sums of F versus f for r = 1. We use 5, 11, and 17 terms in the partial sums. L legendre.nb We see that the trend is correct, but that many more terms would be needed for an accurate representation of the 19 boundary condition. Fortunately, when we evaluate the solution away from the boundary, we have the factor (r/a i in the ith term and this greatly accelerates the convergence. To show this, we look at the solution on an interior sphere, namely r = 1. We plot a short sequence of partial sums of F versus f for r = 1. We use 5, 11, and 17 terms in the partial sums. L Do Plot Fsum 1.0, f, 5 + 6 * i , f, 0, p , PlotRange Ø -4, 4 , AxesLabel Ø "f", "F 1,f " , PlotPoints Ø 100, p p 3 p TicksA AØ 0,@ ÅÅÅÅ , ÅÅÅÅ , ÅÅÅÅÅÅÅÅ , pD ,8Automatic< , PlotLabel8Ø < 4 2 4 SequenceForm8 "k =",H PaddedFormL < 5 + 6 * i, 3 , i, 0, 2 99 = = F 1,f k = 5 4 @ @ DDE 8

F 1,f k = 11 4 3 H L 2 1 f p p 3 p p -1 4 2 4 -2 -3 -4 20 legendre.nb

F 1,f k = 17 4 3 H L 2 1 f p p 3 p p -1 4 2 4 -2 -3 -4 The three curves are graphically identical, as you can see by animating the sequence. Thus at this value of r, the solution is well-represented by three nonzero terms.

ü 3.2 Exterior of a Sphere

We consider in this section the solution of Laplace's equation exterior to a sphere of radius a, with the boundary condition on the sphere being the same as the one in the preceeding problem. The full problem state- ment is given below.

1 ∂ ∂F 1 ∂ ∂F ÅÅÅÅÅÅÅÅ ÅÅÅÅÅÅÅÅÅ r2 ÅÅÅÅÅÅÅÅÅÅÅ + ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ ÅÅÅÅÅÅÅÅÅÅ sinf ÅÅÅÅÅÅÅÅÅÅÅ = 0 , r > a, and 0 § f § p , r2 ∂r ∂r r2 sinf ∂f ∂f p with F a, f = V0 for 0 § f § ÅÅÅÅÅÅ , 2 (39) J N p J N and F a, f = -V for ÅÅÅÅÅÅ < f § p , 0 2 and F rH, f öL 0 . rz¶ The separated solutionsH L are given by equation (3). Because of the condition at ¶, only the negative powers of r may be used in thisH regionL exterior to a sphere. We superpose all of those solutions to get F:

¶ - n+1 F r, f = Bn r Pn cosf . (40) n=0 Imposing the boundary condition,H L we get H L ‚ H L

¶ - n+1 F a, f = Bn a Pn cosf . (41) n=0 H L Apart from the factor of the voltage V0 , the boundary function is the function expanded in the first example of section 2.3.H TheL coefficients‚ were storedH inL the array Co, except for the n = 0 coefficient, which is zero in this case. Thus

- n+1 Bn a = V0 Cn , (42)

where Cn is given by equation (28), and is equal to Co[[n]]. Then the kth partial sum of the series for F is given H L by (we clear the numerical values given earlier to a and V0 ): legendre.nb 21

Clear a, V0 ;

Fsum2 r_, f_, k_ := i+1 V0 Sum@ a Dr Co i LegendreP i, Cos f , i, 1, k We look at the first few partial sums. @ D @H ê L @@ DD @ @ DD 8

3 a2 V0 Cos f ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ2 ÅÅÅÅÅÅÅÅÅÅÅÅ 2@ r D

For r p a this is a reasonable@ D approximation to the entire solution, because the omitted terms are higher inverse powers of r. Thus when we are far from the sphere it looks like a dipole. Higher approximations are obtained by keeping more terms.

Fsum2 r, f, 3

3 a2 Cos f 7 a4 -3 Cos f + 5 Cos f 3 V0 ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ - ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ @ 2 r2 D 16 r4

i @ D H @ D @ D L y Fsum2j r, f, 5 z k { 3 a2 Cos f 7 a4 -3 Cos f + 5 Cos f 3 V0 ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ - ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ + @ 2 r2 D 16 r4 11 a6 15 Cos f - 70 Cos f 3 + 63 Cos f 5 ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ i @ D H 6 @ D @ D L j 128 r k H @ D @ D @ D L y ü 3.3 The Region Between Two Concentric Spheres z { As our final example, we consider the region between two concentric spheres, with radii a and b , b > a. We solve the Laplace equation in the region between the spheres, subject to a boundary condition on each sphere. The problem statement is given below.

1 ∂ ∂F 1 ∂ ∂F ÅÅÅÅÅÅÅÅ ÅÅÅÅÅÅÅÅÅ r2 ÅÅÅÅÅÅÅÅÅÅÅ + ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ ÅÅÅÅÅÅÅÅÅÅ sinf ÅÅÅÅÅÅÅÅÅÅÅ = 0 , a < r < b, and 0 § f § p , r2 ∂r ∂r r2 sinf ∂f ∂f (43) with F a, f = g f and F b,J f =N h f . J N We will specify g and h explicitly shortly. We leave them general now because it is easier to see the structure of the calculation thatH way.L WeH beginL by expanding both g and h in Legendre polynomials. That will make our task easier. H L H L

¶ 2 n + 1 p g f = Cn Pn cosf , where Cn = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ g f Pn cosf sinf „ f , (44) 2 n=0 0

and H L H L ‚ H L ‡ H L H L ¶ 2 n + 1 p h f = Dn Pn cosf , where Dn = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ h f Pn cosf sinf „ f . (45) 2 n=0 0

The coefficients Cn and Dn are known from the knownH boundaryL functions g and h. The separated solutions are given by equationH L ‚(3). The domainH L of the present problem, a <‡ r < Hb,L doesH not Linclude either the origin or the point at infinity. Thus there are no grounds for discarding any of the solutions and we keep them all. The solution for F is then obtained by superposition: 22 legendre.nb

The coefficients Cn and Dn are known from the known boundary functions g and h. The separated solutions are given by equation (3). The domain of the present problem, a < r < b, does not include either the origin or the point at infinity. Thus there are no grounds for discarding any of the solutions and we keep them all. The solution for F is then obtained by superposition:

¶ n - n+1 F r, f = An r + Bn r Pn cosf . (46) n=0 We now impose the two boundary conditions.H L We get H L ‚ H L H L

¶ ¶ n - n+1 F a, f = An a + Bn a Pn cosf = g f = Cn Pn cosf , (47) n=0 n=0 and H L H L ‚ H L H L H L ‚ H L

¶ ¶ n - n+1 F b, f = An b + Bn b Pn cosf = h f = Dn Pn cosf . (48) n=0 n=0 By equating the coefficients of correspondingH L terms in the Legendre expansions of (47) and (48), we get H L ‚ H L H L H L ‚ H L n - n+1 n - n+1 An a + Bn a = Cn , and An b + Bn b = Dn . (49)

These constitute two linear algebraic equations for each pair An and Bn . We solve them to get H L H L

n+1 n+1 n+1 n n b Dn - a Cn ab b Cn - a Dn An = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ , and Bn = ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ . (50) b2 n+1 - a2 n+1 b2 n+1 - a2 n+1 Now we look at a specific example. We take the functions given below for g and h. H L H L p g f = Va cos f for 0 § f § ÅÅÅÅÅ , 2 p and g f = 0 for ÅÅÅÅÅ < f § p , (51) 2 andH Lh f = 0 forH Lall f. This means thatH L H L Cn = Va Co2 n , Dn = 0 , (52) where Co2[[n]] are the coefficients calculated for the second example in section 2.3. We will use the coefficients in a somewhat different way here. Our new way will be more convenient with respect to the indexing, in that it will allow us to use index@@ zeroDD for the first term in the series. In section 2.3, we defined a function coeff[n] which returned the value of the nth coefficient Co2[[n]] in the above expansion. We use that function now to creat the

coefficient functions A[n] and B[n] corresponding to An and Bn .

A n_ := Va -an+1 coeff n b2 n + 1 - a2 n + 1

B n_ := Va an+1 b2 n + 1 coeff n b2 n + 1 - a2 n + 1 We @nowD define theH kth partial sum@ ofD theê H solution F. We callLL it Fsum3.

@ D H @ D ê H LL Fsum3 r_, f_, k_ := Sum A i ri + B i r- i + 1 LegendreP i, Cos f , i, 0, k We check this by looking at the first two partial sums. @ D H L @H @ D @ D L @ @ DD 8

Fsum3 r, f, 1

a Va a b Va a2 b3 Va a2 r Va - ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ + ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ + ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ3 ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ3 ÅÅ2ÅÅ - ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ3 ÅÅÅÅÅÅÅÅ3ÅÅÅÅÅÅ Cos f 4 -@a + b D4 -a + b r 2 -a + b r 2 -a + b

i y Fsum3 r, f, 2 j z @ D H L H L k H L H L { a Va a b Va a2 b3 Va a2 r Va - ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ + ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ + ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ3 ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ3 ÅÅ2ÅÅ - ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ3 ÅÅÅÅÅÅÅÅ3ÅÅÅÅÅÅ Cos f + 4 -@a + b D4 -a + b r 2 -a + b r 2 -a + b 1 5 a3 b5 Va 5 a3 r2 Va ÅÅÅÅ ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ - ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ -1 + 3 Cos f 2 5 5 3 i 5 5 y 2 16 -a + b r 16 -ja + b z @ D H L H L k H L H L { Now wei will use our solution to calculate the potentialy on a sphere half way between our two boundary j z H @ D L spheres. In addition,k H we will checkL our boundaryH conditionsL { on r = a and r = b. We assign numerical values to the parameters:

a = 2 ** m ** ; b = 4 ** m ** ; Va = 10.0 ** volts ** ; Next we define a function grapher[r,k] which uses the kth partial sum to construct a plot of potential versus f on the sphere of radius r. H L H L H L g f_ := If f < p 2 , Va * Cos f , 0

grapher r_, k_ := @PlotD Fsum3@Hr, f, kê ,L fH, 0, p ,@AxesLabelDL H LD Ø "f", "F r,f " , PlotLabel Ø SequenceForm "r = ", PaddedForm N r , 4, 1 , @ D p p 3 p PlotRangeA @Ø 0, 1.1D *8Va , Ticks< Ø 0, ÅÅÅÅ , ÅÅ8ÅÅ , ÅÅÅÅÅÅÅÅ ,Hp ,LAutomatic< 4 2 4 @ @ @ D 8

Do grapher a + i * b - a 5, 10 , i, 0, 5 ;

F r,f r = 2.0 @ @ H L ê D 8

6

4

2

f p p 3 p p 4 2 4 24 legendre.nb

F r,f r = 2.4

10 H L 8

6

4

2

f p p 3 p p 4 2 4

F r,f r = 2.8

10 H L 8

6

4

2

f p p 3 p p 4 2 4

F r,f r = 3.2

10 H L 8

6

4

2

f p p 3 p p 4 2 4 legendre.nb 25

F r,f r = 3.6

10 H L 8

6

4

2

f p p 3 p p 4 2 4

F r,f r = 4.0

10 H L 8

6

4

2

f p p 3 p p 4 2 4 The first and last graphs verify the boundary conditions that we have imposed on the inner and outer sphere. The remaining graphs show how the solution of the Laplace equation interpolates smoothly between these.