function cubic_spline f = @(x) 1./(1+x.^2); a = linspace(-5,5,1000); b = f(a); error=[]; for n = 2.^(1:15) x = linspace(-5,5,n); y = f(x); c = spline(x,y,a); error=[error,max(abs(b-c))]; end loglog(2.^(1:15),error) grid on