% compute best approximation to some function
% must add Chebfund to path 

 path(path,'C:\Users\bishop\Desktop\Matlab\Chebfun\chebfun');

f=chebfun(@abs,[-1,1],'splitting', 'on');
%f=chebfun('sin(20*x) + cos(10*(1+x).^2)',[-1,1]);
[p,error]=minimax(f,10);
figure; hold on; grid on;
plot(f,'k','LineWidth',2)
plot(p,'r--','LineWidth',2)
plot(f-p,'b:','LineWidth',2)



