16.12.2012 Views

Computer Algebra Recipes

Computer Algebra Recipes

Computer Algebra Recipes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6.1. WAVE EQUATION MODELS 249<br />

> sol:=pdsolve(WE,HINT=sin(k*x)*g(t),INTEGRATE,build);<br />

sol := Ã(x; t) =sin(kx) C1 sin(ckt)+sin(kx) C2 cos(ckt)<br />

The string is initially at rest, so the transverse velocity _ Ã(x; 0) is equal to 0.<br />

Mentally di®erentiating the above output, clearly only the cos(ckt) term should<br />

be retained, since its derivative vanishes at t = 0, whereas the derivative of the<br />

sin(ckt) term does not. So Vectoria selects the term on the rhs of the solution<br />

containing the cosine term.<br />

> sol2:=select(has,rhs(sol),cos);<br />

sol2 := sin(kx) C2 cos(ckt)<br />

The displacement of the string must also vanish at x = L for arbitrary times, so<br />

onemusthavesin(kL) = 0, which yields k = n¼=L,withnapositive integer.<br />

She substitutes this result into sol2 , and temporarily removes any coe±cients<br />

by setting C1 and C2 equal to 1.<br />

> F[n]:=subs(fk=n*Pi/L,_C1=1,_C2=1g,sol2);<br />

³<br />

n¼x<br />

´ μ <br />

cn¼t<br />

Fn := sin cos<br />

L<br />

L<br />

The general solution satisfying the boundary conditions at x =0andL, and<br />

with zero initial transverse velocity, then is<br />

1X<br />

1X ³<br />

n¼x<br />

´ μ <br />

cn¼t<br />

Ã(x; t) = An Fn = An sin cos ; (6.2)<br />

L<br />

L<br />

n=1<br />

n=1<br />

where the coe±cients An have to be determined from the initial string pro¯le.<br />

This pro¯le is given by the piecewise function f.<br />

> f:=piecewise(xL/2,2*h*(L-x)/L);<br />

8<br />

><<br />

2 hx<br />

x<<br />

f := L<br />

>:<br />

L<br />

2<br />

2 h (L ¡ x) L<br />

L 2 0.<br />

> A[n]:=int(f*sin(n*Pi*x/L),x=0..L)/int(sin(n*Pi*x/L)^2,x=0..L)<br />

assuming L>0:<br />

The nth Fourier term in the in¯nite series representing the string displacement<br />

is then Ãn =An Fn, the result being simpli¯ed by assuming that n is an integer.<br />

> psi[n]:=simplify(A[n]*F[n]) assuming n::integer;<br />

³<br />

n¼<br />

´ ³<br />

n¼x<br />

´ μ <br />

cn¼t<br />

8 h sin sin cos<br />

2 L<br />

L<br />

Ãn :=<br />

n2 ¼2 0

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

Saved successfully!

Ooh no, something went wrong!