a) The wave equation is
> |
pde:=diff(u(x,t),t$2)=c^2*diff(u(x,t),x$2):%; |
|
The d'Alembert's solution is
> |
pdesol:=pdsolve(pde,u(x,t)):%; |
|
> |
pdesol:=subs(_F1=F[1],_F2=F[2],%):%; |
|
> |
uxt:=unapply(rhs(pdesol),x,t): |
|
d'Alembert's solution satisfying the initial conditions
|
> |
eq2:=D[2](uxt)(x,0)=g(x):%; |
|
Integrating gives
> |
Int(lhs(eq2),x)=Int(subs(x=s,rhs(eq2)),s=a..x):%; |
|
|
Solving for and
> |
sol:=solve({eq1,eq3},{F[1](x),F[2](-x)}):%; |
> |
F1:=unapply(subs(sol,F[1](x)),x): F2:=unapply(subs(sol,F[2](-x)),x): |
The solution of
is then
> |
u(x,t)=F1(c*t+x)+F2(c*t-x); |
|
b) The solution is given by
> |
u(x,t)=VibratingString(f,g,L,c,infinity):
simplify(%) assuming n::integer; |
> |
uxt:=unapply(VibratingString(f,g,L,c,10),x,t):
p1:=plot(uxt(x,0),x=0..1,color=brown,legend=typeset(u(`x,0`))): |
|
> |
u(0.6,0.2)=evalf(uxt(0.6,0.2)); |
> |
u(0.6,0.3)=evalf(uxt(0.6,0.3)); |
> |
u(0.6,0.5)=evalf(uxt(0.6,0.5)); |
> |
u(0.6,1)=evalf(uxt(0.6,1)); |
|
> |
animate(plot,[uxt(x,t),x=0..1,color=blue,thickness=2],t=0..3,frames=40,background=p1):%; |
|
> |
dAlembert(f,g,L,c,3,40,s):%; |
Click and start the animation.
|
The approximated solution above using 10 partial sums was .
Using 100 partial sums, we get
> |
uxt:=unapply(VibratingString(f,g,L,c,100),x,t):
p1:=plot(uxt(x,0),x=0..1,color=brown,legend=typeset(u(`x,0`))): |
> |
u(0.6,1)=evalf(uxt(0.6,1)); |
|