function legendre_approximate_humps ( d )

%*****************************************************************************80
%
%% legendre_approximate_humps uses Legendre polynomials to approximate humps().
%
  c = legendre_approximate ( @(x)humps(x), d );

  x = linspace ( -1.0, +1.0, 101 );
  y = legendre_combo_value ( c, x );
  clf ( );
  hold ( 'on' );
  plot ( x, humps(x), 'g-', 'linewidth', 5  );
  plot ( x, y, 'k-', 'linewidth', 2 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- X --->' );
  ylabel ( '<-- Y(X) --->' );
  label = sprintf ( 'Legendre approximant to humps() using degree %d', d );
  title ( label );

  filename = 'legendre_approximate_humps.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

