numpy.polyder#
- numpy.polyder(p, m=1)[原始碼]#
Return the derivative of the specified order of a polynomial.
備註
這是舊版多項式 API 的一部分。自 1.4 版本起,建議使用
numpy.polynomial中定義的新版多項式 API。有關差異的概述,請參閱 transition guide。- 參數:
- ppoly1d or sequence
Polynomial to differentiate. A sequence is interpreted as polynomial coefficients, see
poly1d.- mint, optional
Order of differentiation (default: 1)
- 回傳值:
- derpoly1d
A new polynomial representing the derivative.
範例
The derivative of the polynomial \(x^3 + x^2 + x^1 + 1\) is:
>>> import numpy as np
>>> p = np.poly1d([1,1,1,1]) >>> p2 = np.polyder(p) >>> p2 poly1d([3, 2, 1])
which evaluates to:
>>> p2(2.) 17.0
We can verify this, approximating the derivative with
(f(x + h) - f(x))/h:>>> (p(2. + 0.001) - p(2.)) / 0.001 17.007000999997857
The fourth-order derivative of a 3rd-order polynomial is zero:
>>> np.polyder(p, 2) poly1d([6, 2]) >>> np.polyder(p, 3) poly1d([6]) >>> np.polyder(p, 4) poly1d([0])