function dwdt = wave_deriv ( t, w )

%*****************************************************************************80
%
%% wave_deriv returns the right hand side of the wave PDE.
%
%  Discussion:
%
%    U is the vertical displacement;
%    V is dUdT;
%
%    C is the propagation speed.
%    XMIN, XMAX are the interval limits.
%
%    u' = v
%    v' = - c^2 uxx
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    19 December 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real t, the current time.
%
%    real w(nx*2), the current state values.
%
%  Output:
%
%    real dwdt(nx*2,1), the time derivatives of the current state values.
%
  [ xmin, xmax, nx, dx, c, t0 ] = wave_parameters ( );
%
%  Force W to be a COLUMN vector!
%
  w = w ( : );

  u = w(1:  nx);
  v = w(nx+1:2*nx);

%
%  We can approximate uxx:
%
  if ( false )
    uxx = laplacian_pp ( u, dx );
%
%  or use an exact formula.
%
  else
    uxx = wave_exact_xx ( t );
  end

  dudt = v;
  dvdt = c * uxx';
%
%  DWDT must be a COLUMN vector to keep ode45() happy.
%
  dwdt = [ dudt; dvdt ];

  return
end

