# Wave Equation PDE [closed]

I'm trying to solve the following PDE wave equation using method of lines:

Wave Equation: u_tt = u_xx

with initial condition: u(0,x) = sin*pi,u_t(0,x)=0, 0 < x < 1

boundary condition: u(t,0) = 0, u(t,1) = 0, t >= 1

Edited: deleted the old code and will be posting a new one soon. :)

• There is now no question here at all. – David Ketcheson Nov 14 '15 at 7:48

The problem is that odeint solves first-order ODEs of the form $$\dot u(t) = Au(t),$$ but the wave equation is (after discretization in space) a second-order ODE of the form $$\ddot{u}(t) = Au(t).$$ (And in fact, your plot looks quite reasonable for the solution to a parabolic equation.) To apply a black-box ODE solver (which is really not such a great idea, by the way), you first need to rewrite the wave equation as a system of first-order equations \left\{\begin{aligned} \dot{u}(t) &= v(t),\\ \dot{v}(t) &= Au(t).\end{aligned}\right.
Since the wave equation involves a second derivative in time, two initial conditions are necessary: initial displacement $U(x,0)$ and initial velocity $U_t(x,0)$. I don't see the initial velocity condition specified in your question. This leads me to suspect that there is something wrong with the tutorial you linked to...