
    Kh                        S r / SQrSSKrSSKrSSKrSSKJr  SSKJs  J	r
  SSKJrJrJrJrJrJrJrJr  SSKJr  SSKJr  SS	KJrJr  SS
KJr  SSKJrJrJrJ r   SSK!J"r"J#r#J$r$  \RJ                  " \RL                  SS9r&S r'\&" \'5      S 5       r(S r)\&" \)5      S 5       r*S&S jr+\&" \+5      S'S j5       r,S(S jr-\&" \-5      S)S j5       r.S*S jr/\&" \/5      S+S j5       r0S r1\&" \15      S 5       r2S r3\&" \35      S 5       r4\&" \35      S 5       r5\&" \35      S 5       r6S r7\&" \75      S  5       r8\Rr                  " S!5      r:S,S" jr;\" S5       " S# S$5      5       r<\Rz                  " S%\5        g)-z'
Functions to operate on polynomials.

)polyrootspolyintpolyderpolyaddpolysubpolymulpolydivpolyvalpoly1dpolyfit    N   )
set_module)isscalarabsfinfo
atleast_1dhstackdotarrayones)	overrides)RankWarning)diagvander)
trim_zeros)	iscomplexrealimagmintypecode)eigvalslstsqinvnumpy)modulec                     U $ N )seq_of_zeross    L/var/www/html/env/lib/python3.13/site-packages/numpy/lib/_polynomial_impl.py_poly_dispatcherr+      s        c           	      V   [        U 5      n U R                  n[        U5      S:X  a!  US   US   :X  a  US   S:w  a  [        U 5      n OU[        U5      S:X  a;  U R                  nU[
        :w  a$  U R                  [        UR                  5      5      n O[        S5      e[        U 5      S:X  a  gU R                  n[        SUS9nU  H$  n[        R                  " U[        SU* /US9SS	9nM&     [        UR                  R                  [        R                   5      (       a  [        R"                  " U [$        5      n[        R&                  " [        R(                  " U5      [        R(                  " UR+                  5       5      :H  5      (       a  UR,                  R/                  5       nU$ )
a(  
Find the coefficients of a polynomial with the given sequence of roots.

.. 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:`transition guide </reference/routines.polynomials>`.

Returns the coefficients of the polynomial whose leading coefficient
is one for the given sequence of zeros (multiple roots must be included
in the sequence as many times as their multiplicity; see Examples).
A square matrix (or array, which will be treated as a matrix) can also
be given, in which case the coefficients of the characteristic polynomial
of the matrix are returned.

Parameters
----------
seq_of_zeros : array_like, shape (N,) or (N, N)
    A sequence of polynomial roots, or a square array or matrix object.

Returns
-------
c : ndarray
    1D array of polynomial coefficients from highest to lowest degree:

    ``c[0] * x**(N) + c[1] * x**(N-1) + ... + c[N-1] * x + c[N]``
    where c[0] always equals 1.

Raises
------
ValueError
    If input is the wrong shape (the input must be a 1-D or square
    2-D array).

See Also
--------
polyval : Compute polynomial values.
roots : Return the roots of a polynomial.
polyfit : Least squares polynomial fit.
poly1d : A one-dimensional polynomial class.

Notes
-----
Specifying the roots of a polynomial still leaves one degree of
freedom, typically represented by an undetermined leading
coefficient. [1]_ In the case of this function, that coefficient -
the first one in the returned array - is always taken as one. (If
for some reason you have one other point, the only automatic way
presently to leverage that information is to use ``polyfit``.)

The characteristic polynomial, :math:`p_a(t)`, of an `n`-by-`n`
matrix **A** is given by

:math:`p_a(t) = \mathrm{det}(t\, \mathbf{I} - \mathbf{A})`,

where **I** is the `n`-by-`n` identity matrix. [2]_

References
----------
.. [1] M. Sullivan and M. Sullivan, III, "Algebra and Trigonometry,
   Enhanced With Graphing Utilities," Prentice-Hall, pg. 318, 1996.

.. [2] G. Strang, "Linear Algebra and Its Applications, 2nd Edition,"
   Academic Press, pg. 182, 1980.

Examples
--------
Given a sequence of a polynomial's zeros:

>>> import numpy as np

>>> np.poly((0, 0, 0)) # Multiple root example
array([1., 0., 0., 0.])

The line above represents z**3 + 0*z**2 + 0*z + 0.

>>> np.poly((-1./2, 0, 1./2))
array([ 1.  ,  0.  , -0.25,  0.  ])

The line above represents z**3 - z/4

>>> np.poly((np.random.random(1)[0], 0, np.random.random(1)[0]))
array([ 1.        , -0.77086955,  0.08618131,  0.        ]) # random

Given a square array object:

>>> P = np.array([[0, 1./3], [-1./2, 0]])
>>> np.poly(P)
array([1.        , 0.        , 0.16666667])

Note how in all cases the leading coefficient is always 1.

r   r      z.input must be 1d or non-empty square 2d array.      ?r.   dtypefull)mode)r   shapelenr!   r2   objectastyper    char
ValueErrorr   NXconvolver   
issubclasstypecomplexfloatingasarraycomplexallsort	conjugater   copy)r)   shdtazeror   s         r*   r   r   "   sG   @ l+L			B
2w!|1A2a5A:|,	RA<'..{277/CDLIJJ
<A			BTAKK5!dU26VD  !'',, 2 233

<166"''%.BGGEOO,=$>>??AHr,   c                     U $ r'   r(   )ps    r*   _roots_dispatcherrL      s    Hr,   c                 N   [        U 5      n U R                  S:w  a  [        S5      e[        R                  " [        R
                  " U 5      5      S   n[        U5      S:X  a  [        R                  " / 5      $ [        U 5      US   -
  S-
  nU [        US   5      [        US   5      S-    n [        U R                  R                  [        R                  [        R                  45      (       d  U R                  [        5      n [        U 5      nUS:  aN  [!        [        R"                  " US-
  4U R                  5      S5      nU SS * U S   -  USSS24'   [%        U5      nO[        R                  " / 5      n['        U[        R(                  " X%R                  5      45      nU$ )aO  
Return the roots of a polynomial with coefficients given in p.

.. 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:`transition guide </reference/routines.polynomials>`.

The values in the rank-1 array `p` are coefficients of a polynomial.
If the length of `p` is n+1 then the polynomial is described by::

  p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]

Parameters
----------
p : array_like
    Rank-1 array of polynomial coefficients.

Returns
-------
out : ndarray
    An array containing the roots of the polynomial.

Raises
------
ValueError
    When `p` cannot be converted to a rank-1 array.

See also
--------
poly : Find the coefficients of a polynomial with a given sequence
       of roots.
polyval : Compute polynomial values.
polyfit : Least squares polynomial fit.
poly1d : A one-dimensional polynomial class.

Notes
-----
The algorithm relies on computing the eigenvalues of the
companion matrix [1]_.

References
----------
.. [1] R. A. Horn & C. R. Johnson, *Matrix Analysis*.  Cambridge, UK:
    Cambridge University Press, 1999, pp. 146-7.

Examples
--------
>>> import numpy as np
>>> coeff = [3.2, 2, 1]
>>> np.roots(coeff)
array([-0.3125+0.46351241j, -0.3125-0.46351241j])

r.   zInput must be a rank-1 array.r   r   N)r   ndimr:   r;   nonzeroravelr6   r   intr=   r2   r>   floatingr?   r8   floatr   r   r!   r   zeros)rK   non_zerotrailing_zerosNAr   s         r*   r   r      sV   t 	1Avv{899 zz"((1+&q)H 8}xx| Vhrl*Q.N 	
#hqk
3x|,Q./A aggllR[["2D2D$EFFHHUOAA1u!A#)2.AB%!A$!A#
 E288NKK@ABELr,   c                     U 4$ r'   r(   )rK   mks      r*   _polyint_dispatcherr]      	    4Kr,   c           	         [        U5      nUS:  a  [        S5      eUc  [        R                  " U[        5      n[        U5      n[        U5      S:X  a'  US:  a!  US   [        R                  " U[        5      -  n[        U5      U:  a  [        S5      e[        U [        5      n[        R                  " U 5      n US:X  a  U(       a  [        U 5      $ U $ [        R                  " U R                  [        R                  " [        U 5      SS5      5      US   /45      n[        XAS-
  USS S9nU(       a  [        U5      $ U$ )a  
Return an antiderivative (indefinite integral) of a polynomial.

.. 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:`transition guide </reference/routines.polynomials>`.

The returned order `m` antiderivative `P` of polynomial `p` satisfies
:math:`\frac{d^m}{dx^m}P(x) = p(x)` and is defined up to `m - 1`
integration constants `k`. The constants determine the low-order
polynomial part

.. math:: \frac{k_{m-1}}{0!} x^0 + \ldots + \frac{k_0}{(m-1)!}x^{m-1}

of `P` so that :math:`P^{(j)}(0) = k_{m-j-1}`.

Parameters
----------
p : array_like or poly1d
    Polynomial to integrate.
    A sequence is interpreted as polynomial coefficients, see `poly1d`.
m : int, optional
    Order of the antiderivative. (Default: 1)
k : list of `m` scalars or scalar, optional
    Integration constants. They are given in the order of integration:
    those corresponding to highest-order terms come first.

    If ``None`` (default), all constants are assumed to be zero.
    If `m = 1`, a single scalar can be given instead of a list.

See Also
--------
polyder : derivative of a polynomial
poly1d.integ : equivalent method

Examples
--------
The defining property of the antiderivative:

>>> import numpy as np

>>> p = np.poly1d([1,1,1])
>>> P = np.polyint(p)
>>> P
 poly1d([ 0.33333333,  0.5       ,  1.        ,  0.        ]) # may vary
>>> np.polyder(P) == p
True

The integration constants default to zero, but can be specified:

>>> P = np.polyint(p, 3)
>>> P(0)
0.0
>>> np.polyder(P)(0)
0.0
>>> np.polyder(P, 2)(0)
0.0
>>> P = np.polyint(p, 3, k=[6,5,3])
>>> P
poly1d([ 0.01666667,  0.04166667,  0.16666667,  3. ,  5. ,  3. ]) # may vary

Note that 3 = 6 / 2!, and that the constants are given in the order of
integrations. Constant of the highest-order polynomial term comes first:

>>> np.polyder(P, 2)(0)
6.0
>>> np.polyder(P, 1)(0)
5.0
>>> P(0)
3.0

r   z0Order of integral must be positive (see polyder)Nr.   z7k must be a scalar or a rank-1 array of length 1 or >m.rN   )r\   )rR   r:   r;   rU   rT   r   r6   r   
isinstancer   r@   concatenate__truediv__aranger   )rK   r[   r\   truepolyyvals         r*   r   r     s   X 	AA1uKLLyHHQ1A
1v{q1uaDE""
1vzGI 	I !V$H


1AAv!9 NNAMM"))CFAr*BCadVLMaQ!AB%(#;
r,   c                     U 4$ r'   r(   )rK   r[   s     r*   _polyder_dispatcherrh   k  r^   r,   c                 4   [        U5      nUS:  a  [        S5      e[        U [        5      n[        R
                  " U 5      n [        U 5      S-
  nU SS [        R                  " USS5      -  nUS:X  a  U nO[        XAS-
  5      nU(       a  [        U5      nU$ )a  
Return the derivative of the specified order of a polynomial.

.. 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:`transition guide </reference/routines.polynomials>`.

Parameters
----------
p : poly1d or sequence
    Polynomial to differentiate.
    A sequence is interpreted as polynomial coefficients, see `poly1d`.
m : int, optional
    Order of differentiation (default: 1)

Returns
-------
der : poly1d
    A new polynomial representing the derivative.

See Also
--------
polyint : Anti-derivative of a polynomial.
poly1d : Class for one-dimensional polynomials.

Examples
--------
The derivative of the polynomial :math:`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])

r   z2Order of derivative must be positive (see polyint)r.   NrN   )	rR   r:   r`   r   r;   r@   r6   rc   r   )rK   r[   rd   nre   rf   s         r*   r   r   o  s    z 	AA1uMNN!V$H


1AA
A	#21a$$AAvaQSkJr,   c                 
    XU4$ r'   r(   )xre   degrcondr3   wcovs          r*   _polyfit_dispatcherrq     s    !9r,   c                    [        U5      S-   n[        R                  " U 5      S-   n [        R                  " U5      S-   nUS:  a  [        S5      eU R                  S:w  a  [        S5      eU R                  S:X  a  [        S5      eUR                  S:  d  UR                  S:  a  [        S5      eU R                  S   UR                  S   :w  a  [        S	5      eUc+  [        U 5      [        U R                  5      R                  -  n[        X5      nUn	Ub  [        R                  " U5      S-   nUR                  S:w  a  [        S5      eUR                  S   UR                  S   :w  a  [        S5      eXS
S
2[        R                  4   -  nU	R                  S:X  a  XS
S
2[        R                  4   -  n	OX-  n	[        R                  " X-  R                  SS95      n
X-  n[!        XU5      u  ppUR"                  U
-  R"                  nX:w  a#  U(       d  Sn[$        R&                  " U[(        SS9  U(       a  XXU4$ U(       a  [+        [-        UR"                  U5      5      nU[        R.                  " X5      -  nUS:X  a  SnO+[        U 5      U::  a  [        S5      eU[        U 5      U-
  -  nUR                  S:X  a  UUU-  4$ UUS
S
2S
S
2[        R                  4   U-  4$ U$ )a  
Least squares polynomial fit.

.. 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:`transition guide </reference/routines.polynomials>`.

Fit a polynomial ``p(x) = p[0] * x**deg + ... + p[deg]`` of degree `deg`
to points `(x, y)`. Returns a vector of coefficients `p` that minimises
the squared error in the order `deg`, `deg-1`, ... `0`.

The `Polynomial.fit <numpy.polynomial.polynomial.Polynomial.fit>` class
method is recommended for new code as it is more stable numerically. See
the documentation of the method for more information.

Parameters
----------
x : array_like, shape (M,)
    x-coordinates of the M sample points ``(x[i], y[i])``.
y : array_like, shape (M,) or (M, K)
    y-coordinates of the sample points. Several data sets of sample
    points sharing the same x-coordinates can be fitted at once by
    passing in a 2D-array that contains one dataset per column.
deg : int
    Degree of the fitting polynomial
rcond : float, optional
    Relative condition number of the fit. Singular values smaller than
    this relative to the largest singular value will be ignored. The
    default value is len(x)*eps, where eps is the relative precision of
    the float type, about 2e-16 in most cases.
full : bool, optional
    Switch determining nature of return value. When it is False (the
    default) just the coefficients are returned, when True diagnostic
    information from the singular value decomposition is also returned.
w : array_like, shape (M,), optional
    Weights. If not None, the weight ``w[i]`` applies to the unsquared
    residual ``y[i] - y_hat[i]`` at ``x[i]``. Ideally the weights are
    chosen so that the errors of the products ``w[i]*y[i]`` all have the
    same variance.  When using inverse-variance weighting, use
    ``w[i] = 1/sigma(y[i])``.  The default value is None.
cov : bool or str, optional
    If given and not `False`, return not just the estimate but also its
    covariance matrix. By default, the covariance are scaled by
    chi2/dof, where dof = M - (deg + 1), i.e., the weights are presumed
    to be unreliable except in a relative sense and everything is scaled
    such that the reduced chi2 is unity. This scaling is omitted if
    ``cov='unscaled'``, as is relevant for the case that the weights are
    w = 1/sigma, with sigma known to be a reliable estimate of the
    uncertainty.

Returns
-------
p : ndarray, shape (deg + 1,) or (deg + 1, K)
    Polynomial coefficients, highest power first.  If `y` was 2-D, the
    coefficients for `k`-th data set are in ``p[:,k]``.

residuals, rank, singular_values, rcond
    These values are only returned if ``full == True``

    - residuals -- sum of squared residuals of the least squares fit
    - rank -- the effective rank of the scaled Vandermonde
       coefficient matrix
    - singular_values -- singular values of the scaled Vandermonde
       coefficient matrix
    - rcond -- value of `rcond`.

    For more details, see `numpy.linalg.lstsq`.

V : ndarray, shape (deg + 1, deg + 1) or (deg + 1, deg + 1, K)
    Present only if ``full == False`` and ``cov == True``.  The covariance
    matrix of the polynomial coefficient estimates.  The diagonal of
    this matrix are the variance estimates for each coefficient.  If y
    is a 2-D array, then the covariance matrix for the `k`-th data set
    are in ``V[:,:,k]``


Warns
-----
RankWarning
    The rank of the coefficient matrix in the least-squares fit is
    deficient. The warning is only raised if ``full == False``.

    The warnings can be turned off by

    >>> import warnings
    >>> warnings.simplefilter('ignore', np.exceptions.RankWarning)

See Also
--------
polyval : Compute polynomial values.
linalg.lstsq : Computes a least-squares fit.
scipy.interpolate.UnivariateSpline : Computes spline fits.

Notes
-----
The solution minimizes the squared error

.. math::
    E = \sum_{j=0}^k |p(x_j) - y_j|^2

in the equations::

    x[0]**n * p[0] + ... + x[0] * p[n-1] + p[n] = y[0]
    x[1]**n * p[0] + ... + x[1] * p[n-1] + p[n] = y[1]
    ...
    x[k]**n * p[0] + ... + x[k] * p[n-1] + p[n] = y[k]

The coefficient matrix of the coefficients `p` is a Vandermonde matrix.

`polyfit` issues a `~exceptions.RankWarning` when the least-squares fit is
badly conditioned. This implies that the best fit is not well-defined due
to numerical error. The results may be improved by lowering the polynomial
degree or by replacing `x` by `x` - `x`.mean(). The `rcond` parameter
can also be set to a value smaller than its default, but the resulting
fit may be spurious: including contributions from the small singular
values can add numerical noise to the result.

Note that fitting polynomial coefficients is inherently badly conditioned
when the degree of the polynomial is large or the interval of sample points
is badly centered. The quality of the fit should always be checked in these
cases. When polynomial fits are not satisfactory, splines may be a good
alternative.

References
----------
.. [1] Wikipedia, "Curve fitting",
       https://en.wikipedia.org/wiki/Curve_fitting
.. [2] Wikipedia, "Polynomial interpolation",
       https://en.wikipedia.org/wiki/Polynomial_interpolation

Examples
--------
>>> import numpy as np
>>> import warnings
>>> x = np.array([0.0, 1.0, 2.0, 3.0,  4.0,  5.0])
>>> y = np.array([0.0, 0.8, 0.9, 0.1, -0.8, -1.0])
>>> z = np.polyfit(x, y, 3)
>>> z
array([ 0.08703704, -0.81349206,  1.69312169, -0.03968254]) # may vary

It is convenient to use `poly1d` objects for dealing with polynomials:

>>> p = np.poly1d(z)
>>> p(0.5)
0.6143849206349179 # may vary
>>> p(3.5)
-0.34732142857143039 # may vary
>>> p(10)
22.579365079365115 # may vary

High-order polynomials may oscillate wildly:

>>> with warnings.catch_warnings():
...     warnings.simplefilter('ignore', np.exceptions.RankWarning)
...     p30 = np.poly1d(np.polyfit(x, y, 30))
...
>>> p30(4)
-0.80000000000000204 # may vary
>>> p30(5)
-0.99999999999999445 # may vary
>>> p30(4.5)
-0.10547061179440398 # may vary

Illustration:

>>> import matplotlib.pyplot as plt
>>> xp = np.linspace(-2, 6, 100)
>>> _ = plt.plot(x, y, '.', xp, p(xp), '-', xp, p30(xp), '--')
>>> plt.ylim(-2,2)
(-2, 2)
>>> plt.show()

r.           r   zexpected deg >= 0zexpected 1D vector for xzexpected non-empty vector for xr   zexpected 1D or 2D array for yz$expected x and y to have same lengthNz expected a 1-d array for weightsz(expected w and y to have the same length)axisz!Polyfit may be poorly conditioned
stacklevelunscaledzJthe number of data points must exceed order to scale the covariance matrix)rR   r;   r@   r:   rO   	TypeErrorsizer5   r6   r   r2   epsr   newaxissqrtsumr"   Twarningswarnr   r#   r   outer)rl   re   rm   rn   r3   ro   rp   orderlhsrhsscalecresidsranksmsgVbasefacs                     r*   r   r     s   b HqLE


1A


1A Qw,--vv{233vv{9::vvzQVVaZ788wwqzQWWQZ>?? }AuQWW~))) 
C
C 	}JJqMC66Q;>??771:#FGGBJJ88q=Q

]##CHC GGSWMMqM)*ELCs/At	
UA }T1c;15$5((	CsO$%''*C1v  "B C C CFUN+C66Q;eck>!eAaO,s222r,   c                     X4$ r'   r(   )rK   rl   s     r*   _polyval_dispatcherr     	    6Mr,   c                     [         R                  " U 5      n [        U[        5      (       a  SnO,[         R                  " U5      n[         R
                  " U5      nU  H
  nX!-  U-   nM     U$ )a  
Evaluate a polynomial at specific values.

.. 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:`transition guide </reference/routines.polynomials>`.

If `p` is of length N, this function returns the value::

    p[0]*x**(N-1) + p[1]*x**(N-2) + ... + p[N-2]*x + p[N-1]

If `x` is a sequence, then ``p(x)`` is returned for each element of ``x``.
If `x` is another polynomial then the composite polynomial ``p(x(t))``
is returned.

Parameters
----------
p : array_like or poly1d object
   1D array of polynomial coefficients (including coefficients equal
   to zero) from highest degree to the constant term, or an
   instance of poly1d.
x : array_like or poly1d object
   A number, an array of numbers, or an instance of poly1d, at
   which to evaluate `p`.

Returns
-------
values : ndarray or poly1d
   If `x` is a poly1d instance, the result is the composition of the two
   polynomials, i.e., `x` is "substituted" in `p` and the simplified
   result is returned. In addition, the type of `x` - array_like or
   poly1d - governs the type of the output: `x` array_like => `values`
   array_like, `x` a poly1d object => `values` is also.

See Also
--------
poly1d: A polynomial class.

Notes
-----
Horner's scheme [1]_ is used to evaluate the polynomial. Even so,
for polynomials of high degree the values may be inaccurate due to
rounding errors. Use carefully.

If `x` is a subtype of `ndarray` the return value will be of the same type.

References
----------
.. [1] I. N. Bronshtein, K. A. Semendyayev, and K. A. Hirsch (Eng.
   trans. Ed.), *Handbook of Mathematics*, New York, Van Nostrand
   Reinhold Co., 1985, pg. 720.

Examples
--------
>>> import numpy as np
>>> np.polyval([3,0,1], 5)  # 3 * 5**2 + 0 * 5**1 + 1
76
>>> np.polyval([3,0,1], np.poly1d(5))
poly1d([76])
>>> np.polyval(np.poly1d([3,0,1]), 5)
76
>>> np.polyval(np.poly1d([3,0,1]), np.poly1d(5))
poly1d([76])

r   )r;   r@   r`   r   
asanyarray
zeros_like)rK   rl   re   pvs       r*   r
   r
     sZ    J 	

1A!VMM!MM!EBJ Hr,   c                     X4$ r'   r(   )a1a2s     r*   _binary_op_dispatcherr     s	    8Or,   c                    [        U [        5      =(       d    [        U[        5      n[        U 5      n [        U5      n[        U5      [        U 5      -
  nUS:X  a  X-   nOUS:  a;  [        R
                  " X0R                  5      n[        R                  " XP45      U-   nOD[        R
                  " [        U5      UR                  5      nU [        R                  " XQ45      -   nU(       a  [        U5      nU$ )a  
Find the sum of two polynomials.

.. 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:`transition guide </reference/routines.polynomials>`.

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.

Parameters
----------
a1, a2 : array_like or poly1d object
    Input polynomials.

Returns
-------
out : ndarray 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.

See Also
--------
poly1d : A one-dimensional polynomial class.
poly, polyadd, polyder, polydiv, polyfit, polyint, polysub, polyval

Examples
--------
>>> 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

r   	r`   r   r   r6   r;   rU   r2   ra   r   r   r   rd   diffrf   zrs         r*   r   r     s    h 2v&@*R*@H	BB	BBr7SWDqyg	XXdHH%nnbX&+XXc$i*2>>2(++SkJr,   c                    [        U [        5      =(       d    [        U[        5      n[        U 5      n [        U5      n[        U5      [        U 5      -
  nUS:X  a  X-
  nOUS:  a;  [        R
                  " X0R                  5      n[        R                  " XP45      U-
  nOD[        R
                  " [        U5      UR                  5      nU [        R                  " XQ45      -
  nU(       a  [        U5      nU$ )a  
Difference (subtraction) of two polynomials.

.. 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:`transition guide </reference/routines.polynomials>`.

Given two polynomials `a1` and `a2`, returns ``a1 - a2``.
`a1` and `a2` can be either array_like sequences of the polynomials'
coefficients (including coefficients equal to zero), or `poly1d` objects.

Parameters
----------
a1, a2 : array_like or poly1d
    Minuend and subtrahend polynomials, respectively.

Returns
-------
out : ndarray or poly1d
    Array or `poly1d` object of the difference polynomial's coefficients.

See Also
--------
polyval, polydiv, polymul, polyadd

Examples
--------
.. math:: (2 x^2 + 10 x - 2) - (3 x^2 + 10 x -4) = (-x^2 + 2)

>>> import numpy as np

>>> np.polysub([2, 10, -2], [3, 10, -4])
array([-1,  0,  2])

r   r   r   s         r*   r   r   W  s    N 2v&@*R*@H	BB	BBr7SWDqyg	XXdHH%nnbX&+XXc$i*2>>2(++SkJr,   c                     [        U [        5      =(       d    [        U[        5      n[        U 5      [        U5      p[        R                  " X5      nU(       a  [        U5      nU$ )a  
Find the product of two polynomials.

.. 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:`transition guide </reference/routines.polynomials>`.

Finds the polynomial resulting from the multiplication of the two input
polynomials. Each input must be either a poly1d object or a 1D sequence
of polynomial coefficients, from highest to lowest degree.

Parameters
----------
a1, a2 : array_like or poly1d object
    Input polynomials.

Returns
-------
out : ndarray or poly1d object
    The polynomial resulting from the multiplication of the inputs. If
    either inputs 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.

See Also
--------
poly1d : A one-dimensional polynomial class.
poly, polyadd, polyder, polydiv, polyfit, polyint, polysub, polyval
convolve : Array convolution. Same output as polymul, but has parameter
           for overlap mode.

Examples
--------
>>> import numpy as np
>>> np.polymul([1, 2, 3], [9, 5, 1])
array([ 9, 23, 38, 17,  3])

Using poly1d objects:

>>> p1 = np.poly1d([1, 2, 3])
>>> p2 = np.poly1d([9, 5, 1])
>>> print(p1)
   2
1 x + 2 x + 3
>>> print(p2)
   2
9 x + 5 x + 1
>>> print(np.polymul(p1, p2))
   4      3      2
9 x + 23 x + 38 x + 17 x + 3

)r`   r   r;   r<   )r   r   rd   rf   s       r*   r   r     sK    p 2v&@*R*@HBZ
++b
CSkJr,   c                     X4$ r'   r(   )uvs     r*   _polydiv_dispatcherr     r   r,   c                    [        U [        5      =(       d    [        U[        5      n[        U 5      S-   n [        U5      S-   nU S   US   -   n[        U 5      S-
  n[        U5      S-
  nSUS   -  n[        R
                  " [        XE-
  S-   S5      4UR                  5      nU R                  UR                  5      n[        SXE-
  S-   5       H"  n	XhU	   -  n
XU	'   XX-   S-   === X-  -  sss& M$     [        R                  " US   SSS9(       aK  UR                  S   S:  a8  USS n[        R                  " US   SSS9(       a  UR                  S   S:  a  M8  U(       a  [        U5      [        U5      4$ Xx4$ )	a  
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:`transition guide </reference/routines.polynomials>`.

The input arrays are the coefficients (including any coefficients
equal to zero) of the "numerator" (dividend) and "denominator"
(divisor) polynomials, respectively.

Parameters
----------
u : array_like or poly1d
    Dividend polynomial's coefficients.

v : array_like or poly1d
    Divisor polynomial's coefficients.

Returns
-------
q : ndarray
    Coefficients, including those equal to zero, of the quotient.
r : ndarray
    Coefficients, including those equal to zero, of the remainder.

See Also
--------
poly, polyadd, polyder, polydiv, polyfit, polyint, polymul, polysub
polyval

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``, and ``u.ndim = 0, v.ndim = 1`` - work.

Examples
--------
.. math:: \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]))

rs   r   r.   r/   g+=)rtolrN   N)r`   r   r   r6   r;   rU   maxr2   r8   rangeallcloser5   )r   r   rd   ro   r[   rj   r   qrr\   ds              r*   r	   r	     sU   j 1f%>Av)>H1A1A	!qtAA
AA
A1IE
#aeai#%qww/A	A1ac!e_aDL!	ACE
ac
  ++adAE
*aabE ++adAE
*aay&)##4Kr,   z\*\*([0-9]*)c                    SnSnSnSn [         R                  X5      nUc  OUR                  5       nUR                  5       S   nXUS    n	US   nU	S[	        U5      S-
  -  -   n
S[	        U	5      S-
  -  U-   n[	        U5      [	        U
5      -   U:  d  [	        U5      [	        U5      -   U:  a  XSS-   U-   S-   -  nUnU
nO-XIS[	        U5      S-
  -  -   -  nUS[	        U	5      S-
  -  U-   -  nM  XSS-   U-   -  nXPUS  -   $ )Nr     r.   
z
 )	_poly_matsearchspangroupsr6   )astrwraprj   line1line2outputmatr   powerpartstrtoadd2toadd1s               r*   _raise_powerr     s6   	AEEF
t';xxz

Qa/G3E
1--c'l1n%-Z#f+%,Uc&k)D0dlU*U22FEEsCJqL111ES#g,q.)E11E# $ dlU""FHr,   c                   p   \ rS rSrSrSr\S 5       r\R                  S 5       r\S 5       r	\S 5       r
\S 5       r\S	 5       r\R                  S
 5       r\r\=r=rr\
rS$S jrS%S jrS rS rS rS rS rS rS rS rS rS rS rS rS r S r!\!r"S r#\#r$S r%S r&S r'S r(S  r)S&S! jr*S'S" jr+S#r,g)(r   i8  aD
  
A one-dimensional polynomial class.

.. 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:`transition guide </reference/routines.polynomials>`.

A convenience class, used to encapsulate "natural" operations on
polynomials so that said operations may take on their customary
form in code (see Examples).

Parameters
----------
c_or_r : array_like
    The polynomial's coefficients, in decreasing powers, or if
    the value of the second parameter is True, the polynomial's
    roots (values where the polynomial evaluates to 0).  For example,
    ``poly1d([1, 2, 3])`` returns an object that represents
    :math:`x^2 + 2x + 3`, whereas ``poly1d([1, 2, 3], True)`` returns
    one that represents :math:`(x-1)(x-2)(x-3) = x^3 - 6x^2 + 11x -6`.
r : bool, optional
    If True, `c_or_r` specifies the polynomial's roots; the default
    is False.
variable : str, optional
    Changes the variable used when printing `p` from `x` to `variable`
    (see Examples).

Examples
--------
Construct the polynomial :math:`x^2 + 2x + 3`:

>>> import numpy as np

>>> p = np.poly1d([1, 2, 3])
>>> print(np.poly1d(p))
   2
1 x + 2 x + 3

Evaluate the polynomial at :math:`x = 0.5`:

>>> p(0.5)
4.25

Find the roots:

>>> p.r
array([-1.+1.41421356j, -1.-1.41421356j])
>>> p(p.r)
array([ -4.44089210e-16+0.j,  -4.44089210e-16+0.j]) # may vary

These numbers in the previous line represent (0, 0) to machine precision

Show the coefficients:

>>> p.c
array([1, 2, 3])

Display the order (the leading zero-coefficients are removed):

>>> p.order
2

Show the coefficient of the k-th power in the polynomial
(which is equivalent to ``p.c[-(i+1)]``):

>>> p[1]
2

Polynomials can be added, subtracted, multiplied, and divided
(returns quotient and remainder):

>>> p * p
poly1d([ 1,  4, 10, 12,  9])

>>> (p**3 + 4) / p
(poly1d([ 1.,  4., 10., 12.,  9.]), poly1d([4.]))

``asarray(p)`` gives the coefficient array, so polynomials can be
used in all functions that accept arrays:

>>> p**2 # square of polynomial
poly1d([ 1,  4, 10, 12,  9])

>>> np.square(p) # square of individual coefficients
array([1, 4, 9])

The variable used in the string representation of `p` can be modified,
using the `variable` parameter:

>>> p = np.poly1d([1,2,3], variable='z')
>>> print(p)
   2
1 z + 2 z + 3

Construct a polynomial from its roots:

>>> np.poly1d([1, 2], True)
poly1d([ 1., -3.,  2.])

This is the same polynomial as obtained by:

>>> np.poly1d([1, -1]) * np.poly1d([1, -2])
poly1d([ 1, -3,  2])

Nc                     U R                   $ )zThe polynomial coefficients )_coeffsselfs    r*   coeffspoly1d.coeffs  s     ||r,   c                 6    XR                   La  [        S5      eg )NzCannot set attribute)r   AttributeError)r   values     r*   r   r     s     $ !788 %r,   c                     U R                   $ )z$The name of the polynomial variable )	_variabler   s    r*   variablepoly1d.variable  s     ~~r,   c                 2    [        U R                  5      S-
  $ )z&The order or degree of the polynomial r.   )r6   r   r   s    r*   r   poly1d.order  s     4<< 1$$r,   c                 ,    [        U R                  5      $ )z0The roots of the polynomial, where self(x) == 0 )r   r   r   s    r*   r   poly1d.roots  s     T\\""r,   c                      U R                   S   $ Nr   __dict__r   s    r*   r   poly1d._coeffs  s    }}X&&r,   c                      XR                   S'   g r   r   )r   r   s     r*   r   r     s    "(hr,   c                 l   [        U[        5      (       a  UR                  U l        UR                  U l        [	        UR
                  5      [	        U R
                  5      -
  (       aA  Sn[        R                  " U[        SS9  U R
                  R                  UR
                  5        Ub  X0l        g U(       a  [        U5      n[        U5      nUR                  S:  a  [        S5      e[        USS9n[        U5      S:X  a   [         R"                  " S/UR$                  S	9nXl        Uc  S
nX0l        g )NzbIn the future extra properties will not be copied across when constructing one poly1d from anotherr   ru   r.   zPolynomial must be 1d only.f)trimr   r1   rl   )r`   r   r   r   setr   r   r   FutureWarningupdater   r   rO   r:   r   r6   r;   r   r2   )r   c_or_rr   r   r   s        r*   __init__poly1d.__init__  s    ff%%#--DN!>>DL6??#c$--&88Jc=Q?$$V__5#!)&\FF#;;?:;;F-v;!XXqc6FH!r,   c                     U(       a  [         R                  " U R                  XS9$ [         R                  " U R                  US9$ )N)rE   )r;   r@   r   )r   trE   s      r*   	__array__poly1d.__array__  s/    ::dkk188::dkk55r,   c                 @    [        U R                  5      nUSS nSU-  $ )N   rN   z
poly1d(%s))reprr   )r   valss     r*   __repr__poly1d.__repr__  s&    DKK Abzd""r,   c                     U R                   $ r'   )r   r   s    r*   __len__poly1d.__len__  s    zzr,   c           	         SnU R                   nU R                  [        R                  R	                  U R                  S:g  5         n[        U5      S-
  nS n[        U5       GH  u  pg[        U5      (       d  U" [        U5      5      nOM[        U5      S:X  a  SU" [        U5      5      -  nO)SU" [        U5      5      < SU" [        U5      5      < S3nXF-
  n	U	S:X  a  US:w  a  U< n
OKUS:X  a  Sn
OBS	n
O?U	S:X  a  US:X  a  S	n
O0US
:X  a  Un
O'U< SU< 3n
OUS:X  a  S	n
OUS
:X  a  SX)4-  n
OSXU	4-  n
US:  a:  U
S	:w  a1  U
R                  S5      (       a  U< SU
SS  < 3nGM  U< SU
< 3nGM  GM  U
nGM     [        U5      $ )N0r   r.   c                 F    SU -  nUR                  S5      (       a  US S nU$ )Nz%.4gz.0000)endswith)r   r   s     r*   	fmt_float!poly1d.__str__.<locals>.fmt_float  s*    
Azz'""crFHr,   z%sj(z + zj)r   br   z%s**%dz	%s %s**%d-z - )r   r   r;   
logical_or
accumulater6   	enumerater   r   r   
startswithr   )r   thestrvarr   rX   r   r\   coeffcoefstrr   newstrs              r*   __str__poly1d.__str__  s   mm R]]55dkkQ6FGHKM	 "&)HAU###DK0e!)DK"88 " +4DK*@*3DK*@B SEzc>%,FAv!$!#!c>F^ F(/5Fc>F^%5F(G%+@@F1uR<((--.4fQRj!A.4f!=	    Q *R F##r,   c                 .    [        U R                  U5      $ r'   )r
   r   )r   rf   s     r*   __call__poly1d.__call__2  s    t{{C((r,   c                 .    [        U R                  * 5      $ r'   )r   r   r   s    r*   __neg__poly1d.__neg__5  s    t{{l##r,   c                     U $ r'   r(   r   s    r*   __pos__poly1d.__pos__8  s    r,   c                     [        U5      (       a  [        U R                  U-  5      $ [        U5      n[        [        U R                  UR                  5      5      $ r'   r   r   r   r   r   others     r*   __mul__poly1d.__mul__;  sB    E??$++-..5ME'$++u||<==r,   c                     [        U5      (       a  [        XR                  -  5      $ [        U5      n[        [        U R                  UR                  5      5      $ r'   r  r  s     r*   __rmul__poly1d.__rmul__B  s@    E??%++-..5ME'$++u||<==r,   c                 j    [        U5      n[        [        U R                  UR                  5      5      $ r'   r   r   r   r  s     r*   __add__poly1d.__add__I  %    ugdkk5<<899r,   c                 j    [        U5      n[        [        U R                  UR                  5      5      $ r'   r  r  s     r*   __radd__poly1d.__radd__M  r  r,   c                     [        U5      (       a  [        U5      U:w  d  US:  a  [        S5      eS/n[        U5       H  n[	        U R
                  U5      nM     [        U5      $ )Nr   z$Power to non-negative integers only.r.   )r   rR   r:   r   r   r   r   )r   rf   res_s       r*   __pow__poly1d.__pow__Q  sV    }}CC37CDDcsA$++s+C c{r,   c                 j    [        U5      n[        [        U R                  UR                  5      5      $ r'   r   r   r   r  s     r*   __sub__poly1d.__sub__Y  r  r,   c                 j    [        U5      n[        [        UR                  U R                  5      5      $ r'   r!  r  s     r*   __rsub__poly1d.__rsub__]  s%    ugellDKK899r,   c                 ~    [        U5      (       a  [        U R                  U-  5      $ [        U5      n[        X5      $ r'   r   r   r   r	   r  s     r*   __div__poly1d.__div__a  s3    E??$++e+,,5ME4''r,   c                 |    [        U5      (       a  [        XR                  -  5      $ [        U5      n[        X5      $ r'   r(  r  s     r*   __rdiv__poly1d.__rdiv__j  s1    E??%+,,5ME5''r,   c                     [        U[        5      (       d  [        $ U R                  R                  UR                  R                  :w  a  gU R                  UR                  :H  R                  5       $ )NF)r`   r   NotImplementedr   r5   rB   r  s     r*   __eq__poly1d.__eq__s  sP    %((!!;; 2 22u||+0022r,   c                 d    [        U[        5      (       d  [        $ U R                  U5      (       + $ r'   )r`   r   r/  r0  r  s     r*   __ne__poly1d.__ne__z  s'    %((!!;;u%%%r,   c                     U R                   U-
  nXR                   :  a%  U R                  R                  R                  S5      $ US:  a%  U R                  R                  R                  S5      $ U R                  U   $ )Nr   )r   r   r2   r>   )r   rf   inds      r*   __getitem__poly1d.__getitem__  sf    jj3;;$$))!,,7;;$$))!,,{{3r,   c                 <   U R                   U-
  nUS:  a  [        S5      eXR                   :  a_  [        R                  " XR                   -
  U R                  R
                  5      n[        R                  " X@R                  45      U l        SnX R                  U'   g )Nr   z!Does not support negative powers.)r   r:   r;   rU   r   r2   ra   r   )r   keyrf   r6  r   s        r*   __setitem__poly1d.__setitem__  sx    jj37@AA#jj.$++*;*;<B>>2{{*;<DLCSr,   c                 ,    [        U R                  5      $ r'   )iterr   r   s    r*   __iter__poly1d.__iter__  s    DKK  r,   c                 <    [        [        U R                  XS95      $ )z
Return an antiderivative (indefinite integral) of this polynomial.

Refer to `polyint` for full documentation.

See Also
--------
polyint : equivalent function

)r[   r\   )r   r   r   )r   r[   r\   s      r*   integpoly1d.integ  s     gdkkQ455r,   c                 <    [        [        U R                  US95      $ )z
Return a derivative of this polynomial.

Refer to `polyder` for full documentation.

See Also
--------
polyder : equivalent function

)r[   )r   r   r   )r   r[   s     r*   derivpoly1d.deriv  s     gdkkQ/00r,   )r   r   )FNNN)r.   r   r0   )-__name__
__module____qualname____firstlineno____doc____hash__propertyr   setterr   r   r   r   r   r   coefcoefficientsor   r   r   r   r   r  r  r  r  r  r  r  r  r"  r%  r)  rb   r,  __rtruediv__r0  r3  r7  r;  r?  rB  rE  __static_attributes__r(   r,   r*   r   r   8  sB   jV H  ]]9 9
  
 % % # # ' '^^) ) 	A$$A$|A"66#
7$r)$>>::::( K( L3& 	!61r,   r   alwaysrG  )r.   Nr'   r0   )NNNN)NFNF)F   )>rL  __all__	functoolsrer   _utilsr   numpy._core.numeric_corenumericr;   numpy._corer   r   r   r   r   r   r   r   r   numpy.exceptionsr   numpy.lib._twodim_base_implr   r   numpy.lib._function_base_implr   numpy.lib._type_check_implr   r   r   r    numpy.linalgr!   r"   r#   partialarray_function_dispatchr+   r   rL   r   r]   r   rh   r   rq   r   r   r
   r   r   r   r   r   r	   compiler   r   r   simplefilterr(   r,   r*   <module>rh     s    	         ! ( 4 4 I I , , $++%%g7  )*y +yx *+Y ,Yx ,-c .cL ,-J .JZ ,-u .up ,-L .L^ ./A 0AH ./4 04n ./< 0<~ ,-F .FP JJ'	6 Gu1 u1 u1r 	  h ,r,   