龙贝格算法-实验8-龙贝格算法.pdf
实验八龙贝格算法龙贝格算法代码:代码:#include#include using namespace std;int main()int k=1;double a,b,c,d,h,x,s,T2,S2,C2,R2;coutab;coutendl;coutc;coutendl;h=b-a;if(a=0)T0=(1+sin(b)/b)*h/2;else T0=(sin(a)/a+sin(b)/b)*h/2;loop2:s=0;x=a+h/2;loop1:s=s+sin(x)/x;x+=h;if(xb)goto loop1;T1=T0/2+s*h/2;S1=T1+(T1-T0)/3;if(k=1)else C1=S1+(S1-S0)/15;if(k=2)else R1=C1+(C1-C0)/63;if(k=3)R0=R1;C0=C1;h=h/2;k+;T0=T1;S0=S1;C0=C1;k+;h=h/2;T0=T1;S0=S1;goto loop2;h=h/2;k+;T0=T1;S0=S1;goto loop2;goto loop2;else d=fabs(R1-R0);if(c=d)else cout得出的值是R1 h运行界面运行界面h/2f(a)+f(b)=0=sS+f(x)=sX Th/2=hIt1-t2I T1输出 T2结束