3
$\begingroup$

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.

$\endgroup$

1 Answer 1

2
$\begingroup$
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}]

enter image description here

$\endgroup$
1
  • $\begingroup$ That was it, Thanks! $\endgroup$
    – daaan
    Dec 21, 2020 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.