Open in the MATLAB editor: e02ac_example
function e02ac_example fprintf('e02ac example results\n\n'); x = [0:0.05:1]'; y = exp(x); m1 = int64(6); [a, ref] = e02ac(x, y, m1); disp('Polynomial coefficients'); disp(a); fprintf('\nReference deviation = %10.2e\n\n',ref); z = x(1:2:end); pz = polyval(a(end:-1:1),z); expz = exp(z); resz = pz - expz; fprintf(' x Fit exp(x) Residual(*10^-6)\n'); disp([z pz expz resz*10^6]);
e02ac example results Polynomial coefficients 1.0000 1.0001 0.4991 0.1704 0.0348 0.0139 Reference deviation = 1.09e-06 x Fit exp(x) Residual(*10^-6) 0 1.0000 1.0000 -1.0915 0.1000 1.1052 1.1052 0.9740 0.2000 1.2214 1.2214 -0.7439 0.3000 1.3499 1.3499 -0.9175 0.4000 1.4918 1.4918 0.2988 0.5000 1.6487 1.6487 1.0915 0.6000 1.8221 1.8221 0.4586 0.7000 2.0138 2.0138 -0.8163 0.8000 2.2255 2.2255 -0.8419 0.9000 2.4596 2.4596 0.8755 1.0000 2.7183 2.7183 -1.0915