function test2 ( )

%*****************************************************************************80
%
%% test2() is the main program for problem 2.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    16 May 2009
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'TEST2\n' );
  fprintf ( 1, '  MATLAB version\n' );
  fprintf ( 1, '  A test problem for FD1D_HEAT_STEADY.\n' );
  fprintf ( 1, '  Low K, high K, moderate K.\n' );

  n = 11;

  a = 0.0;
  b = 1.0;

  ua = 0.0;
  ub = 1.0;

  [ x, u ] = fd1d_heat_steady ( n, a, b, ua, ub, @k2, @f2 );

  plot ( x, u );
  title ( 'Problem 2: low K, high K, moderate K' );
  xlabel ( 'X' );
  ylabel ( 'Temperature' );

  filename = 'test2_nodes.txt';
  r8mat_write ( filename, 1, n, x );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  X data written to "%s".\n', filename );
  filename = 'test2_values.txt';
  r8mat_write ( filename, 1, n, u' );
  fprintf ( 1, '  U data written to "%s".\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'TEST2\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end
function value = k2 ( x )

%*****************************************************************************80
%
%% k2() evaluates the heat transfer coefficient K(X).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    16 May 2009
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real X, the position.
%
%  Output:
%
%    real VALUE, the value of K(X).
%
  if ( x < 0.50 )
    value = 0.25;
  elseif ( x < 0.75 )
    value = 4.0;
  else
    value = 1.0;
  end

  return
end
function value = f2 ( x )

%*****************************************************************************80
%
%% f2() evaluates the right hand side function F(X).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    16 May 2009
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real X, the position.
%
%  Output:
%
%    real VALUE, the value of F(X).
%
  value = 0.0;

  return
end

