function expsin_rk12_adapt ( )

%*****************************************************************************80
%
%% expsin_rk12_adapt uses RK12 adaptive ODE integration on the expsin problem.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    21 March 2020
%
%  Author:
%
%    John Burkardt
%
  f = @ expsin_deriv;
  tspan = [ 0.0, 10.0 ];
  y0 = 1.0;
  dt = 0.1;
  tol = 0.75;
 
  [ t, y ] = rk12_adapt ( f, tspan, y0, dt, tol );

  n = length ( t );
  fprintf ( 1, '  Number of steps taken: %d\n', n );

  ye = expsin_exact ( t );
  e = abs ( ye - y );

  fprintf ( 1, '  Norm of error: %g\n', norm ( e ) );

  plot ( t, ye, 'b-', ...
         t, y, 'o', ...
         t, e, 'g', 'linewidth', 2 );
  grid ( 'on' );
  xlabel ( '<--- T --->' );
  ylabel ( '<--- Y(T) --->' );
  legend ( 'Exact', 'Estimate', 'Error' );
  filename = 'expsin_rk12_adapt.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

