function dydt = henon_heiles_deriv ( t, y )

%*****************************************************************************80
%
%% henon_heiles_deriv() evaluates the derivative of henon_heiles_ode().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 April 2021
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Michel Henon, Carl Heiles,
%    The applicability of the third integral of motion: 
%    Some numerical experiments,
%    The Astronomical Journal,
%    Volume 69, pages 73-79, 1964.
%
%  Input:
%
%    real T, Y(4): the arguments of the derivative.
%
%  Output:
%
%    real DYDT(4): the value of the derivative.
%
  [ e, lam, t0, y0, tstop ] = henon_heiles_parameters ( );

  u =  y(1);
  up = y(2);
  v =  y(3);
  vp = y(4);

  dudt = up;
  dupdt = - u - 2.0 * lam * u * v;
  dvdt = vp;
  dvpdt = - v - lam * ( u.^2 - v.^2 );

  dydt = [ dudt; dupdt; dvdt; dvpdt ];

  return
end

