function gear_euler_backward_test ( n )

%*****************************************************************************80
%
%% gear_euler_backward() uses the backward Euler method on gear_ode().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 June 2026
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N: the number of steps to take.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'gear_backward_euler_test():\n' );
  fprintf ( 1, '  Solve gear_ode() using the backward Euler method.\n' );

  [ t0, y0, tstop ] = gear_parameters ( );

  [ t1, y1 ] = gear_euler_backward ( n );

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

  clf ( );
  plot ( t1, y1(:,1), 'r-', ...
         t1, y1(:,2), 'm-', ...
         t2, y2(:,1), 'b--', ...
         t2, y2(:,2), 'c--', 'linewidth', 3 );

  grid ( 'on' );
  xlabel ( '<-- t -->' );
  ylabel ( '<-- y(t) -->' );
  title ( 'gear\_ode(): backward Euler method' );
  legend ( 'Computed y', 'Computed y''', 'Exact y', 'Exact y''' );
  filename = 'gear_euler_backward.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
