function sqrty_backward_euler_explicit ( n )

%*****************************************************************************80
%
%% sqrty_backward_euler_explicit applies the backward euler method to the sqrty equation.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    19 October 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N: the number of steps to take.
%
  if ( nargin < 1 )
    n = 25;
  end

  t0 = 0.0;
  y0 = 1.0;
  tstop = 4.0;
  dt = ( tstop - t0 ) / n;

  t1 = zeros ( n + 1, 1 );
  y1 = zeros ( n + 1, 1 );

  t1(1) = t0;
  y1(1) = y0;

  for i = 1 : n
    t1(i+1) = t1(i) + dt;
    y1(i+1) = y1(i) / ( 1.0 + dt * ( 1.0 + 2.0 * t1(i+1) ) );
  end

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

  plot ( t1, y1, 'r-o', t2, y2, 'b-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- t -->' );
  ylabel ( '<-- y(t) -->' );
  s = sprintf ( 'sqrty ODE, backward euler explicit method, n = %d', n );
  title ( s );
  legend ( 'Computed', 'Exact' );
  filename = sprintf ( 'sqrty_backward_euler_explicit_%d.png', n );
  print ( '-dpng', filename );

  return
end
