numpy.polyadd#
- numpy.polyadd(a1, a2)[原始碼]#
Find the sum of two polynomials.
備註
這是舊版多項式 API 的一部分。自 1.4 版本起,建議使用
numpy.polynomial中定義的新版多項式 API。有關差異的概述,請參閱 transition guide。Returns the polynomial resulting from the sum of two input polynomials. Each input must be either a poly1d object or a 1D sequence of polynomial coefficients, from highest to lowest degree.
- 參數:
- a1, a2類別數組物件或一維多對象
Input polynomials.
- 回傳值:
- outndarray or poly1d object
The sum of the inputs. If either input is a poly1d object, then the output is also a poly1d object. Otherwise, it is a 1D array of polynomial coefficients from highest to lowest degree.
也參考
範例
>>> import numpy as np >>> np.polyadd([1, 2], [9, 5, 4]) array([9, 6, 6])
Using poly1d objects:
>>> p1 = np.poly1d([1, 2]) >>> p2 = np.poly1d([9, 5, 4]) >>> print(p1) 1 x + 2 >>> print(p2) 2 9 x + 5 x + 4 >>> print(np.polyadd(p1, p2)) 2 9 x + 6 x + 6