YYnotesYYNotes

课程回顾与目标Review and Learning Objectives - Note

#课程回顾与目标#数值微分回顾#三点差分法基础#实例练习

笔记:week8Week 8 - Numerical Differentiation and Integration Review and Error Analysis

数值微分与积分的综合复习,重点推导公式、误差估计及外推方法。A thorough review of numerical differentiation and integration focusing on derivations, error formulas, and Romberg extrapolation.

课程回顾与目标

Review and Learning Objectives

  • 本周结合数值微分与积分的核心内容,重点复习三点差分公式、积分近似规则及误差(Error)推导。

  • This week combines core concepts in numerical differentiation and integration with a focus on reviewing three-point difference formulas, quadrature rules, and error analysis.

  • 学习目标包括:

  • Learning objectives include:

  • 利用三个采样点拟合多项式导出均匀与非均匀网格差分公式。

  • Derive difference formulas on uniform and non-uniform grids via polynomial interpolation.

  • 理解梯形法与 Simpson 公式的推导过程及其误差(Error)阶。

  • Understand derivations of trapezoid and Simpson rules along with their error orders.

  • 掌握外推技术(如 Romberg 外推)以提升数值积分(Numerical Integration)精度。

  • Master extrapolation techniques (e.g. Romberg extrapolation) to improve numerical integration accuracy.

  • 分析积分误差(Error)的符号和权重,理解误差(Error)消除原理。

  • Analyze the signs and weights of integration errors, and understand the error cancellation principle.

数值微分回顾

Numerical Differentiation Review

三点差分法基础

Three-Point Differentiation Formulas

给定节点 p,q,rp, q, r 及对应函数值 P,Q,RP, Q, R,通过二次插值

Given nodes p,q,rp,q,r with values P,Q,RP,Q,R, fit quadratic

p2(x)=f[p]+f[p,q](xp)+f[p,q,r](xp)(xq)p_2(x) = f[p] + f[p,q](x-p) + f[p,q,r](x-p)(x-q)

导数近似为

Derivatives approximated by

p2(p),p2(q),p2(r).p_2'(p), \quad p_2'(q), \quad p_2'(r).

均匀网格简化版本:设 xh,x,x+hx-h, x, x+h,则

Uniform grid simplification at xh,x,x+hx-h, x, x+h:

  • 一阶导数中心差分公式
  • First derivative central difference:
f(x)f(x+h)f(xh)2hf'(x) \approx \frac{f(x+h) - f(x-h)}{2h}
  • 二阶导数中心差分公式
  • Second derivative central difference:
f(x)f(x+h)+f(xh)2f(x)h2f''(x) \approx \frac{f(x+h) + f(x-h) - 2 f(x)}{h^2}

实例练习

Example Practice

给定数据点 (1,P),(2,Q),(3,R)(1,P), (2,Q), (3,R),用三点公式估计 f(1),f(2),f(3)f'(1), f'(2), f'(3)

ExampleBlock:

Given points (1,P),(2,Q),(3,R)(1,P), (2,Q), (3,R), estimate f(1),f(2),f(3)f'(1), f'(2), f'(3) using three-point formulas.

数值积分(Numerical Integration)基本方法

Fundamental Numerical Integration Methods

右端点近似法 (REA)

Right-Endpoint Approximation (REA)

区间 [a,b][a,b] 均匀划分 nn 段,步长 h=banh=\frac{b-a}{n},用右端点采样值近似面积:

Partition [a,b][a,b] into nn subintervals each of width h=(ba)/nh = (b-a)/n, approximate area by right endpoints:

REA(f,[a,b],n)=hi=1nf(xi)\mathrm{REA}(f,[a,b],n) = h \sum_{i=1}^n f(x_i)

梯形法

Trapezoid Rule

复化梯形公式(Trapezoidal Rule)权重在内点翻倍,公式为:

Tn=h[12f(x0)+i=1n1f(xi)+12f(xn)]T_n = h \left[ \frac{1}{2} f(x_0) + \sum_{i=1}^{n-1} f(x_i) + \frac{1}{2} f(x_n) \right]

Simpson 1/31/3

Composite Simpson 1/31/3 Rule

nn 为偶数时,采样点分为奇数和偶数索引点,权重结构为:

Sn=h3[f(x0)+4i oddf(xi)+2i even0<i<nf(xi)+f(xn)]S_n = \frac{h}{3} \left[ f(x_0) + 4 \sum_{\substack{i \text{ odd}}} f(x_i) + 2 \sum_{\substack{ i \text{ even} \\ 0 < i < n }} f(x_i) + f(x_n) \right]

Simpson 单区间权重

Simpson Single Panel Weights

单面板 Simpson 3/83/8 法权重比例为 (1,3,3,1)(1,3,3,1)


积分误差(Error)分析

Integration Error Analysis

Taylor 展开与误差(Error)

Taylor Expansion and Error Order

以函数在点 00 处展开:

f(x)=a+bx+cx2+dx3+ex4+f(x) = a + bx + cx^2 + dx^3 + ex^4 + \cdots

积分区间取对称区间 [h,h][-h,h],真积分值计算为:

AUC(f,[h,h])=hhf(x)dx=2ha+2h33c+2h55e+\mathrm{AUC}(f,[-h,h]) = \int_{-h}^h f(x) \, dx = 2h a + \frac{2h^3}{3} c + \frac{2 h^5}{5} e + \cdots

Simpson 近似权重为 ww,样本分别在 h,0,h-h,0,h,权重向量为 (w,12w,w)(w, 1-2w, w),有:

ApproxArea=2h[wf(h)+(12w)f(0)+wf(h)]\mathrm{ApproxArea} = 2h \left[ w f(-h) + (1-2w) f(0) + w f(h) \right]

Simpson 局部误差(Error)

Local Error of Simpson Rule

优化 ww 使得二次项误差(Error)补偿,得 w=16w = \frac{1}{6},权重即为 Simpson 的 (1,4,1)/6(1,4,1)/6

局部误差(Error)项主导为:

ESimpsonh5f(4)(ξ)E_\text{Simpson} \propto h^5 f^{(4)}(\xi)

即 Simpson 公式具有五阶局部误差(整体四阶精度)。

梯形法与中点法误差(Error)符号互异

Opposite Signs of Trapezoid and Midpoint Errors

  • 梯形法误差(Error)为:

    ET=2h[23ch2+45eh4+]E_T = 2h \left[ \frac{2}{3} c h^2 + \frac{4}{5} e h^4 + \cdots \right]
  • 中点法误差(Error)为:

    EM=2h[13ch215eh4+]E_M = 2h \left[ -\frac{1}{3} c h^2 - \frac{1}{5} e h^4 + \cdots \right]

符号相反,利用这一对立可以进行误差(Error)消除。

The errors have opposite signs enabling weighted error cancellation.

Simpson 公式为梯形与中点混合

Simpson as a Mixture of Trapezoid and Midpoint Rules

选择混合参数 λ\lambda 使得 O(h3)O(h^3) 主导误差(Error)消除,即

λET+(1λ)EM=0    λ=23\lambda E_T + (1-\lambda) E_M = 0 \implies \lambda = \frac{2}{3}

由此得到 Simpson 权重为:

(1/6,4/6,1/6)(1/6, 4/6, 1/6)

Romberg 外推方法

Romberg Extrapolation

粗细网格积分近似

Coarse-Fine Grid Approximations

IhI_hIh/2I_{h/2} 分别为步长为 hhh/2h/2 的积分近似:

Ih=I+Khp+,Ih/2=I+K(h2)p+I_h = I + K h^p + \cdots, \quad I_{h/2} = I + K \left(\frac{h}{2}\right)^p + \cdots

通过线性组合消除主误差(Error)KhpK h^p,得更高阶近似:

Iextrap=2pIh/2Ih2p1I_\text{extrap} = \frac{2^p I_{h/2} - I_h}{2^p -1}

这是 Romberg 外推的核心思想。

五点 Newton-Cotes 权重通过混合获得

Five-Point Newton-Cotes Weights by Error-Weight Plot

利用粗网格和细网格的加权和,解误差(Error)线性方程获得五点权重:

Weimix=190(7,32,12,32,7)\text{Wei}_\text{mix} = \frac{1}{90} (7, 32, 12, 32, 7)

对应 Simpson 3/83/8 相关较高阶的 Newton-Cotes 配置。


总结

Summary

  • 三点差分法为数值微分提供方便的多点插值模板,均匀网格下有简洁公式。
  • 右端点法、梯形法与 Simpson 法为常用的数值积分(Numerical Integration)方法,权重设计决定精度与误差(Error)结构。
  • Simpson 公式等价于梯形与中点法的误差(Error)消除型加权组合,达到更高的局部误差(Error)阶。
  • Romberg 外推通过多尺度积分估计线性组合,实现误差(Error)高阶抵消与数值精度提升。

练习题

Practice Questions

<PracticeQuestionBlock>
  1. 给定函数 f(x)f(x)x=1,2,3x=1,2,3 处的值为 P,Q,RP, Q, R,计算利用三点差分法估计 f(2)f'(2)
  • Given f(x)f(x) values P,Q,RP, Q, R at x=1,2,3x=1,2,3, compute the estimate for f(2)f'(2) using three-point formula.
  1. 通过右端点近似法计算 f(x)=x2f(x) = x^2[0,1][0,1] 区间上分成 n=2n=2 段的积分近似值,并与精确积分比较。
  • Use the right-endpoint approximation to estimate the integral of f(x)=x2f(x) = x^2 on [0,1][0,1] with n=2n=2 subintervals and compare with the exact value.
  1. 推导梯形法在区间 [h,h][-h,h] 上积分误差(Error)的主导项。
  • Derive the leading error term of the trapezoid rule approximating the integral over [h,h][-h, h].
  1. 证明 Simpson 公式的近似误差(Error)为局部 O(h5)O(h^5),整体为 O(h4)O(h^4)
  • Prove that Simpson's rule has local error order O(h5)O(h^5) and global error order O(h4)O(h^4).
  1. 利用 Romberg 外推法给出 IhI_hIh/2I_{h/2},组成更高阶积分近似公式。
  • Using Romberg extrapolation, given integrals IhI_h and Ih/2I_{h/2} compute a higher-order accurate integral estimate.
</PracticeQuestionBlock>