+
    ic!                         R t ^ RIHtHtHtHt ^ RIHtHtH	t	H
t
 ^ RIHtHt ^ RIHtHt ^ RIHtHt ^ RIHt ^ RIHtHtHt ]R 4       t]R	 4       t]R
 4       t]]! R4      3R l4       t]RR l4       tR# )z/High-level polynomials manipulation functions. )SBasicsymbolsDummy)PolificationFailedComputationFailedMultivariatePolynomialErrorOptionError)allowed_flagsbuild_options)poly_from_exprPoly)symmetric_polyinterpolating_poly)sring)numbered_symbolstakepublicc                   \        VRR.4       Rp\        V R4      '       g   RpV .p \        V .VO5/ VB w  r@VP                  p\	        W4      pVP                  p\        \        V4      4       Uu. uF  p\        V4      NK  	  pp. pV  FE  p	V	P                  4       w  rpVP                  V
P                  ! V!  VP                  ! V!  34       KG  	  \        VX4       UUUu. uF  w  pw  rWP                  4       3NK  	  ppppVP                  '       g.   \        V4       F  w  pw  ppVP                  V4      V3W&   K   	  V'       g   Vw  pVP                  '       g   V# V'       d   VV3# VV3,           # u upi u upppi )a^  
Rewrite a polynomial in terms of elementary symmetric polynomials.

A symmetric polynomial is a multivariate polynomial that remains invariant
under any variable permutation, i.e., if `f = f(x_1, x_2, \dots, x_n)`,
then `f = f(x_{i_1}, x_{i_2}, \dots, x_{i_n})`, where
`(i_1, i_2, \dots, i_n)` is a permutation of `(1, 2, \dots, n)` (an
element of the group `S_n`).

Returns a tuple of symmetric polynomials ``(f1, f2, ..., fn)`` such that
``f = f1 + f2 + ... + fn``.

Examples
========

>>> from sympy.polys.polyfuncs import symmetrize
>>> from sympy.abc import x, y

>>> symmetrize(x**2 + y**2)
(-2*x*y + (x + y)**2, 0)

>>> symmetrize(x**2 + y**2, formal=True)
(s1**2 - 2*s2, 0, [(s1, x + y), (s2, x*y)])

>>> symmetrize(x**2 - y**2)
(-2*x*y + (x + y)**2, -2*y**2)

>>> symmetrize(x**2 - y**2, formal=True)
(s1**2 - 2*s2, -2*y**2, [(s1, x + y), (s2, x*y)])

formalr   T__iter__F)r
   hasattrr   r   r   rangelennext
symmetrizeappendas_exprzipr   	enumeratesubs)FgensargsiterableRoptr   iresultfprms_gpolyssymnon_syms   &*,                u/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/polys/polyfuncs.pyr   r      sg   B $9-.H1j!!C"T"T"DA99D

#CkkG&+CI&67&6tG}&6G7F,,.aqyy'*AIIt,<=>  037A?)!VaaE?:::!*6!2A~W%'2FI "3 :::5= UH$$/ 8 @s   2E=%Fc                   \        V. 4        \        V .VO5/ VB w  r4\        P
                  TP                  rvTP                  '       d)   TP                  4        F  pYg,          T,           pK  	  T# \        Y74      TR,          rTP                  4        F  pYg,          \        T.TO5/ TB ,           pK!  	  T#   \         d   pTP                  u Rp?# Rp?ii ; i)a  
Rewrite a polynomial in Horner form.

Among other applications, evaluation of a polynomial at a point is optimal
when it is applied using the Horner scheme ([1]).

Examples
========

>>> from sympy.polys.polyfuncs import horner
>>> from sympy.abc import x, y, a, b, c, d, e

>>> horner(9*x**4 + 8*x**3 + 7*x**2 + 6*x + 5)
x*(x*(x*(9*x + 8) + 7) + 6) + 5

>>> horner(a*x**4 + b*x**3 + c*x**2 + d*x + e)
e + x*(d + x*(c + x*(a*x + b)))

>>> f = 4*x**2*y**2 + 2*x**2*y + 2*x*y**2 + x*y

>>> horner(f, wrt=x)
x*(x*y*(4*y + 2) + y*(2*y + 1))

>>> horner(f, wrt=y)
y*(x*y*(4*x + 2) + x*(2*x + 1))

References
==========
[1] - https://en.wikipedia.org/wiki/Horner_scheme

N   NN)r
   r   r   exprr   Zerogenis_univariate
all_coeffsr   horner)	r)   r"   r#   r!   r&   excformr9   coeffs	   &*,      r3   r<   r<   W   s    B $1D1D1 #\\^E8e#D $ K q,R4\\^E8fU:T:T::D $ K  xxs   B< <CCCCc                   \        V 4      p\        V \        4      '       d;   W9   d   \        W,          4      # \	        \        V P                  4       !  4      w  r4M\        V ^ ,          \        4      '       d<   \	        \        V !  4      w  r4W9   d!   \        WCP                  V4      ,          4      # MWV\        ^V^,           4      9   d   \        W^,
          ,          4      # \	        V 4      p\	        \        ^V^,           4      4      p \        W!W44      P                  4       #   \         d7    \        4       p\        Y%Y44      P                  4       P                  YQ4      u # i ; i)a  
Construct an interpolating polynomial for the data points
evaluated at point x (which can be symbolic or numeric).

Examples
========

>>> from sympy.polys.polyfuncs import interpolate
>>> from sympy.abc import a, b, x

A list is interpreted as though it were paired with a range starting
from 1:

>>> interpolate([1, 4, 9, 16], x)
x**2

This can be made explicit by giving a list of coordinates:

>>> interpolate([(1, 1), (2, 4), (3, 9)], x)
x**2

The (x, y) coordinates can also be given as keys and values of a
dictionary (and the points need not be equispaced):

>>> interpolate([(-1, 2), (1, 2), (2, 5)], x)
x**2 + 1
>>> interpolate({-1: 2, 1: 2, 2: 5}, x)
x**2 + 1

If the interpolation is going to be used only once then the
value of interest can be passed instead of passing a symbol:

>>> interpolate([1, 4, 9], 5)
25

Symbolic coordinates are also supported:

>>> [(i,interpolate((a, b), i)) for i in range(1, 4)]
[(1, a), (2, b), (3, -a + 2*b)]
)r   
isinstancedictr   listr   itemstupleindexr   r   expand
ValueErrorr   r    )dataxnXYds   &&    r3   interpolaterO      s   T 	D	A$9TW:C&'1d1gu%%T
#DAv771:''  E!QUO#!e~%T
AU1a!e_%AB!!-4466 BG!!-446;;AAABs   D& &>E'&E'rJ   c                J  aaa
 ^ RI Hp \        \        V !  4      w  rE\	        V4      S,
          ^,
          pV^ 8  d   \        R4      hV! SV,           ^,           SV,           ^,           4      p\        \        SV4      4       FE  p\        SV,           ^,           4       F%  p	WyV3,          WI,          ,          WyV^,           3&   K'  	  KG  	  \        V^,           4       FZ  p\        SV,           ^,           4       F:  p	WyWh,
          3,          ) WY,          ,          WySV,           ^,           V,
          3&   K<  	  K\  	  VP                  4       ^ ,          o
\        VV
3R l\        S^,           4       4       4      \        VVV
3R l\        V^,           4       4       4      ,          # )a  
Returns a rational interpolation, where the data points are element of
any integral domain.

The first argument  contains the data (as a list of coordinates). The
``degnum`` argument is the degree in the numerator of the rational
function. Setting it too high will decrease the maximal degree in the
denominator for the same amount of data.

Examples
========

>>> from sympy.polys.polyfuncs import rational_interpolate

>>> data = [(1, -210), (2, -35), (3, 105), (4, 231), (5, 350), (6, 465)]
>>> rational_interpolate(data, 2)
(105*x**2 - 525)/(x + 1)

Values do not need to be integers:

>>> from sympy import sympify
>>> x = [1, 2, 3, 4, 5, 6]
>>> y = sympify("[-1, 0, 2, 22/5, 7, 68/7]")
>>> rational_interpolate(zip(x, y), 2)
(3*x**2 - 7*x + 2)/(x + 1)

The symbol for the variable can be changed if needed:
>>> from sympy import symbols
>>> z = symbols('z')
>>> rational_interpolate(data, 2, X=z)
(105*z**2 - 525)/(z + 1)

References
==========

.. [1] Algorithm is adapted from:
       http://axiom-wiki.newsynthesis.org/RationalInterpolation

)onesz'Too few values for the required degree.c              3   R   <"   T F  pSV,          SV,          ,          x  K  	  R # 5iN ).0r'   rL   r+   s   & r3   	<genexpr>'rational_interpolate.<locals>.<genexpr>  s!     7%6!q!t%6s   $'c              3   n   <"   T F*  pSVS,           ^,           ,          SV,          ,          x  K,  	  R# 5i)r6   NrT   )rU   r'   rL   degnumr+   s   & r3   rV   rW     s*     ALq!AJN#ad**Ls   25)
sympy.matrices.denserQ   rC   r   r   r	   r   max	nullspacesum)rI   rY   rL   rQ   xdataydatakcjr'   r+   s   &ff       @r3   rational_interpolaterc      sD   R *T
#LEE
VaA1uCDDVaZ!^VaZ!^,A3vq>"vzA~&AqD'%(*AQhK ' # 1q5\vzA~&A()QU(|EH'<A!a!##$ '  	
aA7U6A:%677AE!a%LAAB C    Nc                   \        V. 4       \        V\        4      '       d   V3V,           Rr \        V .VO5/ VB w  rT P                  '       d   \        R4      hT P                  4       pT^8  d   \        R4      hTf   \        R^R7      p\        Y4      pT\        T4      8w  d   \        RT: R\        T4      : 24      hT P                  4       T P                  4       r. R
r\        TR	,          4       F<  w  r\!        T^,           T4      pYT,          ,          pT	P#                  Y34       T
) p
K>  	  T	#   \         d   p\        R^T4      hRp?ii ; i)z
Generate Viete's formulas for ``f``.

Examples
========

>>> from sympy.polys.polyfuncs import viete
>>> from sympy import symbols

>>> x, a, b, c, r1, r2 = symbols('x,a:c,r1:3')

>>> viete(a*x**2 + b*x + c, [r1, r2], x)
[(r1 + r2, -b/a), (r1*r2, c/a)]

Nvietez(multivariate polynomials are not allowedz8Cannot derive Viete's formulas for a constant polynomialr+   )startz	required z roots, got r5   )r
   rA   r   r   r   r   is_multivariater   degreerH   r   r   r   LCr;   r   r   r   )r)   rootsr"   r#   r&   r=   rK   lccoeffsr(   signr'   r?   polys   &&*,          r3   rf   rf     sI   " $%hote11D1D1 	)68 	8 	

A1uFH 	H } A.NECJ3u:FGGrDfRj)a!eU+Bhtm$u	 * M=  1C001s   D= =EEErS   )__doc__
sympy.corer   r   r   r   sympy.polys.polyerrorsr   r   r   r	   sympy.polys.polyoptionsr
   r   sympy.polys.polytoolsr   r   sympy.polys.specialpolysr   r   sympy.polys.ringsr   sympy.utilitiesr   r   r   r   r<   rO   rc   rf   rT   rd   r3   <module>ry      s    5 0 /. . A 6( # : :D% D%N 2 2j >B >BB )0 8C 8Cv 5 5rd   