function exercise4 ( )

%*****************************************************************************80
%
%% exercise4 does a better job of plotting the results.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    16 July 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'exercise4\n' );
  fprintf ( 1, '  Improved plotting of the solution of a Poisson equation.\n' );
  n = 11;
  a = 0.0;
  b = 5.0;

  [ x, u ] = poisson_solve ( n, a, b,  @f, @g );
  
  x2 = linspace ( a, b, 101 );

  plot ( x, u, 'ro', x2, g(x2), 'b-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- x -->' );
  ylabel ( '<-- u(x) -->' );
  title ( 'Exercise 4: Improved plotting.' );
  legend ( 'Computed', 'Exact' );
  print ( '-dpng', 'exercise4.png' );
  
  return
end

function value = f ( x )

%*****************************************************************************80
%
  value = - ( 2.0 * x + 5.0 ) .* exp ( x );
  return
end

function value = g ( x )

%*****************************************************************************80
%
  value = ( 2.0 * x + 1.0 ) .* exp ( x );
  return
end

