function squircle_ode45 ( )

%*****************************************************************************80
%
%% squircle_ode45() tests squircle_ode() using ode45().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 November 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'squircle_ode45():\n' );
  fprintf ( 1, '  Test squircle_ode() using ode45().\n' );

  [ s, t0, y0, tstop ] = squircle_parameters ( );

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

  n = length ( t );
  fprintf ( 1, '  Number of steps taken was %d\n', n );
%
%  Plot u, v.
%
  figure ( 1 );
  clf ( );
  hold ( 'on' );
    plot ( t, y(:,1), 'r-', 'linewidth', 2 );
    plot ( t, y(:,2), 'b-', 'linewidth', 2 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- Time -->' );
  ylabel ( '<-- Solution components -->' );
  title ( 'squircle_ode(): ode45: solution components' );
  legend ( 'y_1', 'y_2' );
  filename = 'squircle_ode45_plot.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
%
%  Phase plot.
%
  figure ( 2 );
  clf ( );
  plot ( y(:,1), y(:,2), 'b-', 'linewidth', 2 );
  grid ( 'on' );
  xlabel ( '<-- y_1 -->' );
  ylabel ( '<-- y_2 -->' );
  title ( 'squircle_ode(): ode45: phase plot' );
  axis ( 'equal' );
  filename = 'squircle_ode45_phase.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
%
%  Plot energy.
%
  h = squircle_conserved ( y );

  figure ( 3 );
  clf ( );
  hold ( 'on' );
    plot ( t, h, 'r-', 'linewidth', 2 );
    plot ( [ t0, tstop ], [ h(1), h(1) ], 'b--', 'linewidth', 2 );
    plot ( [ t0, tstop ], [ 0.0, 0.0 ], 'k-', 'linewidth', 2 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- Time -->' );
  ylabel ( '<-- Energy -->' );
  title ( 'squircle_ode(): ode45: energy' );
  legend ( 'Computed energy', 'Exact energy', 'Zero energy' );
  filename = 'squircle_ode45_conservation.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );

  return
end

