function dydt = duffing_deriv ( t, y )

%*****************************************************************************80
%
%% duffing_deriv() evaluates the right hand side of duffing_ode().
%
%  Discussion:
%
%    x'' + delta x' + alpha x + beta x^3 = gamma * cos ( omega * t )
%
%    y1' = y2
%    y2' = - delta y2 - alpha y1 - beta y1^3 + gamma * cos ( omega * t )
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 April 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T, Y[2]: the time and solution value.
%
%  Output:
%
%    real DYDT[2]: the derivative value.
%
  [ alpha, beta, gamma, delta, omega, t0, y0, tstop ] = duffing_parameters ( );

  y1 = y(1);
  y2 = y(2);

  dy1dt = y2;
  dy2dt = - delta * y2 - alpha * y1 - beta * y1.^3 + gamma * cos ( omega * t );

  dydt = [ dy1dt; dy2dt ];

  return
end

