function exercise3 ( )

%*****************************************************************************80
%
%% exercise3 sets up and solves a Poisson problem using poisson_solve().
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    16 July 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'exercise3:\n' );
  fprintf ( 1, '  Use poisson_solve() to solve a 1D 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, x2, g(x2) );
  print ( '-dpng', 'exercise3.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

