
    \hB                        S r SSKJrJrJrJrJrJrJrJ	r	J
r
JrJrJrJr  SSKJr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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-S  r.S! r/S" r0S# r1S$ r2S% r3S& r4S' r5S( r6S) r7S* r8S+ r9S, r:S- r;S. r<S/ r=S0 r>S1 r?S2 r@S3 rAS4 rBS5 rCS6 rDS7 rES8 rFS9 rGS: rHS; rIS< rJS= rKS> rLS? rMS@ rNSA rOSB rPSC rQgD)EzEArithmetics for dense recursive polynomials in ``K[x]`` or ``K[X]``.     )	dup_slicedup_LCdmp_LC
dup_degree
dmp_degree	dup_strip	dmp_strip
dmp_zero_pdmp_zero	dmp_one_pdmp_one
dmp_ground	dmp_zeros)ExactQuotientFailedPolynomialDivisionFailedc                     U(       d  U $ [        U 5      nXB-
  S-
  nX$S-
  :X  a  [        U S   U-   /U SS -   5      $ X$:  a  U/UR                  /X$-
  -  -   U -   $ U SU X   U-   /-   XS-   S -   $ )z
Add ``c*x**i`` to ``f`` in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_add_term(x**2 - 1, ZZ(2), 4)
2*x**4 + x**2 - 1

   r   Nlenr   zerofciKnms         N/var/www/auris/envauris/lib/python3.13/site-packages/sympy/polys/densearith.pydup_add_termr      s     AA		AEz!A$(ae+,,63!&&15))A--Ra5AD1H:%a%&	11    c                 <   U(       d  [        XX$5      $ US-
  n[        X5      (       a  U $ [        U 5      nXb-
  S-
  nX&S-
  :X  a!  [        [	        U S   XU5      /U SS -   U5      $ X&:  a  U/[        X&-
  XT5      -   U -   $ U SU [	        X   XU5      /-   XS-   S -   $ )z
Add ``c(x_2..x_u)*x_0**i`` to ``f`` in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_add_term(x*y + 1, 2, 2)
2*x**2 + x*y + 1

r   r   N)r   r
   r   r	   dmp_addr   r   r   r   ur   vr   r   s           r   dmp_add_termr&   +   s     A!''	AA!AA		AEz'!A$a01AabE91==6315!//!33Ra5GAD!233aAi??r    c                     U(       d  U $ [        U 5      nXB-
  S-
  nX$S-
  :X  a  [        U S   U-
  /U SS -   5      $ X$:  a  U* /UR                  /X$-
  -  -   U -   $ U SU X   U-
  /-   XS-   S -   $ )z
Subtract ``c*x**i`` from ``f`` in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_sub_term(2*x**4 + x**2 - 1, ZZ(2), 4)
x**2 - 1

r   r   Nr   r   s         r   dup_sub_termr(   M   s     AA		AEz!A$(ae+,,6B4166(AE**Q..Ra5AD1H:%a%&	11r    c                 R   U(       d  [        X* X$5      $ US-
  n[        X5      (       a  U $ [        U 5      nXb-
  S-
  nX&S-
  :X  a!  [        [	        U S   XU5      /U SS -   U5      $ X&:  a  [        XU5      /[        X&-
  XT5      -   U -   $ U SU [	        X   XU5      /-   XS-   S -   $ )z
Subtract ``c(x_2..x_u)*x_0**i`` from ``f`` in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_sub_term(2*x**2 + x*y + 1, 2, 2)
x*y + 1

r   r   N)r   r
   r   r	   dmp_subdmp_negr   r#   s           r   dmp_sub_termr,   j   s     Ar1((	AA!AA		AEz'!A$a01AabE91==6A!$%	!%(>>BBRa5GAD!233aAi??r    c                 x    U(       a  U (       d  / $ U  Vs/ s H  oDU-  PM	     snUR                   /U-  -   $ s  snf )z
Multiply ``f`` by ``c*x**i`` in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_mul_term(x**2 - 1, ZZ(3), 2)
3*x**4 - 3*x**2

r   )r   r   r   r   cfs        r   dup_mul_termr0      s7     A	"#%!Ba!%
22%s   7c           	          U(       d  [        XX$5      $ US-
  n[        X5      (       a  U $ [        X5      (       a  [        U5      $ U  Vs/ s H  n[        XaXT5      PM     sn[	        X%U5      -   $ s  snf )z
Multiply ``f`` by ``c(x_2..x_u)*x_0**i`` in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_mul_term(x**2*y + x, 3*y, 2)
3*x**4*y**2 + 3*x**3*y

r   )r0   r
   r   dmp_mulr   )r   r   r   r$   r   r%   r/   s          r   dmp_mul_termr3      sm     A!''	AA!!{013"%3ia6HHH3s   
A0c                     [        XSU5      $ )z
Add an element of the ground domain to ``f``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_add_ground(x**3 + 2*x**2 + 3*x + 4, ZZ(4))
x**3 + 2*x**2 + 3*x + 8

r   )r   r   r   r   s      r   dup_add_groundr6           a##r    c                 6    [        U [        XS-
  5      SX#5      $ )z
Add an element of the ground domain to ``f``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_add_ground(x**3 + 2*x**2 + 3*x + 4, ZZ(4))
x**3 + 2*x**2 + 3*x + 8

r   r   )r&   r   r   r   r$   r   s       r   dmp_add_groundr:           :aQ/A99r    c                     [        XSU5      $ )z
Subtract an element of the ground domain from ``f``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_sub_ground(x**3 + 2*x**2 + 3*x + 4, ZZ(4))
x**3 + 2*x**2 + 3*x

r   )r(   r5   s      r   dup_sub_groundr=      r7   r    c                 6    [        U [        XS-
  5      SX#5      $ )z
Subtract an element of the ground domain from ``f``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_sub_ground(x**3 + 2*x**2 + 3*x + 4, ZZ(4))
x**3 + 2*x**2 + 3*x

r   r   )r,   r   r9   s       r   dmp_sub_groundr?      r;   r    c                 V    U(       a  U (       d  / $ U  Vs/ s H  o3U-  PM	     sn$ s  snf )z
Multiply ``f`` by a constant value in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_mul_ground(x**2 + 2*x - 1, ZZ(3))
3*x**2 + 6*x - 3

 r   r   r   r/   s       r   dup_mul_groundrC      s(     A	"#%!Ba!%%%s   &c           	      v    U(       d  [        XU5      $ US-
  nU  Vs/ s H  n[        XQXC5      PM     sn$ s  snf )z
Multiply ``f`` by a constant value in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_mul_ground(2*x + 2*y, ZZ(3))
6*x + 6*y

r   )rC   dmp_mul_groundr   r   r$   r   r%   r/   s         r   rE   rE     s<     aA&&	AA3461R^B1(1666   6c                     U(       d  [        S5      eU (       d  U $ UR                  (       a!  U  Vs/ s H  o2R                  X15      PM     sn$ U  Vs/ s H  o3U-  PM	     sn$ s  snf s  snf )z
Quotient by a constant in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ, QQ

>>> R, x = ring("x", ZZ)
>>> R.dup_quo_ground(3*x**2 + 2, ZZ(2))
x**2 + 1

>>> R, x = ring("x", QQ)
>>> R.dup_quo_ground(3*x**2 + 2, QQ(2))
3/2*x**2 + 1

polynomial division)ZeroDivisionErroris_FieldquorB   s       r   dup_quo_groundrM   )  s\    $  566zz()+"r++#$&1Rq1&& ,&s   A#A(c           	      v    U(       d  [        XU5      $ US-
  nU  Vs/ s H  n[        XQXC5      PM     sn$ s  snf )a  
Quotient by a constant in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ, QQ

>>> R, x,y = ring("x,y", ZZ)
>>> R.dmp_quo_ground(2*x**2*y + 3*x, ZZ(2))
x**2*y + x

>>> R, x,y = ring("x,y", QQ)
>>> R.dmp_quo_ground(2*x**2*y + 3*x, QQ(2))
x**2*y + 3/2*x

r   )rM   dmp_quo_groundrF   s         r   rO   rO   F  s<    $ aA&&	AA3461R^B1(1666rG   c                     U(       d  [        S5      eU (       d  U $ U  Vs/ s H  o2R                  X15      PM     sn$ s  snf )z
Exact quotient by a constant in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, QQ
>>> R, x = ring("x", QQ)

>>> R.dup_exquo_ground(x**2 + 2, QQ(2))
1/2*x**2 + 1

rI   )rJ   exquorB   s       r   dup_exquo_groundrR   `  s9      566&')aWWR^a)))s   =c           	      v    U(       d  [        XU5      $ US-
  nU  Vs/ s H  n[        XQXC5      PM     sn$ s  snf )z
Exact quotient by a constant in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, QQ
>>> R, x,y = ring("x,y", QQ)

>>> R.dmp_exquo_ground(x**2*y + 2*x, QQ(2))
1/2*x**2*y + x

r   )rR   dmp_exquo_groundrF   s         r   rT   rT   v  s=     a((	AA568QrbQ*Q888rG   c                 8    U (       d  U $ XR                   /U-  -   $ )z
Efficiently multiply ``f`` by ``x**n`` in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_lshift(x**2 + 1, 2)
x**4 + x**2

r.   r   r   r   s      r   
dup_lshiftrW     s     FF8A:~r    c                     U SU*  $ )z
Efficiently divide ``f`` by ``x**n`` in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_rshift(x**4 + x**2, 2)
x**2 + 1
>>> R.dup_rshift(x**4 + x**2 + 2, 2)
x**2 + 1

NrA   rV   s      r   
dup_rshiftrY     s      Sqb6Mr    c                 N    U  Vs/ s H  o!R                  U5      PM     sn$ s  snf )z
Make all coefficients positive in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_abs(x**2 - 1)
x**2 + 1

)absr   r   coeffs      r   dup_absr^     s"     ()*qeUU5\q***s   "c                 t    U(       d  [        X5      $ US-
  nU  Vs/ s H  n[        XCU5      PM     sn$ s  snf )z
Make all coefficients positive in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_abs(x**2*y - x)
x**2*y + x

r   )r^   dmp_absr   r$   r   r%   r/   s        r   r`   r`     9     q}	AA)*,2WRA,,,   5c                 2    U  Vs/ s H  o"* PM     sn$ s  snf )z
Negate a polynomial in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_neg(x**2 - 1)
-x**2 + 1

rA   r\   s      r   dup_negre     s     "#$V$$$s   c                 t    U(       d  [        X5      $ US-
  nU  Vs/ s H  n[        XCU5      PM     sn$ s  snf )z
Negate a polynomial in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_neg(x**2*y - x)
-x**2*y + x

r   )re   r+   ra   s        r   r+   r+     rb   rc   c                 Z   U (       d  U$ U(       d  U $ [        U 5      n[        U5      nX4:X  a+  [        [        X5       VVs/ s H	  u  pVXV-   PM     snn5      $ [        X4-
  5      nX4:  a	  U SU XS pOUSU XS pU[        X5       VVs/ s H	  u  pVXV-   PM     snn-   $ s  snnf s  snnf )z
Add dense polynomials in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_add(x**2 - 1, x - 2)
x**2 + x - 3

N)r   r   zipr[   	r   gr   dfdgabkhs	            r   dup_addrq     s     	AB	AB	xSY8YTQ15Y899L7Ra5!B%qRa5!B%qs1y2ytqQUy222 9 3s   B!
B'c                    U(       d  [        XU5      $ [        X5      nUS:  a  U$ [        X5      nUS:  a  U $ US-
  nXE:X  a4  [        [        X5       VVs/ s H  u  px[	        XxXc5      PM     snnU5      $ [        XE-
  5      n	XE:  a	  U SU	 X	S p
OUSU	 XS pU
[        X5       VVs/ s H  u  px[	        XxXc5      PM     snn-   $ s  snnf s  snnf )z
Add dense polynomials in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_add(x**2 + y, x**2*y + x)
x**2*y + x**2 + x + y

r   r   N)rq   r   r	   rh   r"   r[   r   rj   r$   r   rk   rl   r%   rm   rn   ro   rp   s              r   r"   r"   $  s     qQ	A	B	Av	A	B	Av	AA	x3q9F94171.9FJJL7Ra5!B%qRa5!B%qSY@YTQWQ1(Y@@@ G As   C
*Cc                    U (       d  [        X5      $ U(       d  U $ [        U 5      n[        U5      nX4:X  a+  [        [        X5       VVs/ s H	  u  pVXV-
  PM     snn5      $ [	        X4-
  5      nX4:  a	  U SU XS pO[        USU U5      XS pU[        X5       VVs/ s H	  u  pVXV-
  PM     snn-   $ s  snnf s  snnf )z
Subtract dense polynomials in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_sub(x**2 - 1, x - 2)
x**2 - x + 1

N)re   r   r   rh   r[   ri   s	            r   dup_subru   N  s     q}	AB	AB	xSY8YTQ15Y899L7Ra5!B%q1Ra5!$aeqs1y2ytqQUy222 9 3s   
B4
B:c                    U(       d  [        XU5      $ [        X5      nUS:  a  [        XU5      $ [        X5      nUS:  a  U $ US-
  nXE:X  a4  [        [	        X5       VVs/ s H  u  px[        XxXc5      PM     snnU5      $ [        XE-
  5      n	XE:  a	  U SU	 X	S p
O[        USU	 X#5      XS pU
[	        X5       VVs/ s H  u  px[        XxXc5      PM     snn-   $ s  snnf s  snnf )z
Subtract dense polynomials in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_sub(x**2 + y, x**2*y + x)
-x**2*y + x**2 - x + y

r   r   N)ru   r   r+   r	   rh   r*   r[   rs   s              r   r*   r*   q  s     qQ	A	B	AvqQ	A	B	Av	AA	x3q9F94171.9FJJL7Ra5!B%q1Ra5!'2qSY@YTQWQ1(Y@@@ G As   !C
>C"c                 0    [        U [        XU5      U5      $ )z
Returns ``f + g*h`` where ``f, g, h`` are in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_add_mul(x**2 - 1, x - 2, x + 2)
2*x**2 - 5

)rq   dup_mulr   rj   rp   r   s       r   dup_add_mulrz          1gaA&**r    c           	      0    [        U [        XX45      X45      $ )z
Returns ``f + g*h`` where ``f, g, h`` are in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_add_mul(x**2 + y, x, x + 2)
2*x**2 + 2*x + y

)r"   r2   r   rj   rp   r$   r   s        r   dmp_add_mulr~          1gaA)100r    c                 0    [        U [        XU5      U5      $ )z
Returns ``f - g*h`` where ``f, g, h`` are in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_sub_mul(x**2 - 1, x - 2, x + 2)
3

)ru   rx   ry   s       r   dup_sub_mulr     r{   r    c           	      0    [        U [        XX45      X45      $ )z
Returns ``f - g*h`` where ``f, g, h`` are in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_sub_mul(x**2 + y, x, x + 2)
-2*x + y

)r*   r2   r}   s        r   dmp_sub_mulr     r   r    c           
      F   X:X  a  [        X5      $ U (       a  U(       d  / $ [        U 5      n[        U5      n[        X45      S-   nUS:  d  UR                  (       d|  / n[	        SX4-   S-   5       HZ  nUR
                  n[	        [        SXt-
  5      [        X75      S-   5       H  n	XU	   XU	-
     -  -  nM     UR                  U5        M\     [        U5      $ US-  n
[        U SX5      [        USX5      p[        [        X
XR5      X5      n[        [        XXR5      X5      n[        XU5      [        XU5      nn[        [        XU5      [        XU5      U5      n[        U[        UUU5      U5      n[        [        U[        UX5      U5      [        USU
-  U5      U5      $ )z
Multiply dense polynomials in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_mul(x - 2, x + 2)
x**2 - 4

r   d   r      )dup_sqrr   maxis_Exactranger   minappendr   r   rY   rx   rq   ru   rW   )r   rj   r   rk   rl   r   rp   r   r]   jn2flglfhghlohimids                     r   rx   rx     s    	vq}!		AB	ABBaA3wajjq"'A+&AFFE3q!&>3r:>:1aAh& ; HHUO ' |
 T1a'1a)?B	!.6	!.6#WRQ%7Bgba('"!*<a@c72r1-q1wr:c2#91=!"adA.3 	3r    c                    U(       d  [        XU5      $ X:X  a  [        XU5      $ [        X5      nUS:  a  U $ [        X5      nUS:  a  U$ / US-
  pv[        SXE-   S-   5       Hi  n[	        U5      n	[        [        SX-
  5      [        XH5      S-   5       H"  n
[        U	[        X
   XU
-
     Xs5      Xs5      n	M$     UR                  U	5        Mk     [        Xb5      $ )z
Multiply dense polynomials in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_mul(x*y + 1, x)
x**2*y + x

r   r   )rx   dmp_sqrr   r   r   r   r   r"   r2   r   r	   )r   rj   r$   r   rk   rl   rp   r%   r   r]   r   s              r   r2   r2     s     qQvqQ	A	B	Av	A	B	Avq1uq1bgk"s1af~s2zA~6AE714q51#@!GE 7 	
 # Q?r    c                 v   [        U 5      S-
  / p2[        SSU-  S-   5       H  nUR                  n[        SXB-
  5      n[	        XB5      nXv-
  S-   nXhS-  -   S-
  n[        XgS-   5       H  n	XPU	   XU	-
     -  -  nM     XU-  nUS-  (       a  XS-      n
XZS-  -  nUR                  U5        M     [        U5      $ )z
Square dense polynomials in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_sqr(x**2 + 1)
x**4 + 2*x**2 + 1

r   r   r   )r   r   r   r   r   r   r   )r   r   rk   rp   r   r   jminjmaxr   r   elems              r   r   r   C  s     FQJ1adQhFF1af~1zK!O1f}q tAX&A1aAhA ' 	
q5AX;DqLA	'  * Q<r    c                    U(       d  [        X5      $ [        X5      nUS:  a  U $ / US-
  pT[        SSU-  S-   5       H  n[        U5      n[	        SXc-
  5      n[        Xc5      n	X-
  S-   n
XS-  -   S-
  n	[        XS-   5       H"  n[        U[        X   XU-
     XR5      XR5      nM$     [        Xr" S5      XR5      nU
S-  (       a  [        X	S-      XR5      n[        X|XR5      nUR                  U5        M     [        XA5      $ )z
Square dense polynomials in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_sqr(x**2 + x*y + y**2)
x**4 + 2*x**3*y + 3*x**2*y**2 + 2*x*y**3 + y**4

r   r   r   )r   r   r   r   r   r   r"   r2   rE   r   r   r	   )r   r$   r   rk   rp   r%   r   r   r   r   r   r   r   s                r   r   r   k  s    q}	A	B	Avq1uq1adQhQK1af~1zK!O1f}q tAX&A714q518!?A ' 1adA)q51AX;-D&A	'  * Q?r    c                    U(       d  UR                   /$ US:  a  [        S5      eUS:X  d  U (       a  XR                   /:X  a  U $ UR                   /n US-  UpAUS-  (       a  [        X0U5      nU(       d   U$ [        X5      n M3  )z
Raise ``f`` to the ``n``-th power in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_pow(x - 2, 3)
x**3 - 6*x**2 + 12*x - 8

r   +Cannot raise polynomial to a negative powerr   r   )one
ValueErrorrx   r   )r   r   r   rj   r   s        r   dup_powr     s     w1uFGGAvQ!w,	
A
!tQ1q5a A H AM r    c                 @   U(       d  [        XU5      $ U(       d  [        X#5      $ US:  a  [        S5      eUS:X  d!  [        X5      (       d  [	        XU5      (       a  U $ [        X#5      n US-  UpQUS-  (       a  [        X@X#5      nU(       d   U$ [        XU5      n M4  )z
Raise ``f`` to the ``n``-th power in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_pow(x*y + 1, 3)
x**3*y**3 + 3*x**2*y**2 + 3*x*y + 1

r   r   r   r   )r   r   r   r
   r   r2   r   )r   r   r$   r   rj   r   s         r   dmp_powr     s     qQq}1uFGGAvA!!YqQ%7%7A
!tQ1q5a#A H A! r    c                    [        U 5      n[        U5      n/ XpvnU(       d  [        S5      eX4:  a  XV4$ X4-
  S-   n[        X5      n	 [        Xb5      n
Xt-
  US-
  p[        XYU5      n[	        XX5      n[        XiU5      n[        XX5      n[        XU5      nU[        U5      pXt:  a  OX:  d  [        XU5      eMt  X-  n[        UUU5      n[        UUU5      nXV4$ )z
Polynomial pseudo-division in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_pdiv(x**2 + 1, 2*x - 4)
(2*x + 4, 20)

rI   r   )r   rJ   r   rC   r   r0   ru   r   )r   rj   r   rk   rl   qrdrNlc_glc_rr   QRG_drr   s                    r   dup_pdivr     s     
AB	AB1"A 566	t
!A!<D
a|wA11A&!'1A&!'A!jmR7(*133! $ 	Aq!QAq!QA4Kr    c                 `   [        U 5      n[        U5      nXpeU(       d  [        S5      eX4:  a  U$ X4-
  S-   n[        X5      n [        XR5      n	Xd-
  US-
  pz[        XXU5      n[	        XX5      n[        XU5      nU[        U5      pmXd:  a  OXm:  d  [        XU5      eM\  [        XXU-  U5      $ )z
Polynomial pseudo-remainder in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_prem(x**2 + 1, 2*x - 4)
20

rI   r   )r   rJ   r   rC   r0   ru   r   )r   rj   r   rk   rl   r   r   r   r   r   r   r   r   r   s                 r   dup_premr     s     
AB	ABr 566	
!A!<D
a|wA11A&!'A!jmR7(*133  !1Wa((r    c                      [        XU5      S   $ )z
Polynomial exact pseudo-quotient in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_pquo(x**2 - 1, 2*x - 2)
2*x + 2

>>> R.dup_pquo(x**2 + 1, 2*x - 4)
2*x + 4

r   )r   r   rj   r   s      r   dup_pquor   J  s    " A!Qr    c                 F    [        XU5      u  p4U(       d  U$ [        X5      e)a,  
Polynomial pseudo-quotient in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_pexquo(x**2 - 1, 2*x - 2)
2*x + 2

>>> R.dup_pexquo(x**2 + 1, 2*x - 4)
Traceback (most recent call last):
...
ExactQuotientFailed: [2, -4] does not divide [1, 0, 1]

)r   r   r   rj   r   r   r   s        r   
dup_pexquor   ^  s%    & A!DA!!''r    c                    U(       d  [        XU5      $ [        X5      n[        X5      nUS:  a  [        S5      e[        U5      XpnXE:  a  Xg4$ XE-
  S-   n	[	        X5      n
 [	        Xs5      nX-
  U	S-
  p[        XjSX#5      n[        XXU5      n[        XzSX#5      n[        XXU5      n[        XX#5      nU[        Xr5      nnX:  a  OUU:  d  [        XU5      eMz  [        XUS-
  U5      n[        UUSX#5      n[        UUSX#5      nXg4$ )z
Polynomial pseudo-division in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_pdiv(x**2 + x*y, 2*x + 2)
(2*x + 2*y - 2, -4*y + 4)

r   rI   r   )
r   r   rJ   r   r   r3   r&   r*   r   r   )r   rj   r$   r   rk   rl   r   r   r   r   r   r   r   r   r   r   r   r   s                     r   dmp_pdivr   y  s/    a  	A	B	A	B	Av 566{A"A	wt
!A!<D
a|wA1!Q*!*!Q*!*A!j&R7s(*133! $ 	Q"AQ1a#AQ1a#A4Kr    c                    U(       d  [        XU5      $ [        X5      n[        X5      nUS:  a  [        S5      eXpvXE:  a  U$ XE-
  S-   n[        X5      n	 [        Xc5      n
Xu-
  US-
  p[	        XiSX#5      n[	        XXU5      n[        XX#5      nU[        Xb5      p~Xu:  a  OX~:  d  [        XU5      eM^  [        XUS-
  U5      n[	        XoSX#5      $ )z
Polynomial pseudo-remainder in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_prem(x**2 + x*y, 2*x + 2)
-4*y + 4

r   rI   r   )r   r   rJ   r   r3   r*   r   r   )r   rj   r$   r   rk   rl   r   r   r   r   r   r   r   r   r   r   s                   r   dmp_premr     s     a  	A	B	A	B	Av 566r	w
!A!<D
a|wA1!Q*!*A!j&R7(*133  	Q"Aa&&r    c                      [        XX#5      S   $ )z
Polynomial exact pseudo-quotient in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> f = x**2 + x*y
>>> g = 2*x + 2*y
>>> h = 2*x + 2

>>> R.dmp_pquo(f, g)
2*x

>>> R.dmp_pquo(f, h)
2*x + 2*y - 2

r   )r   r   rj   r$   r   s       r   dmp_pquor     s    * A!""r    c                 X    [        XX#5      u  pE[        XR5      (       a  U$ [        X5      e)aS  
Polynomial pseudo-quotient in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> f = x**2 + x*y
>>> g = 2*x + 2*y
>>> h = 2*x + 2

>>> R.dmp_pexquo(f, g)
2*x

>>> R.dmp_pexquo(f, h)
Traceback (most recent call last):
...
ExactQuotientFailed: [[2], [2]] does not divide [[1], [1, 0], []]

)r   r
   r   r   rj   r$   r   r   r   s         r   
dmp_pexquor     s-    . A!DA!!!''r    c                 t   [        U 5      n[        U5      n/ XpvnU(       d  [        S5      eX4:  a  XV4$ [        X5      n [        Xb5      n	X-  (       a   XV4$ UR                  X5      n
Xt-
  n[	        XZX5      n[        XX5      n[        XlU5      nU[        U5      p}Xt:  a   XV4$ X}:  d  [        XU5      eMy  )z
Univariate division with remainder over a ring.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_rr_div(x**2 + 1, 2*x - 4)
(0, x**2 + 1)

rI   )r   rJ   r   rQ   r   r0   ru   r   r   rj   r   rk   rl   r   r   r   r   r   r   r   rp   r   s                 r   
dup_rr_divr     s     
AB	AB1"A 566	t!<D
a|;  4K GGDGq$q$A!jmR7 4K (*133% r    c                    U(       d  [        XU5      $ [        X5      n[        X5      nUS:  a  [        S5      e[        U5      XpnXE:  a  Xg4$ [	        X5      US-
  p [	        Xs5      n[        XX5      u  p[        X5      (       d   Xg4$ X-
  n[        XlXU5      n[        XXU5      n[        XX#5      nU[        Xr5      nnX:  a   Xg4$ UU:  d  [        XU5      eM  )z
Multivariate division with remainder over a ring.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_rr_div(x**2 + x*y, 2*x + 2)
(0, x**2 + x*y)

r   rI   r   )r   r   rJ   r   r   
dmp_rr_divr
   r&   r3   r*   r   r   rj   r$   r   rk   rl   r   r   r   r   r%   r   r   r   r   rp   r   s                    r   r   r   M       !""	A	B	A	B	Av 566{A"A	wtQlAE!
a|$a+! 4K GqQ'qQ'A!j&R7 4K s(*133% r    c                    [        U 5      n[        U5      n/ XpvnU(       d  [        S5      eX4:  a  XV4$ [        X5      n [        Xb5      n	UR                  X5      n
Xt-
  n[	        XZX5      n[        XX5      n[        XlU5      nU[        U5      p}Xt:  a   XV4$ X}:X  a4  UR                  (       d#  [        USS 5      n[        U5      nXt:  a   XV4$ OX}:  d  [        XU5      eM  )z
Polynomial division with remainder over a field.

Examples
========

>>> from sympy.polys import ring, QQ
>>> R, x = ring("x", QQ)

>>> R.dup_ff_div(x**2 + 1, 2*x - 4)
(1/2*x + 1, 5)

rI   r   N)
r   rJ   r   rQ   r   r0   ru   r   r   r   r   s                 r   
dup_ff_divr     s     
AB	AB1"A 566	t!<D
a|GGDGq$q$A!jmR7 4K Yqzz!AB% AABw 4K (*133+ r    c                    U(       d  [        XU5      $ [        X5      n[        X5      nUS:  a  [        S5      e[        U5      XpnXE:  a  Xg4$ [	        X5      US-
  p [	        Xs5      n[        XX5      u  p[        X5      (       d   Xg4$ X-
  n[        XlXU5      n[        XXU5      n[        XX#5      nU[        Xr5      nnX:  a   Xg4$ UU:  d  [        XU5      eM  )z
Polynomial division with remainder over a field.

Examples
========

>>> from sympy.polys import ring, QQ
>>> R, x,y = ring("x,y", QQ)

>>> R.dmp_ff_div(x**2 + x*y, 2*x + 2)
(1/2*x + 1/2*y - 1/2, -y + 1)

r   rI   r   )r   r   rJ   r   r   
dmp_ff_divr
   r&   r3   r*   r   r   s                    r   r   r     r   r    c                 T    UR                   (       a  [        XU5      $ [        XU5      $ )a  
Polynomial division with remainder in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ, QQ

>>> R, x = ring("x", ZZ)
>>> R.dup_div(x**2 + 1, 2*x - 4)
(0, x**2 + 1)

>>> R, x = ring("x", QQ)
>>> R.dup_div(x**2 + 1, 2*x - 4)
(1/2*x + 1, 5)

)rK   r   r   r   s      r   dup_divr     s%    $ 	zz!""!""r    c                      [        XU5      S   $ )z
Returns polynomial remainder in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ, QQ

>>> R, x = ring("x", ZZ)
>>> R.dup_rem(x**2 + 1, 2*x - 4)
x**2 + 1

>>> R, x = ring("x", QQ)
>>> R.dup_rem(x**2 + 1, 2*x - 4)
5

r   r   r   s      r   dup_remr         $ 1Ar    c                      [        XU5      S   $ )z
Returns exact polynomial quotient in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ, QQ

>>> R, x = ring("x", ZZ)
>>> R.dup_quo(x**2 + 1, 2*x - 4)
0

>>> R, x = ring("x", QQ)
>>> R.dup_quo(x**2 + 1, 2*x - 4)
1/2*x + 1

r   r   r   s      r   dup_quor     r   r    c                 F    [        XU5      u  p4U(       d  U$ [        X5      e)a'  
Returns polynomial quotient in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_exquo(x**2 - 1, x - 1)
x + 1

>>> R.dup_exquo(x**2 + 1, 2*x - 4)
Traceback (most recent call last):
...
ExactQuotientFailed: [2, -4] does not divide [1, 0, 1]

)r   r   r   s        r   	dup_exquor   -  s%    & 1DA!!''r    c                 T    UR                   (       a  [        XX#5      $ [        XX#5      $ )a  
Polynomial division with remainder in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ, QQ

>>> R, x,y = ring("x,y", ZZ)
>>> R.dmp_div(x**2 + x*y, 2*x + 2)
(0, x**2 + x*y)

>>> R, x,y = ring("x,y", QQ)
>>> R.dmp_div(x**2 + x*y, 2*x + 2)
(1/2*x + 1/2*y - 1/2, -y + 1)

)rK   r   r   r   s       r   dmp_divr   H  s%    $ 	zz!%%!%%r    c                      [        XX#5      S   $ )z
Returns polynomial remainder in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ, QQ

>>> R, x,y = ring("x,y", ZZ)
>>> R.dmp_rem(x**2 + x*y, 2*x + 2)
x**2 + x*y

>>> R, x,y = ring("x,y", QQ)
>>> R.dmp_rem(x**2 + x*y, 2*x + 2)
-y + 1

r   r   r   s       r   dmp_remr   `      $ 1q!!r    c                      [        XX#5      S   $ )a  
Returns exact polynomial quotient in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ, QQ

>>> R, x,y = ring("x,y", ZZ)
>>> R.dmp_quo(x**2 + x*y, 2*x + 2)
0

>>> R, x,y = ring("x,y", QQ)
>>> R.dmp_quo(x**2 + x*y, 2*x + 2)
1/2*x + 1/2*y - 1/2

r   r   r   s       r   dmp_quor   u  r   r    c                 X    [        XX#5      u  pE[        XR5      (       a  U$ [        X5      e)aL  
Returns polynomial quotient in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> f = x**2 + x*y
>>> g = x + y
>>> h = 2*x + 2

>>> R.dmp_exquo(f, g)
x

>>> R.dmp_exquo(f, h)
Traceback (most recent call last):
...
ExactQuotientFailed: [[2], [2]] does not divide [[1], [1, 0], []]

)r   r
   r   r   s         r   	dmp_exquor     s-    . 1DA!!!''r    c                 P    U (       d  UR                   $ [        [        X5      5      $ )z
Returns maximum norm of a polynomial in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_max_norm(-x**2 + 2*x - 3)
3

)r   r   r^   r   r   s     r   dup_max_normr          vv71=!!r    c                 b   ^^ U(       d  [        U T5      $ US-
  m[        UU4S jU  5       5      $ )z
Returns maximum norm of a polynomial in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_max_norm(2*x*y - x - 3)
3

r   c              3   >   >#    U  H  n[        UTT5      v   M     g 7fN)dmp_max_norm.0r   r   r%   s     r   	<genexpr>dmp_max_norm.<locals>.<genexpr>  s     0a|Aq!$$a   )r   r   r   r$   r   r%   s     `@r   r   r     s/     Aq!!	AA0a000r    c                 P    U (       d  UR                   $ [        [        X5      5      $ )z
Returns l1 norm of a polynomial in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_l1_norm(2*x**3 - 3*x**2 + 1)
6

)r   sumr^   r   s     r   dup_l1_normr     r   r    c                 b   ^^ U(       d  [        U T5      $ US-
  m[        UU4S jU  5       5      $ )z
Returns l1 norm of a polynomial in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_l1_norm(2*x*y - x - 3)
6

r   c              3   >   >#    U  H  n[        UTT5      v   M     g 7fr   )dmp_l1_normr   s     r   r   dmp_l1_norm.<locals>.<genexpr>  s     /Q{1a##Qr   )r   r   r   s     `@r   r   r     s/     1a  	AA/Q///r    c                 ^    [        U  Vs/ s H  o"S-  PM	     snUR                  5      $ s  snf )z
Returns squared l2 norm of a polynomial in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_l2_norm_squared(2*x**3 - 3*x**2 + 1)
14

r   )r   r   r\   s      r   dup_l2_norm_squaredr     s)     a(aUqa(!&&11(s   *c                 b   ^^ U(       d  [        U T5      $ US-
  m[        UU4S jU  5       5      $ )z
Returns squared l2 norm of a polynomial in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_l2_norm_squared(2*x*y - x - 3)
14

r   c              3   >   >#    U  H  n[        UTT5      v   M     g 7fr   )dmp_l2_norm_squaredr   s     r   r   &dmp_l2_norm_squared.<locals>.<genexpr>!  s     7Q"1a++Qr   )r   r   r   s     `@r   r   r     s/     "1a((	AA7Q777r    c                 h    U (       d  UR                   /$ U S   nU SS  H  n[        X#U5      nM     U$ )z
Multiply together several polynomials in ``K[x]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)

>>> R.dup_expand([x**2 - 1, x, 2])
2*x**3 - 2*x

r   r   N)r   rx   )polysr   r   rj   s       r   
dup_expandr   $  s>     waA12YA!  Hr    c                 d    U (       d  [        X5      $ U S   nU SS  H  n[        X4X5      nM     U$ )z
Multiply together several polynomials in ``K[X]``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> R.dmp_expand([x**2 + y**2, x + 1])
x**3 + x**2 + x*y**2 + y**2

r   r   N)r   r2   )r   r$   r   r   rj   s        r   
dmp_expandr   =  s=     q}aA12YA!  Hr    N)R__doc__sympy.polys.densebasicr   r   r   r   r   r   r	   r
   r   r   r   r   r   sympy.polys.polyerrorsr   r   r   r&   r(   r,   r0   r3   r6   r:   r=   r?   rC   rE   rM   rO   rR   rT   rW   rY   r^   r`   re   r+   rq   r"   ru   r*   rz   r~   r   r   rx   r2   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rA   r    r   <module>r     s{   K    S2:@D2:@D3(I6$":"$":"&(7,':74*,9,(&+"-,%"-, 3F'AT 3F'AT+"1"+"1"63r(V%P-`"J%P2j*)Z ((66r0'f#0(>.b2j1h2j#0**(6&0"*"*(>"(1,"(0,2"8,2r    