function reaction_ode45 ( )

%*****************************************************************************80
%
%% reaction_ode45() uses ode45() to solve reaction_ode().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 April 2021
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'reaction_ode45():\n' );
  fprintf ( 1, '  Use ode45() to solve reaction_ode().\n' );
%
%  Get parameter values.
%
  [ k, t0, y0, tstop ] = reaction_parameters ( );
%
%  Solve the equation.
%
  f = @ reaction_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 );
%
%  Evaluate exact solution.
%
  ye = reaction_exact ( t );
%
%  Plot.
%
  figure ( 1 );
  clf ( );
  hold ( 'on' );
    plot ( t, y(:,1), 'ro', 'linewidth', 3 );
    plot ( t, y(:,2), 'go', 'linewidth', 3 );
    plot ( t, y(:,3), 'bo', 'linewidth', 3 );
    plot ( t, ye(:,1), 'c-', 'linewidth', 3 );
    plot ( t, ye(:,2), 'm-', 'linewidth', 3 );
    plot ( t, ye(:,3), 'y-', 'linewidth', 3 );
    plot ( tspan, [0.0,0.0], 'k-', 'linewidth', 3 );
  hold ( 'off' )
  grid ( 'on' );
  xlabel ( '<---  t  --->' );
  ylabel ( '<---  Concentrations  --->' );
  title ( 'reaction_ode(): A+B --k--> C, ode45()' );
  legend ( 'A', 'B', 'C', 'Aexact', 'Bexact', 'Cexact', 'x axis', 'Location', 'North' );
  filename = 'reaction_ode45_solution.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  h = reaction_conserved ( y );

  figure ( 2 );
  clf ( );
  hold ( 'on' );
    plot ( t, h, 'r-', 'linewidth', 3 );
    plot ( tspan, [h(1),h(1)], 'b--', 'linewidth', 3 );
    plot ( tspan, [0.0,0.0], 'k-', 'linewidth', 3 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<---  t  --->' );
  ylabel ( '<---  conserved quantity  --->' );
  title ( 'reaction_ode(): ode45(): conservation' );
  legend ( 'h', 'h initial', 'x axis' );
  filename = 'reaction_ode45_conservation.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

