% FOO Compare interpolation of a bad function.
% Requires: JAGGED

xx=0:.0001:1;  yy=jagged(xx,10,4,1.2);
plot(xx,yy)                      % f(x)
hold on
x=0:.05:1;  y=jagged(x,10,4,1.2);
plot(x,y,'r')                    % piecewise-linear  l(x)
p = polyfit(x,y,20);
plot(xx,polyval(p,xx),'g')       % deg 20 polynomial  p(x)
plot(xx,spline(x,y,xx),'c')      % cubic spline  s(x)
hold off
axis([0 1 0 1])
print -dpdf foo.pdf

