function duffing_ode45 ( )

%*****************************************************************************80
%
%% duffing_ode45 uses ode45() to solve the Duffing ODE.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    23 April 2021
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'duffing_ode45:\n' )
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Use ode45() to solve the duffing ODE.\n' );

  [ alpha, beta, gamma, delta, omega, t0, y0, tstop ] = duffing_parameters ( );

  f = @ duffing_deriv;
  tspan = [ t0, tstop ];
  
  [ t, y ] = ode45 ( f, tspan, y0 );

  n = size ( t, 1 );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of variable size steps = %d\n', n );
%
%  Plot T, Y1.
%
  plot ( t, y(:,1), 'r-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- t -->' );
  ylabel ( '<-- y1(t) -->' );
  title ( 'ode45: Duffing ODE Y1' );
  filename = 'duffing_ode45_y1.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Plot T, Y2.
%
  plot ( t, y(:,2), 'b-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- t -->' );
  ylabel ( '<-- y2(t) -->' );
  title ( 'ode45: Duffing ODE Y2' );
  filename = 'duffing_ode45_y2.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Plot Y1, Y2.
%
  plot ( y(:,1), y(:,2), 'c-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- y1(t) -->' );
  ylabel ( '<-- y2(t) -->' );
  title ( 'ode45: Duffing ODE Phase' );
  filename = 'duffing_ode45_phase.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'duffing_ode45():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end

