Python求导数

利用Python求导数

scipy.misc.derivative

scipy.misc.derivative(func, x0, dx=1.0, n=1, args=(), order=3)

Parameters:

  • func: function
    • Input function.
    • (被求导函数)
  • x0: float
    • The point at which n-th derivative is found.
    • (求导点)
  • dx: float, optional(float类型数据,可选参数)
    • Spacing.
  • n: int, optional
    • Order of the derivative. Default is 1.
    • (函数阶次,即求几阶导函数,默认是1)
  • args: tuple, optional
    • Arguments
  • order: int, optional
    • Number of points to use, must be odd.

程序代码

>>> from scipy.misc import derivative
>>> def f(x):
...     return x**3 + x**2
>>> derivative(f, 1.0, dx=1e-6)
4.9999999999217337

参考链接:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.misc.derivative.html

你可能感兴趣的:(Python,python)