function h = pendulum_nonlinear_conserved ( y )

%*****************************************************************************80
%
%% pendulum_nonlinear_conserved(): conserved quantity for pendulum_nonlinear_ode().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    16 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real Y(:,2): the current solution.
%
%  Output:
%
%    real H(:): the value of the conserved quantity.
%
  [ g, l, m, t0, y0, tstop ] = pendulum_nonlinear_parameters ( );

  u = y(:,1);
  v = y(:,2);

  h = ( m * g / l ) * ( 1.0 - cos ( u ) ) + 0.5 * m * v.^2;

  return
end

