function unstable_backward_euler ( n )

%*****************************************************************************80
%
%% unstable_backward_euler() uses backward_euler() to solve unstable_ode().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 October 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N: the number of steps to take.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'unstable_backward_euler():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Solve unstable_ode() using backward_euler().\n' );

  [ mu, t0, y0, tstop ] = unstable_parameters ( );

  tspan = [ t0, tstop ];

  f = @ unstable_deriv;

  [ t, y ] = backward_euler ( f, tspan, y0, n );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of fixed steps = %d\n', n );
%
%  Y(t), Y'(t)
%
  figure ( 1 );
  plot ( t, y, 'linewidth', 1 );
  grid ( 'on' );
  xlabel ( '<-- T -->', 'Fontsize', 16 );
  ylabel ( '<-- Y(T) -->', 'Fontsize', 16 );
  title ( 'unstable_ode(): backward euler: time plot' );
  legend ( 'Y(t)', 'Y''(t)' );
  filename = 'unstable_backward_euler_plot.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Y(t), Yexact(t)
%
  yexact = unstable_exact ( t );
  figure ( 2 );
  hold ( 'on' );
  plot ( t, y(:,1), 'linewidth', 1 );
  plot ( t, yexact(:,1), 'linewidth', 1 );
  hold ( 'off' )
  grid ( 'on' );
  xlabel ( '<-- T -->', 'Fontsize', 16 );
  ylabel ( '<-- Y(T), Yexact(T) -->', 'Fontsize', 16 );
  title ( 'unstable_ode(): backward euler: comparison' );
  legend ( 'Y(t)', 'Yexact(t)' );
  filename = 'unstable_backward_euler_comparison.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
