1、数值分析课程的大作业,教材数值分析李乃成.梅立泉clearclcformat longf=input(请输入原函数 f=,s);a=input(积分下限 a=);b=input(积分上限 b=);eps1=input(精度 eps1=);T(1)=double(b-a)/2*(limit(sym(f),findsym(sym(f),a)+limit(sym(f),findsym(sym(f),b);for k=2:4sum1=0;for i=1:2(k-2)sum1=sum1+subs(sym(f),findsym(sym(f),(a+(2*i-1)*(b-a)/2(k-1);end T(k)
2、=1/2*T(k-1)+(b-a)/(2(k-1)*sum1;endfor k=1:3S(k)=T(k+1)+1/(4-1)*(T(k+1)-T(k);endfor k=1:2C(k)=S(k+1)+1/(42-1)*(S(k+1)-S(k);endR(1)=C(2)+1/(43-1)*(C(2)-C(1);k=3;while 1T(1)=T(2);T(2)=T(3);T(3)=T(4);sum2=0;for i=1:2ksum2=sum2+subs(sym(f),findsym(sym(f),(a+(2*i-1)*(b-a)/2(k+1);end T(4)=1/2*T(4)+(b-a)/2(k+1)*sum2;S(1)=S(2);S(2)=S(3);S(3)=T(4)+1/(4-1)*(T(4)-T(3);C(1)=C(2);C(2)=S(3)+1/(42-1)*(S(3)-S(2);R(2)=C(2)+1/(43-1)*(C(2)-C(1);if abs(R(2)-R(1)eps1break;endR(1)=R(2);endvpa(R(2),9)