function exp_backward_euler ( n )

%*****************************************************************************80
%
%% exp_backward_euler() uses the backward Euler method on the EXP ODE.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 April 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N: the number of steps to take.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'exp_backward_euler():\n' );
  fprintf ( 1, '  Solve the EXP ODE using the backward Euler method.\n' );

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

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

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

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of equal steps = %d\n', n );

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

  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_exact ( t1 );
  e = rms ( y1 - y2 );
  fprintf ( 1, '  RMS error norm = %g\n', e );

  return
end

