%% use symbolic expression syms x %% output data in long format , namely, show more digits format long %% specify the function y = cos(x); %% plot function y on [0, 2*pi] ezplot(y, [0, 2*pi]); %% get the 3rd Taylor polynomial P3 = taylor(y,4) %% evaluate P3 at x = 0.01 subs(P3,x,0.01); %% integrate P3 int_P3 = int(P3) %% evaluate definite the integral of P3 on [0, 0.01] i1 = eval(int(P3, x, 0, 0.1)) i2 = eval(int(y, x, 0, 0.1)) %% determine the error err = abs(i1-i2) %subs(int_P3, 0.01) - subs(int_P3, 0.0) %cos(0.01)