numpy.polydiv#
- numpy.polydiv(u, v)[原始碼]#
Returns the quotient and remainder of polynomial division.
備註
這是舊版多項式 API 的一部分。自 1.4 版本起,建議使用
numpy.polynomial中定義的新版多項式 API。有關差異的概述,請參閱 transition guide。The input arrays are the coefficients (including any coefficients equal to zero) of the 「numerator」 (dividend) and 「denominator」 (divisor) polynomials, respectively.
- 參數:
- uarray_like or poly1d
Dividend polynomial’s coefficients.
- varray_like or poly1d
Divisor polynomial’s coefficients.
- 回傳值:
- qndarray
Coefficients, including those equal to zero, of the quotient.
- rndarray
Coefficients, including those equal to zero, of the remainder.
Notes
Both u and v must be 0-d or 1-d (ndim = 0 or 1), but u.ndim need not equal v.ndim. In other words, all four possible combinations -
u.ndim = v.ndim = 0,u.ndim = v.ndim = 1,u.ndim = 1, v.ndim = 0, andu.ndim = 0, v.ndim = 1- work.範例
\[\frac{3x^2 + 5x + 2}{2x + 1} = 1.5x + 1.75, remainder 0.25\]>>> import numpy as np
>>> x = np.array([3.0, 5.0, 2.0]) >>> y = np.array([2.0, 1.0]) >>> np.polydiv(x, y) (array([1.5 , 1.75]), array([0.25]))