Usage example for gauss_lobatto_rule related to Exercies 5.3
0001 % Usage example for gauss_lobatto_rule 0002 % related to Exercies 5.3 0003 0004 a = -1; 0005 b= 1; 0006 E = zeros(10,4); 0007 for n=2:5 0008 for j = 1:10 0009 syms x; 0010 f = x^j; 0011 I = int(f,x,a,b); % true value of the integral 0012 f = matlabFunction(f); 0013 [ Q ] = gauss_lobatto_rule( f,a,b,n ); % approximation of the integral 0014 E(j,n-1) = Q-I; 0015 end 0016 end 0017 disp('The difference between the Gauss-Lobatto rule (n=2,3,4,5) and the true value integrating x^j, j=1,...10 is'); 0018 format shortE; 0019 E