function err=Q5_2(n) %Simpson %Input data a = 0 ; b = 2^(-1/4); N = 2^n; h = (b-a)/N; x = a:h:b; f = (1-x.^4).^(1/4); %weight=(1,4,2,4,2,...,4,2,4,1) w(1:N+1)=2; for j = 1:N/2 w(2*j) = w(2*j)*2; end w(1) = w(N+1) = 1; %Sum s = (h/3)*w*f'; %error exact = 0.8170720599186167; err = abs(exact-s); end %for n=2:12 % Q5_2(n)/Q5_2(n+1) %= 10.1885680322002 %= 12.9009191320832 %= 14.8014553713465 %= 15.6396885314473 %= 15.9044314400104 %= 15.9756212751602 %= 15.9923032657172 %= 16.0531177829099 %= 14.8034188034188 %= 6.15789473684211 %= 1.05555555555556 %error = O(h^4)? %If we integrate from 0 to 1 directly, then the result of error will be: %= 2.38678254209964 %= 2.38247034429886 %= 2.38041786545756 %= 2.37941109208488 %= 2.37891157182918 %= 2.37866264766391 %= 2.37853837793067 %= 2.37847628899956 %= 2.37844525591952 %= 2.37842974238546 %= 2.37842198349467 %The order is lost.