function h = spring_conserved ( y )

%*****************************************************************************80
%
%% spring_conserved() returns a conserved quantity for the spring ODE.
%
%  Discussion:
%
%    This conserved quantity can be regarded as the total energy of
%    the system.  Actually, if damping is present, the energy will 
%    not be conserved.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 May 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real Y(:,2): the current solution.
%
%  Output:
%
%    real H(:): the value of the conserved quantity.
%
  u = y(:,1);
  v = y(:,2);

  [ m, b, k, t0, y0, tstop ] = spring_parameters ( );

  h = 0.5 * k * u.^2 + 0.5 * m * v.^2;

  return
end

