Question: How I solve PDE 1-D Wave Equation with initial and boundary conds

Hello, dear members! I try to solve the 1-D Wave Equation with initial and boundary conditions. And I have a problem when I'm trying to find the coeffs of Fourier series, that they depend on initial conditions. This is my code for Maple:


# set the PDE, ic(initial conds) and bc (boundary conds)
pde := diff(u(x, t), t, t) = a^2*diff(u(x, t), x, x);
ic := u(x, 0) = 0, D[2](u)(x, 0) = psi(x);
bc := u(0, t) = 0, u(l, t) = 0;
psi := piecewise(0 <= x and x <= l/2, x, l/2 <= x and x <= l, l - x);

# using Fourier method for solving (I require use this methods)
res := pdsolve(pde, HINT = T(t)*X(x));

ode1 := op(1, op(1, op(2, res)));

ode2 := op(2, op(1, op(2, res)));               

ode2 := subs(_c[1] = -lambda, ode2);

# solve 2 ODE
# equation rely X(x)
dsolve({ode2, X(0) = 0}, X(x));

sin(sqrt(lambda)*l) = 0;

solve(%, lambda, allsolutions);

lambda := (Pi*n/l)^2;

X := (x, n) -> sin(Pi*n*x/l);

# equation rely T(t)
ode1 := subs(_c[1] = -lambda, ode1);

dsolve({%, T(0) = 0}, T(t));

T := (t, n) -> C1[n]*sin(Pi*n*a*t/l);

# write the general solutions
Un := (x, t, n) -> T(t, n)*X(x, n);

# find the coeffs series
simplify(subs(t = 0, diff(u(x, t), t)) = psi);

((2/l)*l/(Pi*n*a)*int(psi*X(x, n), x = 0 .. l) assuming (x < l))
simplify(%) assuming n::posint;
C1[n] := factor(%)

But I got it:

How to find this C1 coefficient and solve this equation? Maple doesn't work now. This command does not give the result.
I attached mws files, so is another code for solving, but it is not working so((! 

Maybe I use this command wrong, or step-function is not convenient for maple?

Any helpful advice would be very cool. I am grateful in advance!


Please Wait...