Returns the quotient and remainder of polynomial division. .. note:: This forms part of the old polynomial API. Since version 1.4, the new polynomial API defined in `numpy.polynomial` is preferred. A summary of the differences can be found in the :doc:`transitio
(u, v)
| 990 | |
| 991 | @array_function_dispatch(_polydiv_dispatcher) |
| 992 | def polydiv(u, v): |
| 993 | """ |
| 994 | Returns the quotient and remainder of polynomial division. |
| 995 | |
| 996 | .. note:: |
| 997 | This forms part of the old polynomial API. Since version 1.4, the |
| 998 | new polynomial API defined in `numpy.polynomial` is preferred. |
| 999 | A summary of the differences can be found in the |
| 1000 | :doc:`transition guide </reference/routines.polynomials>`. |
| 1001 | |
| 1002 | The input arrays are the coefficients (including any coefficients |
| 1003 | equal to zero) of the "numerator" (dividend) and "denominator" |
| 1004 | (divisor) polynomials, respectively. |
| 1005 | |
| 1006 | Parameters |
| 1007 | ---------- |
| 1008 | u : array_like or poly1d |
| 1009 | Dividend polynomial's coefficients. |
| 1010 | |
| 1011 | v : array_like or poly1d |
| 1012 | Divisor polynomial's coefficients. |
| 1013 | |
| 1014 | Returns |
| 1015 | ------- |
| 1016 | q : ndarray |
| 1017 | Coefficients, including those equal to zero, of the quotient. |
| 1018 | r : ndarray |
| 1019 | Coefficients, including those equal to zero, of the remainder. |
| 1020 | |
| 1021 | See Also |
| 1022 | -------- |
| 1023 | poly, polyadd, polyder, polydiv, polyfit, polyint, polymul, polysub |
| 1024 | polyval |
| 1025 | |
| 1026 | Notes |
| 1027 | ----- |
| 1028 | Both `u` and `v` must be 0-d or 1-d (ndim = 0 or 1), but `u.ndim` need |
| 1029 | not equal `v.ndim`. In other words, all four possible combinations - |
| 1030 | ``u.ndim = v.ndim = 0``, ``u.ndim = v.ndim = 1``, |
| 1031 | ``u.ndim = 1, v.ndim = 0``, and ``u.ndim = 0, v.ndim = 1`` - work. |
| 1032 | |
| 1033 | Examples |
| 1034 | -------- |
| 1035 | |
| 1036 | .. math:: \\frac{3x^2 + 5x + 2}{2x + 1} = 1.5x + 1.75, remainder 0.25 |
| 1037 | |
| 1038 | >>> import numpy as np |
| 1039 | |
| 1040 | >>> x = np.array([3.0, 5.0, 2.0]) |
| 1041 | >>> y = np.array([2.0, 1.0]) |
| 1042 | >>> np.polydiv(x, y) |
| 1043 | (array([1.5 , 1.75]), array([0.25])) |
| 1044 | |
| 1045 | """ |
| 1046 | truepoly = (isinstance(u, poly1d) or isinstance(v, poly1d)) |
| 1047 | u = atleast_1d(u) + 0.0 |
| 1048 | v = atleast_1d(v) + 0.0 |
| 1049 | # w has the common type |
no test coverage detected
searching dependent graphs…