poly
Return polynomial coefficients given a sequence of roots. The returned array represents coefficients in descending degree order, with a leading coefficient of 1.| Name | Type | Default | Description |
|---|---|---|---|
seq_of_zeros | ArrayLike | — | Array of polynomial roots. |
NDArray — 1-D array of polynomial coefficients, highest degree first.
polyadd
Add two polynomials. Inputs are coefficient arrays in descending degree order. The result is trimmed of leading zeros.| Name | Type | Default | Description |
|---|---|---|---|
a1 | ArrayLike | — | Coefficients of the first polynomial. |
a2 | ArrayLike | — | Coefficients of the second polynomial. |
NDArray — Coefficients of the sum polynomial.
polyder
Differentiate a polynomial one or more times. Coefficients are in descending degree order.| Name | Type | Default | Description |
|---|---|---|---|
p | ArrayLike | — | Polynomial coefficients (highest degree first). |
m | number | 1 | Number of times to differentiate. |
NDArray — Coefficients of the m-th derivative.
polydiv
Divide one polynomial by another. Returns quotient and remainder as a tuple.| Name | Type | Default | Description |
|---|---|---|---|
u | ArrayLike | — | Dividend polynomial coefficients. |
v | ArrayLike | — | Divisor polynomial coefficients. |
[NDArray, NDArray] — Tuple of [quotient, remainder] coefficient arrays.
Throws: Error if the divisor is the zero polynomial.
polyfit
Least-squares polynomial fit of degreedeg to data points (x, y). Returns coefficients in descending degree order.
| Name | Type | Default | Description |
|---|---|---|---|
x | ArrayLike | — | x-coordinates of the sample points. |
y | ArrayLike | — | y-coordinates of the sample points. |
deg | number | — | Degree of the fitting polynomial. Must be less than the number of data points. |
NDArray — Polynomial coefficients, highest degree first.
Throws: Error if deg >= len(x).
polyint
Integrate a polynomial one or more times. Optionally specify integration constants.| Name | Type | Default | Description |
|---|---|---|---|
p | ArrayLike | — | Polynomial coefficients (highest degree first). |
m | number | 1 | Number of times to integrate. |
k | number | number[] | 0 | Integration constant(s). A single number applies to all integrations; an array specifies the constant for each successive integration. |
NDArray — Coefficients of the integrated polynomial.
polymul
Multiply two polynomials. Equivalent to convolving their coefficient arrays.| Name | Type | Default | Description |
|---|---|---|---|
a1 | ArrayLike | — | Coefficients of the first polynomial. |
a2 | ArrayLike | — | Coefficients of the second polynomial. |
NDArray — Coefficients of the product polynomial.
polysub
Subtract two polynomials. Result is trimmed of leading zeros.| Name | Type | Default | Description |
|---|---|---|---|
a1 | ArrayLike | — | Coefficients of the first polynomial. |
a2 | ArrayLike | — | Coefficients of the second polynomial. |
NDArray — Coefficients of the difference a1 - a2.
polyval
Evaluate a polynomial at one or more points using Horner’s method.| Name | Type | Default | Description |
|---|---|---|---|
p | ArrayLike | — | Polynomial coefficients (highest degree first). |
x | ArrayLike | — | Points at which to evaluate the polynomial. Can be a single number. |
NDArray | number — Scalar if x is a single number, otherwise an NDArray of evaluated values.
roots
Find the roots of a polynomial with given coefficients. Uses the companion matrix eigenvalue method, the same algorithm used by NumPy.| Name | Type | Default | Description |
|---|---|---|---|
p | ArrayLike | — | Polynomial coefficients (highest degree first). Leading zeros are stripped. |
NDArray — 1-D complex128 array of roots, sorted by descending magnitude.