
The Wave Partial Differential Equation 231
> B(n):=Int((f(x)*gamma/2+g(x))*X[n](x)*w(x), x=a..b)/omega[n];B(n):=expand(value(%)):
B(n) :=
20
⎛
⎝
1
0
11
10
x(1 −x)
√
2 sin(nπx)dx
⎞
⎠
25n
2
π
2
−4
(4.13)
> B(n):=radsimp(subs({sin(n*Pi)=0, cos(n*Pi)=(−1)ˆn},%));
B(n) := −
44
√
2(−1 +(−1)
n
)
π
3
n
3
25n
2
π
2
−4
(4.14)
> T[n](t):=exp((−gamma/2)*t)*(A(n)*cos(omega[n]*t)+B(n)*sin(omega[n]*t)):
Generalized series terms
> u[n](x,t):=eval(T[n](t)*X[n](x)):
Series solution
> u(x,t):=Sum(u[n](x,t),n=1..infinity);
u(x, t) :=
∞
n=1
e
−
1
10
t
⎛
⎝
−
2
√
2(−1 +(−1)
n
) cos
1
20
25n
2
π
2
−4 t
π
3
n
3
(4.15)
−
44
√
2(−1 +(−1)
n
) sin
1
20
25n
2
π
2
−4 t
π
3
n
3
25n
2
π
2
−4
⎞
⎠
√
2 sin(nπx)
First few terms of sum
> u(x,t):=sum(u[n](x,t),n=1..3):
ANIMATION
> animate(u(x,t),x=a..b,t=0..20,thickness=3);
The preceding animation command illustrates the spatial-time-dependent solution for u(x, t).
The following animation sequence in Figure 4.2 shows snapshots of the animation at times
t = 0, 1, 2, 3, 4, and 5.
ANIMATION SEQUENCE
> u(x,0):=subs(t=0,u(x,t)):u(x,1):=subs(t=1,u(x,t)):
> u(x,2):=subs(t=2,u(x,t)):u(x,3):=subs(t=3,u(x,t)):
> u(x,4):=subs(t=4,u(x,t)):u(x,5):=subs(t=5,u(x,t)):
> plot({u(x,0),u(x,1),u(x,2),u(x,3),u(x,4),u(x,5)},x=a..b,thickness=10);