Skip to content

积分与基本定理 — 练习 ​

Download exercise.py

实现 trapezoid(f, a, b, n)。h=(b−a)/n,两端一半、中间全要。直线 2x+1 在 [0,2] 上应精确得到 6(梯形对线性函数没有截断误差)。x2 在 [0,1]、n=64 应靠近 1/3。

bash
cd docs/math/integral/code
python exercise.py

源码位置 ​

docs/math/integral/code/exercise.py