
    (ph#                     @    S SK JrJrJrJrJrJr  S SKJr  S/r	SS jr
g)    )zerosasarrayeyepoly1dhstackr_)linalgpadeNc                    [        U 5      n Uc"  [        U 5      S-
  U-
  nUS:  a  [        S5      eUS:  a  [        S5      eX-   nU[        U 5      S-
  :  a  [        S5      eU SUS-    n [        US-   US-   U R                  S9n[        US-   U4U R                  S9n[        SUS-   5       H  nU SU SSS2   * XVSU24'   M     [        US-   US-   5       H  nXU-
  U SSS2   * XVSS24'   M     [        XE45      n[        R                  " Xp5      nUSUS-    n	[        S	XS-   S 4   n
[        U	SSS2   5      [        U
SSS2   5      4$ )
a5  
Return Pade approximation to a polynomial as the ratio of two polynomials.

Parameters
----------
an : (N,) array_like
    Taylor series coefficients.
m : int
    The order of the returned approximating polynomial `q`.
n : int, optional
    The order of the returned approximating polynomial `p`. By default,
    the order is ``len(an)-1-m``.

Returns
-------
p, q : Polynomial class
    The Pade approximation of the polynomial defined by `an` is
    ``p(x)/q(x)``.

Examples
--------
>>> import numpy as np
>>> from scipy.interpolate import pade
>>> e_exp = [1.0, 1.0, 1.0/2.0, 1.0/6.0, 1.0/24.0, 1.0/120.0]
>>> p, q = pade(e_exp, 2)

>>> e_exp.reverse()
>>> e_poly = np.poly1d(e_exp)

Compare ``e_poly(x)`` and the Pade approximation ``p(x)/q(x)``

>>> e_poly(1)
2.7166666666666668

>>> p(1)/q(1)
2.7179487179487181

N   r   z.Order of q <m> must be smaller than len(an)-1.z&Order of p <n> must be greater than 0.z0Order of q+p <m+n> must be smaller than len(an).)dtypeg      ?)r   len
ValueErrorr   r   r   ranger   r	   solver   r   )anmnNAkjBkjrowCpqpqs              J/var/www/html/venv/lib/python3.13/site-packages/scipy/interpolate/_pade.pyr
   r
      s{   N 
ByGaK!Oq5MNN1uABB	A3r719}KLL	DQqSB
ac1Q3bhh
'C
1a
)CQ!}Tc(DbD))H QqS!A#a%}dd++E
 zA	a	B
4AaCA
3Q34=A!DbD'?F1TrT7O++    )N)numpyr   r   r   r   r   r   scipyr	   __all__r
    r   r   <module>r$      s    9 9 (<,r   