+
    iL                    L   R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt  ! R R]4      t ! R R]4      t ! R R]4      t ! R R4      t ! R R]]4      t]! 4       ;t]n         ! R R]]4      t]! 4       ;t]n        R# )zDomains of Gaussian type.)annotations)I)DMP)CoercionFailed)ZZ)QQ)AlgebraicField)Domain)DomainElement)Field)Ringc                     a  ] tR t^t$ RtR]R&   R]R&   RtRR lt]V 3R l4       t	R t
R tR	 tR
 tR tR tR tR t]R 4       tR t]tR tR tR t]tR tR tR tR tR tR tR tR t R t!Rt"V ;t## ) GaussianElementz1Base class for elements of Gaussian type domains.r	   base_parentc                	j    V P                   P                  pV P                  V! V4      V! V4      4      # N)r   convertnew)clsxyconvs   &&& ڃ/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/polys/domains/gaussiandomains.py__new__GaussianElement.__new__   s*    xxwwtAwQ((    c                >   < \         SV `  V 4      pWn        W#n        V# )z0Create a new GaussianElement of the same domain.)superr   r   r   )r   r   r   obj	__class__s   &&& r   r   GaussianElement.new   s"     goc"
r   c                    V P                   # )z4The domain that this is an element of (ZZ_I or QQ_I))r   selfs   &r   parentGaussianElement.parent#   s    ||r   c                	D    \        V P                  V P                  34      # r   )hashr   r   r#   s   &r   __hash__GaussianElement.__hash__'   s    TVVTVV$%%r   c                	    \        WP                  4      '       d;   V P                  VP                  8H  ;'       d    V P                  VP                  8H  # \        # r   )
isinstancer    r   r   NotImplementedr$   others   &&r   __eq__GaussianElement.__eq__*   s?    e^^,,66UWW$::577)::!!r   c                	    \        V\        4      '       g   \        # V P                  V P                  .VP                  VP                  .8  # r   )r,   r   r-   r   r   r.   s   &&r   __lt__GaussianElement.__lt__0   s:    %11!!577EGG"444r   c                	    V # r    r#   s   &r   __pos__GaussianElement.__pos__5   s    r   c                	R    V P                  V P                  ) V P                  ) 4      # r   r   r   r   r#   s   &r   __neg__GaussianElement.__neg__8   s    xx$&&))r   c                	n    V P                   P                  : R V P                  : RV P                  : R2# )(z, ))r   repr   r   r#   s   &r   __repr__GaussianElement.__repr__;   s!    #||//@@r   c                	J    \        V P                  P                  V 4      4      # r   )strr   to_sympyr#   s   &r   __str__GaussianElement.__str__>   s    4<<((.//r   c                	    \        W4      '       g    V P                  P                  V4      pVP                  VP
                  3#   \         d    Ru # i ; i)N)NN)r,   r   r   r   r   r   )r   r/   s   &&r   _get_xyGaussianElement._get_xyA   sR    %%%"++E2 ww " "!!"s   A AAc                	    V P                  V4      w  r#Ve5   V P                  V P                  V,           V P                  V,           4      # \        # r   rI   r   r   r   r-   r$   r/   r   r   s   &&  r   __add__GaussianElement.__add__J   >    ||E"=88DFFQJ
33!!r   c                	    V P                  V4      w  r#Ve5   V P                  V P                  V,
          V P                  V,
          4      # \        # r   rL   rM   s   &&  r   __sub__GaussianElement.__sub__S   rP   r   c                	    V P                  V4      w  r#Ve3   V P                  W P                  ,
          W0P                  ,
          4      # \        # r   rL   rM   s   &&  r   __rsub__GaussianElement.__rsub__Z   s:    ||E"=88AJFF
33!!r   c                	   V P                  V4      w  r#Vee   V P                  V P                  V,          V P                  V,          ,
          V P                  V,          V P                  V,          ,           4      # \        # r   rL   rM   s   &&  r   __mul__GaussianElement.__mul__a   sX    ||E"=88DFF1Htvvax/DFF1H1DEE!!r   c                	6   V^ 8X  d   V P                  ^^ 4      # V^ 8  d   ^V ,          V) rV^8X  d   V # T pV^,          '       d   T MV P                  P                  pV^,          pV'       d+   W",          pV^,          '       d	   W2,          pV^,          pK2  V#     )r   r   one)r$   exppow2prods   &&  r   __pow__GaussianElement.__pow__j   s    !888Aq>!7$#!8KQwwtDLL$4$4	LDQwwAICr   c                	f    \        V P                  4      ;'       g    \        V P                  4      # r   )boolr   r   r#   s   &r   __bool__GaussianElement.__bool__{   s     DFF|++tDFF|+r   c                    V P                   ^ 8  d   V P                  ^ 8  d   ^ # ^# V P                   ^ 8  d   V P                  ^ 8  d   ^# ^# V P                  ^ 8  d   ^ # ^# )z9Return quadrant index 0-3.

0 is included in quadrant 0.
)r   r   r#   s   &r   quadrantGaussianElement.quadrant~   sY    
 66A:
1))VVaZ
1))!1**r   c                	     V P                   P                  V4      pVP                  V 4      #   \         d
    \        u # i ; ir   )r   r   
__divmod__r   r-   r.   s   &&r   __rdivmod__GaussianElement.__rdivmod__   sE    	*LL((/E ##D))  	"!!	"s   . AAc                	~     \         P                  V4      pVP                  V 4      #   \         d
    \        u # i ; ir   )QQ_Ir   __truediv__r   r-   r.   s   &&r   __rtruediv__GaussianElement.__rtruediv__   s?    	+LL'E $$T**  	"!!	"s   ( <<c                	N    V P                  V4      pV\        J d   V# V^ ,          # r[   rk   r-   r$   r/   qrs   && r   __floordiv__GaussianElement.__floordiv__   &    __U#>)r4r!u4r   c                	N    V P                  V4      pV\        J d   V# V^ ,          # r[   rl   r-   ru   s   && r   __rfloordiv__GaussianElement.__rfloordiv__   (    e$>)r4r!u4r   c                	N    V P                  V4      pV\        J d   V# V^,          #    rt   ru   s   && r   __mod__GaussianElement.__mod__   ry   r   c                	N    V P                  V4      pV\        J d   V# V^,          # r   r{   ru   s   && r   __rmod__GaussianElement.__rmod__   r~   r   r6   )r   r   r[   )$__name__
__module____qualname____firstlineno____doc____annotations__	__slots__r   classmethodr   r%   r)   r0   r3   r7   r;   rA   rF   rI   rN   __radd__rR   rU   rX   __rmul__ra   re   rh   rl   rq   rw   r|   r   r   __static_attributes____classcell__)r    s   @r   r   r      s    ;
LOI)  &"5
*A0    " H""" H",
+*+5555 5r   r   c                  *    ] tR t^tRt]tR tR tRt	R# )GaussianIntegerzGaussian integer: domain element for :ref:`ZZ_I`

>>> from sympy import ZZ_I
>>> z = ZZ_I(2, 3)
>>> z
(2 + 3*I)
>>> type(z)
<class 'sympy.polys.domains.gaussiandomains.GaussianInteger'>
c                :    \         P                  V 4      V,          # )Return a Gaussian rational.)ro   r   r.   s   &&r   rp   GaussianInteger.__truediv__   s    ||D!%''r   c                	   V'       g   \        R P                  V 4      4      hV P                  V4      w  r#Vf   \        # V P                  V,          V P
                  V,          ,           V P                  ) V,          V P
                  V,          ,           rTW",          W3,          ,           p^V,          V,           ^V,          ,          p^V,          V,           ^V,          ,          p\        Wx4      p	WW,          ,
          3# )zdivmod({}, 0))ZeroDivisionErrorformatrI   r-   r   r   r   )
r$   r/   r   r   abcqxqyqs
   &&        r   rk   GaussianInteger.__divmod__   s    #O$:$:4$@AA||E"9!! vvax$&&("TVVGAIq$81C!#I cAg1Q3cAg1Q3B# .  r   r6   N)
r   r   r   r   r   r   r   rp   rk   r   r6   r   r   r   r      s     D(!r   r   c                  *    ] tR t^tRt]tR tR tRt	R# )GaussianRationalzGaussian rational: domain element for :ref:`QQ_I`

>>> from sympy import QQ_I, QQ
>>> z = QQ_I(QQ(2, 3), QQ(4, 5))
>>> z
(2/3 + 4/5*I)
>>> type(z)
<class 'sympy.polys.domains.gaussiandomains.GaussianRational'>
c                   V'       g   \        RP                  V 4      4      hV P                  V4      w  r#Vf   \        # W",          W3,          ,           p\	        V P
                  V,          V P                  V,          ,           V,          V P
                  ) V,          V P                  V,          ,           V,          4      # )r   z{} / 0)r   r   rI   r-   r   r   r   )r$   r/   r   r   r   s   &&   r   rp   GaussianRational.__truediv__   s    #HOOD$9::||E"9!!C!#IDFF1H!4a 7"&&&TVVAX!5q 8: 	:r   c                	     V P                   P                  V4      pT'       g   \	        R P                  T 4      4      hY,          \        P                  3#   \         d
    \        u # i ; i)z{} % 0)r   r   r   r-   r   r   ro   zeror.   s   &&r   rk   GaussianRational.__divmod__   s\    	"LL((/E #HOOD$9:::tyy((  	"!!	"s   A A+*A+r6   N)
r   r   r   r   r   r   r   rp   rk   r   r6   r   r   r   r      s     D
:)r   r   c                      ] tR t^t$ RtR]R&   RtRtRtRt	R t
R tR tR tR	 tR
 tR tR tR tR tR tR tR tR tR tRtR# )GaussianDomainz Base class for Gaussian domains.r	   domTc                    V P                   P                  pV! VP                  4      \        V! VP                  4      ,          ,           # )z!Convert ``a`` to a SymPy object. )r   rE   r   r   r   )r$   r   r   s   && r   rE   GaussianDomain.to_sympy   s0    xx  ACCy1T!##Y;&&r   c                T   VP                  4       w  r#V P                  P                  V4      pV'       g   V P                  V^ 4      # VP	                  4       w  r#V P                  P                  V4      pV\
        J d   V P                  WE4      # \        RP                  V4      4      h)z)Convert a SymPy object to ``self.dtype``.z{} is not Gaussian)as_coeff_Addr   
from_sympyr   as_coeff_Mulr   r   r   )r$   r   rr   r   r   s   &&    r   r   GaussianDomain.from_sympy  s    ~~HH"88Aq>!~~HH"688A>! !5!<!<Q!?@@r   c                "    V P                   ! V!  # )z$Inject generators into this domain. )	poly_ring)r$   genss   &*r   injectGaussianDomain.inject  s    ~~t$$r   c                	J    V P                   VP                  4       ) ,          pV# r   )unitsrh   )r$   dunits   && r   canonical_unitGaussianDomain.canonical_unit  s    zz1::<-(r   c                    R# z/Returns ``False`` for any ``GaussianElement``. Fr6   r$   elements   &&r   is_negativeGaussianDomain.is_negative      r   c                    R# r   r6   r   s   &&r   is_positiveGaussianDomain.is_positive  r   r   c                    R# r   r6   r   s   &&r   is_nonnegativeGaussianDomain.is_nonnegative"  r   r   c                    R# r   r6   r   s   &&r   is_nonpositiveGaussianDomain.is_nonpositive&  r   r   c                    V ! V4      # )z%Convert a GMPY mpz to ``self.dtype``.r6   K1r   K0s   &&&r   from_ZZ_gmpyGaussianDomain.from_ZZ_gmpy*      !ur   c                    V ! V4      # z.Convert a ZZ_python element to ``self.dtype``.r6   r   s   &&&r   from_ZZGaussianDomain.from_ZZ.  r   r   c                    V ! V4      # r   r6   r   s   &&&r   from_ZZ_pythonGaussianDomain.from_ZZ_python2  r   r   c                    V ! V4      # z%Convert a GMPY mpq to ``self.dtype``.r6   r   s   &&&r   from_QQGaussianDomain.from_QQ6  r   r   c                    V ! V4      # r   r6   r   s   &&&r   from_QQ_gmpyGaussianDomain.from_QQ_gmpy:  r   r   c                    V ! V4      # )z.Convert a QQ_python element to ``self.dtype``.r6   r   s   &&&r   from_QQ_pythonGaussianDomain.from_QQ_python>  r   r   c                    VP                   P                  ^ ,          \        8X  d!   V P                  VP	                  V4      4      # R# )z9Convert an element from ZZ<I> or QQ<I> to ``self.dtype``.N)extargsr   r   rE   r   s   &&&r   from_AlgebraicField"GaussianDomain.from_AlgebraicFieldB  s2    66;;q>Q==Q00 r   r6   N)r   r   r   r   r   r   is_Numericalis_Exacthas_assoc_Ringhas_assoc_FieldrE   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r6   r   r   r   r      sj    *	KLHNO'
A%1r   r   c                  l   ] tR tRtRt]t]! ]P                  ]P                  ]P                  .]4      t
]t]! ]! ^ 4      ]! ^ 4      4      t	]! ]! ^4      ]! ^ 4      4      t]! ]! ^ 4      ]! ^4      4      t]]]) ]) 3tRtRtRtRtR tR tR t]R 4       tR	 tR
 tR tR tR tR tR tR tR t Rt!R# )GaussianIntegerRingiH  a?	  Ring of Gaussian integers ``ZZ_I``

The :ref:`ZZ_I` domain represents the `Gaussian integers`_ `\mathbb{Z}[i]`
as a :py:class:`~.Domain` in the domain system (see
:ref:`polys-domainsintro`).

By default a :py:class:`~.Poly` created from an expression with
coefficients that are combinations of integers and ``I`` (`\sqrt{-1}`)
will have the domain :ref:`ZZ_I`.

>>> from sympy import Poly, Symbol, I
>>> x = Symbol('x')
>>> p = Poly(x**2 + I)
>>> p
Poly(x**2 + I, x, domain='ZZ_I')
>>> p.domain
ZZ_I

The :ref:`ZZ_I` domain can be used to factorise polynomials that are
reducible over the Gaussian integers.

>>> from sympy import factor
>>> factor(x**2 + 1)
x**2 + 1
>>> factor(x**2 + 1, domain='ZZ_I')
(x - I)*(x + I)

The corresponding `field of fractions`_ is the domain of the Gaussian
rationals :ref:`QQ_I`. Conversely :ref:`ZZ_I` is the `ring of integers`_
of :ref:`QQ_I`.

>>> from sympy import ZZ_I, QQ_I
>>> ZZ_I.get_field()
QQ_I
>>> QQ_I.get_ring()
ZZ_I

When using the domain directly :ref:`ZZ_I` can be used as a constructor.

>>> ZZ_I(3, 4)
(3 + 4*I)
>>> ZZ_I(5)
(5 + 0*I)

The domain elements of :ref:`ZZ_I` are instances of
:py:class:`~.GaussianInteger` which support the rings operations
``+,-,*,**``.

>>> z1 = ZZ_I(5, 1)
>>> z2 = ZZ_I(2, 3)
>>> z1
(5 + 1*I)
>>> z2
(2 + 3*I)
>>> z1 + z2
(7 + 4*I)
>>> z1 * z2
(7 + 17*I)
>>> z1 ** 2
(24 + 10*I)

Both floor (``//``) and modulo (``%``) division work with
:py:class:`~.GaussianInteger` (see the :py:meth:`~.Domain.div` method).

>>> z3, z4 = ZZ_I(5), ZZ_I(1, 3)
>>> z3 // z4  # floor division
(1 + -1*I)
>>> z3 % z4   # modulo division (remainder)
(1 + -2*I)
>>> (z3//z4)*z4 + z3%z4 == z3
True

True division (``/``) in :ref:`ZZ_I` gives an element of :ref:`QQ_I`. The
:py:meth:`~.Domain.exquo` method can be used to divide in :ref:`ZZ_I` when
exact division is possible.

>>> z1 / z2
(1 + -1*I)
>>> ZZ_I.exquo(z1, z2)
(1 + -1*I)
>>> z3 / z4
(1/2 + -3/2*I)
>>> ZZ_I.exquo(z3, z4)
Traceback (most recent call last):
    ...
ExactQuotientFailed: (1 + 3*I) does not divide (5 + 0*I) in ZZ_I

The :py:meth:`~.Domain.gcd` method can be used to compute the `gcd`_ of any
two elements.

>>> ZZ_I.gcd(ZZ_I(10), ZZ_I(2))
(2 + 0*I)
>>> ZZ_I.gcd(ZZ_I(5), ZZ_I(2, 1))
(2 + 1*I)

.. _Gaussian integers: https://en.wikipedia.org/wiki/Gaussian_integer
.. _gcd: https://en.wikipedia.org/wiki/Greatest_common_divisor

ZZ_ITc                    R# )zFor constructing ZZ_I.Nr6   r#   s   &r   __init__GaussianIntegerRing.__init__      r   c                >    \        V\        4      '       d   R# \        # z0Returns ``True`` if two domains are equivalent. T)r,   r   r-   r.   s   &&r   r0   GaussianIntegerRing.__eq__  s    e011!!r   c                    \        R4      # )Compute hash code of ``self``. r   r(   r#   s   &r   r)   GaussianIntegerRing.__hash__      F|r   c                	    R # Tr6   r#   s   &r   has_CharacteristicZero*GaussianIntegerRing.has_CharacteristicZero      r   c                	    ^ # r[   r6   r#   s   &r   characteristic"GaussianIntegerRing.characteristic      r   c                    V # z)Returns a ring associated with ``self``. r6   r#   s   &r   get_ringGaussianIntegerRing.get_ring      r   c                    \         # z*Returns a field associated with ``self``. )ro   r#   s   &r   	get_fieldGaussianIntegerRing.get_field      r   c                   a V P                  V4      oVS,          p\        ;QJ d    . V3R lV 4       F  NK  	  5M! V3R lV 4       4      pV'       d   V3V,           # T# )zpReturn first quadrant element associated with ``d``.

Also multiply the other arguments by the same power of i.
c              3  4   <"   T F  qS,          x  K  	  R # 5ir   r6   ).0r   r   s   & r   	<genexpr>0GaussianIntegerRing.normalize.<locals>.<genexpr>  s     *TtVVTs   )r   tuple)r$   r   r   r   s   &&*@r   	normalizeGaussianIntegerRing.normalize  sO    
 ""1%	T	u*T*uu*T**"td{))r   c                J    V'       d   Y!V,          r!K  V P                  V4      # )z-Greatest common divisor of a and b over ZZ_I.)r  r$   r   r   s   &&&r   gcdGaussianIntegerRing.gcd  s    !eq~~a  r   c                   V P                   pV P                  pV P                  pV P                   pV'       d8   W,          pY!Wr,          ,
          r!YCWt,          ,
          rCYeWv,          ,
          reK?  V P                  WV4      w  rpW5V3# )z6Return x, y, g such that x * a + y * b = g = gcd(a, b))r]   r   r  )r$   r   r   x_ax_by_ay_br   s   &&&     r   gcdexGaussianIntegerRing.gcdex  so    hhiiiihhA!%iq!'M!'MnnQS1{r   c                >    W,          V P                  W4      ,          # )z+Least common multiple of a and b over ZZ_I.)r  r  s   &&&r   lcmGaussianIntegerRing.lcm  s    $((1.((r   c                    V# )zConvert a ZZ_I element to ZZ_I.r6   r   s   &&&r   from_GaussianIntegerRing,GaussianIntegerRing.from_GaussianIntegerRing      r   c                    V P                  \        P                  ! VP                  4      \        P                  ! VP                  4      4      # )zConvert a QQ_I element to ZZ_I.)r   r   r   r   r   r   s   &&&r   from_GaussianRationalField.GaussianIntegerRing.from_GaussianRationalField  s+    vvbjjorzz!##77r   r6   N)"r   r   r   r   r   r   r   r   r]   r   modr   dtype	imag_unitr   r@   is_GaussianRingis_ZZ_Iis_PIDr   r0   r)   propertyr  r  r
  r  r  r  r#  r&  r)  r-  r   r6   r   r   r   r   H  s    bF C
rvvrww'
,CEA1D
1r!u
CbeRU#I)cTI:.E
COGF%"  *!)8r   r   c                  h   ] tR tRtRt]t]! ]P                  ]P                  ]P                  .]4      t
]t]! ]! ^ 4      ]! ^ 4      4      t	]! ]! ^4      ]! ^ 4      4      t]! ]! ^ 4      ]! ^4      4      t]]]) ]) 3tRtRtRtR tR tR t]R 4       tR	 tR
 tR tR tR tR tR tR tR tRt R# )GaussianRationalFieldi  a  Field of Gaussian rationals ``QQ_I``

The :ref:`QQ_I` domain represents the `Gaussian rationals`_ `\mathbb{Q}(i)`
as a :py:class:`~.Domain` in the domain system (see
:ref:`polys-domainsintro`).

By default a :py:class:`~.Poly` created from an expression with
coefficients that are combinations of rationals and ``I`` (`\sqrt{-1}`)
will have the domain :ref:`QQ_I`.

>>> from sympy import Poly, Symbol, I
>>> x = Symbol('x')
>>> p = Poly(x**2 + I/2)
>>> p
Poly(x**2 + I/2, x, domain='QQ_I')
>>> p.domain
QQ_I

The polys option ``gaussian=True`` can be used to specify that the domain
should be :ref:`QQ_I` even if the coefficients do not contain ``I`` or are
all integers.

>>> Poly(x**2)
Poly(x**2, x, domain='ZZ')
>>> Poly(x**2 + I)
Poly(x**2 + I, x, domain='ZZ_I')
>>> Poly(x**2/2)
Poly(1/2*x**2, x, domain='QQ')
>>> Poly(x**2, gaussian=True)
Poly(x**2, x, domain='QQ_I')
>>> Poly(x**2 + I, gaussian=True)
Poly(x**2 + I, x, domain='QQ_I')
>>> Poly(x**2/2, gaussian=True)
Poly(1/2*x**2, x, domain='QQ_I')

The :ref:`QQ_I` domain can be used to factorise polynomials that are
reducible over the Gaussian rationals.

>>> from sympy import factor, QQ_I
>>> factor(x**2/4 + 1)
(x**2 + 4)/4
>>> factor(x**2/4 + 1, domain='QQ_I')
(x - 2*I)*(x + 2*I)/4
>>> factor(x**2/4 + 1, domain=QQ_I)
(x - 2*I)*(x + 2*I)/4

It is also possible to specify the :ref:`QQ_I` domain explicitly with
polys functions like :py:func:`~.apart`.

>>> from sympy import apart
>>> apart(1/(1 + x**2))
1/(x**2 + 1)
>>> apart(1/(1 + x**2), domain=QQ_I)
I/(2*(x + I)) - I/(2*(x - I))

The corresponding `ring of integers`_ is the domain of the Gaussian
integers :ref:`ZZ_I`. Conversely :ref:`QQ_I` is the `field of fractions`_
of :ref:`ZZ_I`.

>>> from sympy import ZZ_I, QQ_I, QQ
>>> ZZ_I.get_field()
QQ_I
>>> QQ_I.get_ring()
ZZ_I

When using the domain directly :ref:`QQ_I` can be used as a constructor.

>>> QQ_I(3, 4)
(3 + 4*I)
>>> QQ_I(5)
(5 + 0*I)
>>> QQ_I(QQ(2, 3), QQ(4, 5))
(2/3 + 4/5*I)

The domain elements of :ref:`QQ_I` are instances of
:py:class:`~.GaussianRational` which support the field operations
``+,-,*,**,/``.

>>> z1 = QQ_I(5, 1)
>>> z2 = QQ_I(2, QQ(1, 2))
>>> z1
(5 + 1*I)
>>> z2
(2 + 1/2*I)
>>> z1 + z2
(7 + 3/2*I)
>>> z1 * z2
(19/2 + 9/2*I)
>>> z2 ** 2
(15/4 + 2*I)

True division (``/``) in :ref:`QQ_I` gives an element of :ref:`QQ_I` and
is always exact.

>>> z1 / z2
(42/17 + -2/17*I)
>>> QQ_I.exquo(z1, z2)
(42/17 + -2/17*I)
>>> z1 == (z1/z2)*z2
True

Both floor (``//``) and modulo (``%``) division can be used with
:py:class:`~.GaussianRational` (see :py:meth:`~.Domain.div`)
but division is always exact so there is no remainder.

>>> z1 // z2
(42/17 + -2/17*I)
>>> z1 % z2
(0 + 0*I)
>>> QQ_I.div(z1, z2)
((42/17 + -2/17*I), (0 + 0*I))
>>> (z1//z2)*z2 + z1%z2 == z1
True

.. _Gaussian rationals: https://en.wikipedia.org/wiki/Gaussian_rational
ro   Tc                    R# )zFor constructing QQ_I.Nr6   r#   s   &r   r   GaussianRationalField.__init__  r   r   c                >    \        V\        4      '       d   R# \        # r   )r,   r7  r-   r.   s   &&r   r0   GaussianRationalField.__eq__  s    e233!!r   c                    \        R4      # )r   ro   r   r#   s   &r   r)   GaussianRationalField.__hash__  r   r   c                	    R # r   r6   r#   s   &r   r  ,GaussianRationalField.has_CharacteristicZero  r  r   c                	    ^ # r[   r6   r#   s   &r   r  $GaussianRationalField.characteristic  r  r   c                    \         # r	  )r   r#   s   &r   r
  GaussianRationalField.get_ring  r  r   c                    V # r  r6   r#   s   &r   r  GaussianRationalField.get_field  r  r   c                6    \        V P                  \        4      # )z0Get equivalent domain as an ``AlgebraicField``. )r   r   r   r#   s   &r   as_AlgebraicField'GaussianRationalField.as_AlgebraicField  s    dhh**r   c                n    V P                  4       pVP                  WP                  V4      ,          4      # )zGet the numerator of ``a``.)r
  r   denom)r$   r   r   s   && r   numerGaussianRationalField.numer  s'    }}||A

1-..r   c                    V P                   P                  4       pV P                   pV P                  4       pVP                  ! VP                  ! VP                  4      VP                  ! VP
                  4      4      pV! WRP                  4      # )zGet the denominator of ``a``.)r   r
  r&  rJ  r   r   r   )r$   r   r   r   r   denom_ZZs   &&    r   rJ  GaussianRationalField.denom  s_    XX XX}}66"((133-!##7Hgg&&r   c                N    V P                  VP                  VP                  4      # )zConvert a ZZ_I element to QQ_I.r:   r   s   &&&r   r)  .GaussianRationalField.from_GaussianIntegerRing  s    vvacc133r   c                    V# )zConvert a QQ_I element to QQ_I.r6   r   s   &&&r   r-  0GaussianRationalField.from_GaussianRationalField  r+  r   c                    V P                  \        P                  ! VP                  4      \        P                  ! VP                  4      4      # )z'Convert a ComplexField element to QQ_I.)r   r   r   realimagr   s   &&&r   from_ComplexField'GaussianRationalField.from_ComplexField  s-    vvbjj("**QVV*<==r   r6   N)!r   r   r   r   r   r   r   r   r]   r   r/  r   r0  r1  r   r@   is_GaussianFieldis_QQ_Ir   r0   r)   r5  r  r  r
  r  rG  rK  rJ  r)  r-  rW  r   r6   r   r   r7  r7    s    sh C
rvvrww'
,CEA1D
1r!u
CbeRU#I)cTI:.E
CG%"  +/
' >r   r7  N) r   
__future__r   sympy.core.numbersr   sympy.polys.polyclassesr   sympy.polys.polyerrorsr   sympy.polys.domains.integerringr   !sympy.polys.domains.rationalfieldr   "sympy.polys.domains.algebraicfieldr   sympy.polys.domains.domainr	   !sympy.polys.domains.domainelementr
   sympy.polys.domains.fieldr   sympy.polys.domains.ringr   r   r   r   r   r   r   r   r7  ro   r6   r   r   <module>rf     s     "   ' 1 . 0 = - ; + )X5m X5v%!o %!P )  )FO1 O1dx8.$ x8t "5!6 6z>NE z>z #8"9 9r   