clear all m = 8; h=1/m; x=0:h:1; x=x'; y=sin(pi*x); for i=1:m+1, % Form the coefficient matric for j=1:m+1, A(i,j) = x(i)^(j-1); end end [l,u,c,my_det] = my_gauss(m+1,A,y); n = 100; h1 = 1/n; xi=0:h1:1; yi = zeros(n+1,1); for i=1:n+1 % Use the Horner's rule to evaluate the yi(i) = c(m+1); % polynomial. for j=m:-1:1, yi(i) = yi(i)*xi(i) + c(j); end e(i) = yi(i) - sin(pi*xi(i)); % Evaluate the error. end plot(xi,e,'o')