function showpwl2 ( )

%showpwl2() compares pwLStatic and pwLAdapt on [0,1] using the humps function.
%
%   humps(x) = 1/((x-.3)^2 + .01)  +  1/((x-.9)^2+.04)
%

  fprintf ( 1, '\n' );
  fprintf ( 1, 'showpwl2()\n' );

  close all
  
  % Second derivative estimate based on divided differences
  z = linspace(0,1,101);
  humpvals = humps(z);
  M2 = max(abs(diff(humpvals,2)/(.01)^2));
  
  for delta = [1 .5 .1 .05 .01]
    figure
    [x,y] = pwLStatic('humps',M2,0,1,delta);
    subplot(1,2,1)
    plot(x,y,'.');
    title(sprintf('delta = %8.4f Static  n= %2.0f',delta,length(x)))
    [x,y] = pwLAdapt('humps',0,humps(0),1,humps(1),delta,.001);
    subplot(1,2,2)
    plot(x,y,'.');
    title(sprintf('delta = %8.4f  Adapt n= %2.0f',delta,length(x))) 
    filename = sprintf ( 'showpwl2_%f.png', delta );
    print ( '-dpng', filename );
    fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  end

  return
end

