function stiff_rk2_implicit_test ( tspan, y0, n )

%*****************************************************************************80
%
%% stiff_rk2_implicit_test(): solve stiff_ode() using rk2_implicit().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 October 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real TSPAN(2): the first and last times.
%
%    real Y0: the initial condition.
%
%    integer N: the number of steps to take.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'stiff_rk2_implicit_test():\n' );
  fprintf ( 1, '  Solve stiff_ode() using rk2_implicit().\n' );

  f = @ stiff_deriv;
  [ t1, y1 ] = rk2_implicit ( f, tspan, y0, n );

  t2 = linspace ( tspan(1), tspan(2), 101 );
  y2 = stiff_exact ( t2 );

  clf ( );
  plot ( t1, y1, 'ro-', t2, y2, 'b-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- t -->' );
  ylabel ( '<-- y(t) -->' );
  title ( 'rk2\_implicit: Stiff ODE' );
  legend ( 'Computed', 'Exact' );
  filename = 'stiff_rk2_implicit.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

