function hw1 ( )

%*****************************************************************************80
%
%% hw1 sets up and solves a Poisson equation over an interval.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    16 July 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'hw1:\n' );
  fprintf ( 1, '  Set up and solve a Poisson equation over an interval.\n' );

  n = 21;
  a = 0.0;
  b = 0.5;

  [ x, u ] = poisson2_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 ( 'hw1: solving -u''''+u=f(x)' );
  legend ( 'Computed', 'Exact' );
  print ( '-dpng', 'hw1.png' );
  
  return
end

function value = f ( x )

%*****************************************************************************80
%
  value = - 4.0 .* exp ( x );
  return
end

function value = g ( x )

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

