function exp_backward_euler ( n, tstop )

%*****************************************************************************80
%
%% exp_backward_euler uses the backward Euler method on the EXP ODE.
%
%  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.
%
%    real TSTOP: the final time.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'exp_backward_euler\n' );
  fprintf ( 1, '  Solve the EXP ODE using the backward Euler method.\n' );

  [ alpha, t0, y0 ] = exp_parameters ( );

  f = @ exp_deriv;
  tspan = [ t0, tstop ];

  [ t1, y1 ] = backward_euler ( f, tspan, y0, n );

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

  clf ( );
  plot ( t1, y1, 'r-o', t2, y2, 'b-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- t -->' );
  ylabel ( '<-- y(t) -->' );
  title ( ' EXP ODE, backward_euler method' );
  legend ( 'Computed', 'Exact' );
  filename = 'exp_backward_euler.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  y2 = exp_solution ( t1 );
  e = rms ( y1 - y2 );
  fprintf ( 1, '  RMS error norm = %g\n', e );

  return
end

