第五章数值积分与微分.pptVIP

  • 5
  • 0
  • 约5.77千字
  • 约 53页
  • 2018-06-27 发布于湖北
  • 举报
第五章数值积分与微分

求积公式的余项比较 我们知道,两个求积公式的余项分别为 单纯的求积公式 复化求积公式 复化求积公式精度提高。 §2 Composite Quadrature Lab 13. Composite Trapezoidal Rule Use the Composite Trapezoidal rule with a given n 0 to approximate a given integral . You are supposed to write a function double CTR ( int n, double a, double b, double (*f)( ) ) to approximate the integral from a to b of the function f using the trapezoidal rule on n equal-length subintervals. Input There is no input file. Instead, you must hand in your function in a *.h file. The rule of naming the *.h file is the same as that of naming the *.c or *.cpp files. Output For each test case, you are supposed to return the approximation of the integral. Sample Judge Program #include stdio.h #include math.h #include13.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 比较两种复合公式的的余项 为此介绍收敛阶的概念! 定义1. 不难知道,复合梯形、Simpson公式的收敛阶分别为 2阶、4阶 复化求积法通过将积分区间分成n等份,来减小截断误差,因此n越大积分精度越高。但n太大,运算量也增大,舍入误差也增大;n太小,精度可能达不到。如何确定适当的,使得计算结果达到预选给定的精度要求呢? 在实际计算中,常采用积分步长的自动选择。具体地讲,就是在求积过程中,将步长逐次折半,反复利用复合求积公式,直到相邻两次的计算结果之差的绝对值小于允许误差为止。这实际上是一种事后估计误差的方法——变步长求积算法。 §5.3 变步长求积和龙贝格算法 问题 综合前几节的内容,我们知道 梯形公式,Simpson公式,Cotes公式的代数精度分别为 1次,3次和5次 复化梯形、复化Simpson、复化Cotes公式的收敛阶分别为 2阶、4阶和6阶 5.3.1 变步长梯形求积法 对于复合梯形公式,若将积分区间[a,b]n等分,积分近似值记为Tn ,积分精确值记为I ,则有: 把每个子区间分半,也就是将积分区间[a,b] 2n等分,则有 则有 当 在连续,且函数值变化不大时,即有 给定求积精度?,如何取n ? 可用来判断迭代 是否停止。 变步长梯形法计算过程 ⑴ ⑵ ⑶ 可以看到,每次都是在前一次的基础上将子区间再对分。原分点上的函数值不需要重复计算,只需计算新分点上的函数值即可,一般地计算公式为: 由上节变步长梯形公式得到的积分近似值的误差大致是 ,因此人们期望, 如果用这个误差作为对 的一种补偿,则得到的求积公式的代数精度会有

文档评论(0)

1亿VIP精品文档

相关文档