function test_interp_fun_test05 ( )

%*****************************************************************************80
%
%% TEST_INTERP_FUN_TEST05 uses linear spline interpolation on all problems.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    24 August 2011
%
%  Author:
%
%    John Burkardt
%
  max_data = 21;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'TEST_INTERP_FUN_TEST05\n' );
  fprintf ( 1, '  Linear spline interpolation.\n' );

  prob_num = p00_prob_num ( );

  for prob = 1 : prob_num

    title = p00_title ( prob );
    [ a, b ] = p00_lim ( prob );

    fprintf ( 1, '\n' );
    fprintf ( 1, '  Problem %d\n', prob );
    fprintf ( 1, '  %s\n', title );
    fprintf ( 1, '\n' );
    fprintf ( 1, '     N   Max ||Error||\n' );
    fprintf ( 1, '\n' );

    for ndata = 2 : 4 : max_data
%
%  Evaluate the function at NDATA equally spaced points.
%
      xdata = zeros ( ndata, 1 );
      ydata = zeros ( ndata, 1 );

      for i = 1 : ndata

        if ( ndata == 1 )
          xdata(i) = 0.5 * ( a + b );
        else
          xdata(i) = ( ( ndata - i     ) * a    ...
                     + (         i - 1 ) * b  ) ...
                     / ( ndata     - 1 );
        end

        ydata(i) = p00_fun ( prob, xdata(i) );

      end
%
%  Evaluate the interpolation function.
%
      error_max = 0.0;
      imax = 100;

      for i = 0 : imax

        if ( imax == 0 )
          xval = 0.5 * ( a + b );
        else
          xval = ( ( imax - i ) * a    ...
                 + (        i ) * b  ) ...
                 / ( imax     );
        end

        [ yval, ypval ] = spline_linear_val ( ndata, xdata, ydata, xval );

        ytrue = p00_fun ( prob, xval );

        error_max = max ( error_max, abs ( yval - ytrue ) );

      end

      fprintf ( 1, '  %4d  %14g\n', ndata, error_max );

    end

  end

  return
end
