8 2 Composite Quadrature Sample Judge Program #include <stdio.h> fclose(outHile); #include <math. h> # include"9811500113.h" double fl( double x) i return(1.0/(1.0+sin(x) *sin(x)));) Sample output double f2( double x) 0.809093 i return(x*log(x));) 0.639900 void main( f FILE* outhile= fopen ("out. txt",w; Int n: double a, b; 0;b=1.0;n=10: fprintf(outfile, %lf\n",CtR(, a, b, fD)) a=1.0;b=20;n=4 fprintf(outfile, %lfn", CTR(n, a, b, f2))
§2 Composite Quadrature Sample Judge Program #include <stdio.h> #include <math.h> #include "98115001_13.h" double f1 ( double x ) { return (1.0/(1.0+sin(x)*sin(x))); } double f2 ( double x ) { return (x*log(x)); } void main( ) { FILE *outfile = fopen("out.txt", "w"); int n; double a, b; a = 0.0; b = 1.0; n = 10; fprintf(outfile, "%lf\n", CTR(n, a, b, f1)); a = 1.0; b = 2.0; n = 4; fprintf(outfile, "%lf\n", CTR(n, a, b, f2)); fclose(outfile); } Sample Output 0.809093 0.639900
§3龙贝格积分 Romberg Integration 例:计算n=J。1 已知对于=10须将区间对分9次,得到T512=314159202 考察,a!由ls41nh=4rn-1r,来计算/效果是否好些? T-T4=3.141592502=S4 Romberg E列 一般有: IT-T =S 42S. =S C-C =C : R 42-1 <E? Romberg S1=T0<<y 算法:④T=r( GS2=T1、N⑥C1=T2 (0) ⑧S4=T ⑩R1=T2
§3 龙贝格积分 /* Romberg Integration */ 例:计算 dx + x = 1 0 1 4 2 已知对于 = 10−6须将区间对分 9 次,得到 T512 = 3.14159202 由 n n T n Tn 来计算 I 效果是否好些? T T I 3 1 3 4 4 1 4 2 2 = − − − 考察 4 1 2 − − n n I T I T 8 4 3 1 3 4 T − T = 3.141592502 = S4 一般有: n n n S T T = − − 4 1 4 2 n n n C S S = − − 4 1 4 2 2 2 n n n R C C = − − 4 1 4 3 2 3 Romberg 序列 ➢ Romberg 算法: < ? < ? < ? … … … … … … T1 = (0) T0 T8 = (3) T0 T4 = (2) T0 T2 = (1) T0 S1 = (0) T1 R1 = (0) T3 S2 = (1) T1 C1 = (0) T2 C2 = (1) S4 = T2 (2) T1