16.12.2012 Views

Computer Algebra Recipes

Computer Algebra Recipes

Computer Algebra Recipes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

242 CHAPTER 5. LINEAR PDE MODELS. PART 1<br />

To solve Laplace's equation, Hugo loads the VectorCalculus package,<br />

> restart: with(plots): with(VectorCalculus):<br />

and inputs Laplace's equation in spherical coordinates. He notes that the problem<br />

has rotational symmetry about the z-axis, the direction of °uid °ow, so<br />

that there should be no Á dependence in the ¯nal solution. Accordingly, he<br />

takes U = U(r; μ).<br />

LE:=<br />

> LE:=expand(Laplacian(U(r,theta),'spherical'[r,theta,phi]))=0;<br />

μ <br />

@<br />

2 U (r; μ)<br />

@r<br />

r<br />

μ 2 @<br />

+<br />

U (r; μ)<br />

@r2 <br />

+<br />

μ <br />

@<br />

cos(μ) U (r; μ)<br />

@μ<br />

r 2 sin(μ)<br />

+<br />

@2 U (r; μ)<br />

@μ2 With no HINT provided, a general product solution is built with the pdsolve<br />

command, the answer involving one separation constant, c1, and four arbitrary<br />

constants. The result is then expanded.<br />

> sol:=expand(pdsolve(LE,INTEGRATE,build));<br />

sol := U (r; μ) =<br />

+<br />

+<br />

+<br />

C1 r (1=2 p μ<br />

1+4 c1) 1<br />

C3 LegendreP<br />

C1 r (1=2 p 1+4 c1) C4 LegendreQ<br />

p r<br />

μ 1<br />

2<br />

C2 r (¡1=2 p μ<br />

1+4 c1) 1<br />

C3 LegendreP<br />

p r<br />

C2 r (¡1=2 p μ<br />

1+4 c1) 1<br />

C4 LegendreQ<br />

p r<br />

2<br />

p r<br />

2<br />

r 2<br />

=0<br />

p<br />

1+4 c1 ¡ 1<br />

<br />

; cos(μ)<br />

2<br />

p<br />

1+4 c1 ¡ 1<br />

<br />

; cos(μ)<br />

2<br />

2<br />

p<br />

1+4 c1 ¡ 1<br />

<br />

; cos(μ)<br />

2<br />

p<br />

1+4 c1 ¡ 1<br />

<br />

; cos(μ)<br />

2<br />

The solution is expressed in terms of Legendre functions of the ¯rst kind<br />

(LegendreP) and of the second kind (LegendreQ). The former are well-behaved<br />

polynomial functions of cos μ, but the latter diverge at the ends of the angular<br />

range and therefore must be removed on physical grounds.<br />

> U:=remove(has,rhs(sol),LegendreQ);<br />

U :=<br />

C1 r (1=2 p μ<br />

1+4 c1) 1<br />

C3 LegendreP<br />

p r<br />

C2 r (¡1=2 p μ<br />

1+4 c1) 1<br />

C3 LegendreP<br />

2<br />

p<br />

1+4 c1 ¡ 1<br />

<br />

; cos(μ)<br />

2<br />

p<br />

1+4 c1 ¡ 1<br />

<br />

; cos(μ)<br />

2<br />

+<br />

p<br />

r<br />

2<br />

In standard math notation, the Legendre polynomials of the ¯rst kind would

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!