scipy.misc.
derivative#
- scipy.misc.derivative(func, x0, dx=1.0, n=1, args=(), order=3)[原始碼]#
求函數在某一點的 n 階導數。
給定一個函數,使用間距為 *dx* 的中央差分公式計算在 *x0* 的 n 階導數。
自版本 1.10.0 起已棄用:
derivative
已於 SciPy 1.10.0 中從scipy.misc.derivative
棄用,並將在 SciPy 1.12.0 中完全移除。您可以考慮使用 findiff:maroba/findiff 或 numdifftools:pbrod/numdifftools- 參數:
- func函數
輸入函數。
- x0浮點數
求 n 階導數的點。
- dx浮點數,可選
間距。
- n整數,可選
導數的階數。預設為 1。
- args元組,可選
引數
- order整數,可選
使用的點數,必須為奇數。
注意事項
將步長設定得太小可能會導致捨入誤差。
範例
>>> from scipy.misc import derivative >>> def f(x): ... return x**3 + x**2 >>> derivative(f, 1.0, dx=1e-6) 4.9999999999217337