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