function p1_ex3 ( )

%*****************************************************************************80
%
%% P1_EX3 carries out project 1 exercise 3.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    20 February 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'P1_EX3\n' );
  fprintf ( 1, '  Read dataset F.\n' );
  fprintf ( 1, '  Create polynomial models:\n' );
  fprintf ( 1, '  using n from 1 to 12\n' );
%
%  Read data set.
%
  data = load ( 'filip.txt' );
  x = data(:,1);
  y = data(:,2);
  m = length ( x );
%
%  Plot the data.
%
  plot ( x, y, 'bo-', 'linewidth', 3 );
  xlabel ( '<-- X -->' );
  ylabel ( '<-- Y -->' );
  title ( 'The F Dataset', 'fontsize', 16 );
  grid ( 'on' )
  filename = 'p1_ex3_data.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Fill in the table for n = 1 : 12
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  TABLE 3:\n' );
  fprintf ( 1, '   N    rms(r)\n' );
  fprintf ( 1, '\n' );
%
%  Set up the linear system A * c = b for [1,..,x^(n-1)]:
%
  A = [];

  for n = 1 : 12
    A = [ A, x.^(n-1) ];
    b = y;
    c = pinv ( A ) * b;
    r = A * c - b;
    fprintf ( 1, '  %2d  %8.5f\n', n, rms ( r ) );
  end
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'P1_EX3\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end