function quadex_midpoint ( n )

%*****************************************************************************80
%
%% quadex_midpoint applies the midpoint method to the quadex equation.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    03 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N: the number of steps to take.
%
  if ( nargin < 1 )
    n = 25;
  end

  dydt = @ quadex_deriv;
  t0 = 0.0;
  tstop = 2.0;
  tspan = [ t0, tstop ];
  y0 = 2.0 / 25.0;

  [ t1, y1 ] = midpoint ( dydt, tspan, y0, n );

  t2 = linspace ( t0, tstop, 101 );
  y2 = quadex_solution ( t2 );

  plot ( t1, y1, 'r-', t2, y2, 'b-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- t -->' );
  ylabel ( '<-- y(t) -->' );
  s = sprintf ( 'quadex ODE, midpoint method, n = %d', n );
  title ( s );
  legend ( 'Computed', 'Exact', 'Location', 'north' );
  filename = 'quadex_midpoint.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
