function wave_ode45 ( )

%*****************************************************************************80
%
%% wave_ode45() tests wave_ode() using ode45().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    19 December 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'wave_ode45():\n' );
  fprintf ( 1, '  Test wave_ode() using ode45().\n' );
%
%  Get the parameters.
%
  [ xmin, xmax, nx, dx, c, t0, tstop ] = wave_parameters ( );
  x = linspace ( xmin, xmax, nx );
%
%  Under periodic boundary conditions, our integration process is simple.
%
  f = @ wave_deriv;
  tspan = [ t0, tstop ];
  w0 = wave_init ( );

  [ t, w ] = ode45 ( f, tspan, w0 );
%
%  Plot the energy.
%
  we = wave_exact ( t0 );
  he = wave_conserved ( we );

  h = wave_conserved ( w );

  figure ( 1 );
  clf ( );
  hold ( 'on' );
    plot ( t, h, 'ro', 'linewidth', 2 );
    plot ( tspan, [he,he], 'b--', 'linewidth', 2 );
    plot ( tspan, [0.0, 0.0 ], 'k-', 'linewidth', 2 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- Time -->' );
  ylabel ( '<-- Energy -->' );
  title ( 'wave ode45: energy' );
  legend ( 'Computed energy', 'Exact energy', 'Zero energy', ...
    'Location', 'South' );
  filename = 'wave_ode45_energy.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
  close ( 1 );

  return
end

