Skip to content

导数与微分 — 练习

Download exercise.py

实现 central_diff(f, x, h=1e-6)

f(x+h)f(xh)2h

t32t2 处应得到 10(误差小于 106)。不要写成单侧差分,否则过不了断言。

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

源码位置

docs/math/derivative/code/exercise.py