# Numerical Solution of pde with boundary conditions

I'm trying, without success, to solve numerically the pde $$\frac{\partial^2 u(x,t)}{\partial x^2} = \frac{\partial^2 u(x,t)}{\partial t^2}$$ with the boundary conditions $$u(0,t)=0$$, $$u(1,t)=0$$, $$u(x,0)=0$$ and $$\frac{\partial u(x,t)}{\partial t}|_{t=0}=2 \sin(\pi x) + 4 \sin(3 \pi x)$$

Here is my code:

NDSolve[{D[u[x, t], x, x] == D[ u[x, t], t, t],
Derivative[0, 1][u[x, t]][x, 0] ==
2 Sin[\[Pi] x] + 4 Sin[3 \[Pi] x], u[0, t] == 0, u[1, t] == 0,
u[x, 0] == 0}, u[x, t], {x, 0, 1}, {t, 0, 5}]


I'have an analytical solution but need the numeric computation for comparison purposes. Any help is appreciated.

NDSolve[{D[u[x, t], x, x] == D[u[x, t], t, t],
Derivative[0, 1][u][x, 0] == 2 Sin[π x] + 4 Sin[3 π x],
u[0, t] == 0, u[1, t] == 0, u[x, 0] == 0},
u[x, t], {x, 0, 1}, {t, 0, 5}]


Or

NDSolve[{D[u[x, t], x, x] ==
D[u[x, t], t, t], (D[u[x, t], t] /. t -> 0) ==
2 Sin[π x] + 4 Sin[3 π x], u[0, t] == 0, u[1, t] == 0,
u[x, 0] == 0}, u[x, t], {x, 0, 1}, {t, 0, 5}]


• That was it, Thanks! Commented Dec 21, 2020 at 1:16