I have a wave equation for displacement and velocity, I want to add this boundary condition $v(x=0,\,t>0)=1$

My mathematica code is

sol = 
    {1/1000 D[u[x, t], {t, 2}] == D[u[x, t], {x, 2}], 
     D[u[x, t], t] == v[x, t], 
     u[x, 0] == 0, 
     v[x, 0] == 0, v[0, t > 0] == 1, v[L, t] == 0}, 
    {u[x, t], v[x, t]}, {x, 0, L}, {t, 0, 1}]

L is a constant.

  • $\begingroup$ What is the value of L? Would it be acceptable to just reduce your condition to v[0, t] == 1? $\endgroup$
    – MarcoB
    Jan 20, 2021 at 22:11
  • $\begingroup$ Let try v[0, t] == If[t < 10^-4, 0, 1], but system looks like overdetermined. You don't need v as separate variable if you use second order equation for 'u'. $\endgroup$ Jan 20, 2021 at 22:17
  • $\begingroup$ Can you please tell me how to use NDSolve if v is not a separate variable? And how to plot v if I don't make v as separate variable? $\endgroup$ Jan 20, 2021 at 22:57

1 Answer 1


Do I understand this correctly: A string at rest between 0 and L with zero displacement and zero velocity at t==0 and where you move the point at x==0 with constant velocity of 1.

Note, we simply define the velocity at t==0 for all x to be zero and the velocity of point x==1 for all times. There is some inconsistency here, MMA will give a warning, but will happily calculate anyway. We are integrating and a point singularity will have no effect. For an example we choose L==1:

L = 1;
sol[x_, t_] = 
  u[x, t] /. NDSolve[{1/1000 D[u[x, t], {t, 2}] == D[u[x, t], {x, 2}],
      u[x, 0] == 0, Derivative[0, 1][u][x, 0] == 0, 
      Derivative[0, 1][u][0, t] == 1, u[L, t] == 0}, 
     u[x, t], {x, 0, L}, {t, 0, 1}][[1]];
Plot3D[sol[x, t], {x, 0, L}, {t, 0, 1}, AxesLabel -> {"x", "t", "z"}]

enter image description here


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.