function expsin_rk12_error ( )

%*****************************************************************************80
%
%% expsin_rk12_error looks at rk12 error estimation.
%
%  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;
  n = 25;
 
  [ t, y1 ] = rk1 ( f, tspan, y0, n );
  [ t, y2 ] = rk2 ( f, tspan, y0, n );
  y = expsin_exact ( t );
  e_rk12 = abs ( y2 - y1 );
  e1_exact = abs ( y1 - y );
  e2_exact = abs ( y2 - y );
  fprintf ( 1, '  Norm of rk12 error estimate = %g\n', norm ( e_rk12 ) );
  fprintf ( 1, '  Norm of exact y1 error      = %g\n', norm ( e1_exact ) );
  fprintf ( 1, '  Norm of exact y2 error      = %g\n', norm ( e2_exact ) );

  plot ( t, e_rk12, 'r-', ...
         t, e1_exact, 'g-', ...
         t, e2_exact, 'b-', 'linewidth', 2 );
  grid ( 'on' );
  xlabel ( '<--- T --->' );
  ylabel ( '<--- Error --->' );
  title ( 'Error estimate (R), Y1 error (G), Y2 error (B)' );
  filename = 'expsin_rk12_error.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

