§
    OŠtj’Ÿ  ã                  óÚ   — d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ dd
lmZmZmZ ddlmZmZ ddlmZ ddlmZ e G d„ d¦  «        ¦   «         ZdgZdS )z)Implementation of :class:`Domain` class. é    )Úannotations)ÚAny)ÚAlgebraicNumber)ÚBasicÚsympify)Úordered)ÚGROUND_TYPES)ÚDomainElement)Úlex)ÚUnificationFailedÚCoercionFailedÚDomainError)Ú_unify_gensÚ_not_a_coeff)Úpublic)Úis_sequencec                  ó2  — e Zd ZU dZdZded<   	 dZded<   	 dZded<   	 dZ	 dZ		 dZ
	 dZ	 dxZZdxZZdxZZdxZZdxZZdxZZdxZZdxZZdxZZdxZZdxZ Z!dxZ"Z#dZ$d	Z%dZ&dZ'dZ(dZ)	 dZ*dZ+d
ed<   dZ,d
ed<   d„ Z-d„ Z.d„ Z/d„ Z0d„ Z1e2d„ ¦   «         Z3d„ Z4d„ Z5d„ Z6dhd„Z7d„ Z8d„ Z9d„ Z:d„ Z;d„ Z<d„ Z=d„ Z>d„ Z?d„ Z@d „ ZAd!„ ZBd"„ ZCd#„ ZDd$„ ZEd%„ ZFd&„ ZGd'„ ZHd(„ ZId)„ ZJd*„ ZKd+„ ZLd,„ ZMd-„ ZNd.„ ZOdhd/„ZPd0„ ZQd1„ ZRd2„ ZSd3„ ZTd4„ ZUd5„ ZVd6„ ZWeXd7œd8„ZYeXd7œd9„ZZd:„ Z[d;„ Z\dd<œd=„Z]did?„Z^djdA„Z_dB„ Z`dC„ ZadD„ ZbdE„ ZcdF„ ZddG„ ZedH„ ZfdI„ ZgdJ„ ZhdK„ ZidL„ ZjdM„ ZkdN„ ZldO„ ZmdP„ ZndQ„ ZodR„ ZpdS„ ZqdT„ ZrdU„ ZsdV„ ZtdW„ ZudX„ ZvdY„ ZwdZ„ Zxd[„ Zyd\„ Zzd]„ Z{d^„ Z|d_„ Z}d`„ Z~da„ Zdb„ Z€dhdc„Z�e�Z‚dd„ Zƒde„ Z„dhdf„Z…dg„ Z†dS )kÚDomainar  Superclass for all domains in the polys domains system.

    See :ref:`polys-domainsintro` for an introductory explanation of the
    domains system.

    The :py:class:`~.Domain` class is an abstract base class for all of the
    concrete domain types. There are many different :py:class:`~.Domain`
    subclasses each of which has an associated ``dtype`` which is a class
    representing the elements of the domain. The coefficients of a
    :py:class:`~.Poly` are elements of a domain which must be a subclass of
    :py:class:`~.Domain`.

    Examples
    ========

    The most common example domains are the integers :ref:`ZZ` and the
    rationals :ref:`QQ`.

    >>> from sympy import Poly, symbols, Domain
    >>> x, y = symbols('x, y')
    >>> p = Poly(x**2 + y)
    >>> p
    Poly(x**2 + y, x, y, domain='ZZ')
    >>> p.domain
    ZZ
    >>> isinstance(p.domain, Domain)
    True
    >>> Poly(x**2 + y/2)
    Poly(x**2 + 1/2*y, x, y, domain='QQ')

    The domains can be used directly in which case the domain object e.g.
    (:ref:`ZZ` or :ref:`QQ`) can be used as a constructor for elements of
    ``dtype``.

    >>> from sympy import ZZ, QQ
    >>> ZZ(2)
    2
    >>> ZZ.dtype  # doctest: +SKIP
    <class 'int'>
    >>> type(ZZ(2))  # doctest: +SKIP
    <class 'int'>
    >>> QQ(1, 2)
    1/2
    >>> type(QQ(1, 2))  # doctest: +SKIP
    <class 'sympy.polys.domains.pythonrational.PythonRational'>

    The corresponding domain elements can be used with the arithmetic
    operations ``+,-,*,**`` and depending on the domain some combination of
    ``/,//,%`` might be usable. For example in :ref:`ZZ` both ``//`` (floor
    division) and ``%`` (modulo division) can be used but ``/`` (true
    division) cannot. Since :ref:`QQ` is a :py:class:`~.Field` its elements
    can be used with ``/`` but ``//`` and ``%`` should not be used. Some
    domains have a :py:meth:`~.Domain.gcd` method.

    >>> ZZ(2) + ZZ(3)
    5
    >>> ZZ(5) // ZZ(2)
    2
    >>> ZZ(5) % ZZ(2)
    1
    >>> QQ(1, 2) / QQ(2, 3)
    3/4
    >>> ZZ.gcd(ZZ(4), ZZ(2))
    2
    >>> QQ.gcd(QQ(2,7), QQ(5,3))
    1/21
    >>> ZZ.is_Field
    False
    >>> QQ.is_Field
    True

    There are also many other domains including:

        1. :ref:`GF(p)` for finite fields of prime order.
        2. :ref:`RR` for real (floating point) numbers.
        3. :ref:`CC` for complex (floating point) numbers.
        4. :ref:`QQ(a)` for algebraic number fields.
        5. :ref:`K[x]` for polynomial rings.
        6. :ref:`K(x)` for rational function fields.
        7. :ref:`EX` for arbitrary expressions.

    Each domain is represented by a domain object and also an implementation
    class (``dtype``) for the elements of the domain. For example the
    :ref:`K[x]` domains are represented by a domain object which is an
    instance of :py:class:`~.PolynomialRing` and the elements are always
    instances of :py:class:`~.PolyElement`. The implementation class
    represents particular types of mathematical expressions in a way that is
    more efficient than a normal SymPy expression which is of type
    :py:class:`~.Expr`. The domain methods :py:meth:`~.Domain.from_sympy` and
    :py:meth:`~.Domain.to_sympy` are used to convert from :py:class:`~.Expr`
    to a domain element and vice versa.

    >>> from sympy import Symbol, ZZ, Expr
    >>> x = Symbol('x')
    >>> K = ZZ[x]           # polynomial ring domain
    >>> K
    ZZ[x]
    >>> type(K)             # class of the domain
    <class 'sympy.polys.domains.polynomialring.PolynomialRing'>
    >>> K.dtype             # doctest: +SKIP
    <class 'sympy.polys.rings.PolyElement'>
    >>> p_expr = x**2 + 1   # Expr
    >>> p_expr
    x**2 + 1
    >>> type(p_expr)
    <class 'sympy.core.add.Add'>
    >>> isinstance(p_expr, Expr)
    True
    >>> p_domain = K.from_sympy(p_expr)
    >>> p_domain            # domain element
    x**2 + 1
    >>> type(p_domain)
    <class 'sympy.polys.rings.PolyElement'>
    >>> K.to_sympy(p_domain) == p_expr
    True

    The :py:meth:`~.Domain.convert_from` method is used to convert domain
    elements from one domain to another.

    >>> from sympy import ZZ, QQ
    >>> ez = ZZ(2)
    >>> eq = QQ.convert_from(ez, ZZ)
    >>> type(ez)  # doctest: +SKIP
    <class 'int'>
    >>> type(eq)  # doctest: +SKIP
    <class 'sympy.polys.domains.pythonrational.PythonRational'>

    Elements from different domains should not be mixed in arithmetic or other
    operations: they should be converted to a common domain first.  The domain
    method :py:meth:`~.Domain.unify` is used to find a domain that can
    represent all the elements of two given domains.

    >>> from sympy import ZZ, QQ, symbols
    >>> x, y = symbols('x, y')
    >>> ZZ.unify(QQ)
    QQ
    >>> ZZ[x].unify(QQ)
    QQ[x]
    >>> ZZ[x].unify(QQ[y])
    QQ[x,y]

    If a domain is a :py:class:`~.Ring` then is might have an associated
    :py:class:`~.Field` and vice versa. The :py:meth:`~.Domain.get_field` and
    :py:meth:`~.Domain.get_ring` methods will find or create the associated
    domain.

    >>> from sympy import ZZ, QQ, Symbol
    >>> x = Symbol('x')
    >>> ZZ.has_assoc_Field
    True
    >>> ZZ.get_field()
    QQ
    >>> QQ.has_assoc_Ring
    True
    >>> QQ.get_ring()
    ZZ
    >>> K = QQ[x]
    >>> K
    QQ[x]
    >>> K.get_field()
    QQ(x)

    See also
    ========

    DomainElement: abstract base class for domain elements
    construct_domain: construct a minimal domain for some expressions

    Nztype | NoneÚdtyper   ÚzeroÚoneFTz
str | NoneÚrepÚaliasc                ó   — t           ‚©N©ÚNotImplementedError©Úselfs    úX/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/polys/domains/domain.pyÚ__init__zDomain.__init__g  s   € Ý!Ð!ó    c                ó   — | j         S r   )r   r   s    r    Ú__str__zDomain.__str__j  s	   € ØŒxˆr"   c                ó    — t          | ¦  «        S r   )Ústrr   s    r    Ú__repr__zDomain.__repr__m  s   € Ý�4‰yŒyÐr"   c                óB   — t          | j        j        | j        f¦  «        S r   )ÚhashÚ	__class__Ú__name__r   r   s    r    Ú__hash__zDomain.__hash__p  s   € Ý�T”^Ô,¨d¬jÐ9Ñ:Ô:Ð:r"   c                ó   —  | j         |Ž S r   ©r   ©r   Úargss     r    Únewz
Domain.news  ó   € ØˆtŒz˜4Ð Ð r"   c                ó   — | j         S )z#Alias for :py:attr:`~.Domain.dtype`r.   r   s    r    Útpz	Domain.tpv  s   € ð ŒzÐr"   c                ó   —  | j         |Ž S )z7Construct an element of ``self`` domain from ``args``. )r1   r/   s     r    Ú__call__zDomain.__call__{  s   € àˆtŒx˜ˆÐr"   c                ó   —  | j         |Ž S r   r.   r/   s     r    ÚnormalzDomain.normal  r2   r"   c           
     óØ   — |j         �d|j         z   }nd|j        j        z   }t          | |¦  «        }|� |||¦  «        }|�|S t	          d|›dt          |¦  «        ›d|›d| ›�¦  «        ‚)z=Convert ``element`` to ``self.dtype`` given the base domain. NÚfrom_úCannot convert ú	 of type z from ú to )r   r*   r+   Úgetattrr   Útype)r   ÚelementÚbaseÚmethodÚ_convertÚresults         r    Úconvert_fromzDomain.convert_from‚  s�   € àŒ:Ð!Ø˜tœzÑ)ˆFˆFà˜tœ~Ô6Ñ6ˆFå˜4 Ñ(Ô(ˆàÐØ�X˜g tÑ,Ô,ˆFàÐ!Ø�åˆnÈWÈWÈWÕVZÐ[bÑVcÔVcÐVcÐVcÐeiÐeiÐeiÐkoÐkoÐpÑqÔqÐqr"   c                ó  — |�7t          |¦  «        rt          d|z  ¦  «        ‚|                      ||¦  «        S |                      |¦  «        r|S t          |¦  «        rt          d|z  ¦  «        ‚ddlm}m}m}m} |                     |¦  «        r|                      ||¦  «        S t          |t          ¦  «        r|                       ||¦  «        |¦  «        S t          dk    rVt          ||j        ¦  «        r|                      ||¦  «        S t          ||j        ¦  «        r|                      ||¦  «        S t          |t          ¦  «        r) |¦   «         }|                       ||¦  «        |¦  «        S t          |t          ¦  «        r) |¦   «         }|                       ||¦  «        |¦  «        S t          |¦  «        j        dk    r) |¦   «         }|                       ||¦  «        |¦  «        S t          |¦  «        j        dk    r) |¦   «         }|                       ||¦  «        |¦  «        S t          |t"          ¦  «        r(|                      ||                     ¦   «         ¦  «        S | j        r8t)          |dd	¦  «        r'|                      |                     ¦   «         ¦  «        S t          |t.          ¦  «        r-	 |                      |¦  «        S # t2          t4          f$ r Y ngw xY wt7          |¦  «        sT	 t9          |d
¬¦  «        }t          |t.          ¦  «        r|                      |¦  «        S n# t2          t4          f$ r Y nw xY wt          d|›dt          |¦  «        ›d| ›�¦  «        ‚)z'Convert ``element`` to ``self.dtype``. Nz%s is not in any domainr   )ÚZZÚQQÚ	RealFieldÚComplexFieldÚpythonÚmpfÚmpcÚ	is_groundFT)Ústrictr;   r<   r=   )r   r   rE   Úof_typeÚsympy.polys.domainsrG   rH   rI   rJ   Ú
isinstanceÚintr	   r4   ÚfloatÚcomplexr?   r+   r
   ÚparentÚis_Numericalr>   ÚconvertÚLCr   Ú
from_sympyÚ	TypeErrorÚ
ValueErrorr   r   )r   r@   rA   rG   rH   rI   rJ   rV   s           r    rX   zDomain.convert“  s®  € ð ÐÝ˜GÑ$Ô$ð JÝ$Ð%>ÀÑ%HÑIÔIÐIØ×$Ò$ W¨dÑ3Ô3Ð3à�<Š<˜Ñ Ô ð 	ØˆNå˜Ñ Ô ð 	FÝ Ð!:¸WÑ!DÑEÔEÐEàGÐGÐGÐGÐGÐGÐGÐGÐGÐGÐGÐGà�:Š:�gÑÔð 	2Ø×$Ò$ W¨bÑ1Ô1Ð1å�g�sÑ#Ô#ð 	6Ø×$Ò$ R R¨¡[¤[°"Ñ5Ô5Ð5å˜8Ò#Ð#Ý˜' 2¤5Ñ)Ô)ð 6Ø×(Ò(¨°"Ñ5Ô5Ð5Ý˜' 2¤5Ñ)Ô)ð 6Ø×(Ò(¨°"Ñ5Ô5Ð5å�g�uÑ%Ô%ð 	>Ø�Y‘[”[ˆFØ×$Ò$ V V¨G¡_¤_°fÑ=Ô=Ð=å�g�wÑ'Ô'ð 	>Ø!�\‘^”^ˆFØ×$Ò$ V V¨G¡_¤_°fÑ=Ô=Ð=å�‰=Œ=Ô! UÒ*Ð*Ø�Y‘[”[ˆFØ×$Ò$ V V¨G¡_¤_°fÑ=Ô=Ð=å�‰=Œ=Ô! UÒ*Ð*Ø!�\‘^”^ˆFØ×$Ò$ V V¨G¡_¤_°fÑ=Ô=Ð=å�g�}Ñ-Ô-ð 	@Ø×$Ò$ W¨g¯nªnÑ.>Ô.>Ñ?Ô?Ð?ð Ôð 	.¥¨°+¸uÑ!EÔ!Eð 	.Ø—<’< §
¢
¡¤Ñ-Ô-Ð-å�g�uÑ%Ô%ð 	ðØ—’ wÑ/Ô/Ð/øÝ�zÐ*ð ð ð Ø�ðøøøõ ˜wÑ'Ô'ð ðÝ% g°dÐ;Ñ;Ô;�GÝ! '­5Ñ1Ô1ð 8Ø#Ÿš¨wÑ7Ô7Ð7ð8øå!¥:Ð.ð ð ð Ø�Dðøøøõ ˆnÀWÀWÀWÍdÐSZÉmÌmÈmÈmÐ]aÐ]aÐbÑcÔcÐcs$   ËK# Ë#K7Ë6K7Ì
:M ÍMÍMc                ó,   — t          || j        ¦  «        S )z%Check if ``a`` is of type ``dtype``. )rR   r4   )r   r@   s     r    rP   zDomain.of_typeÖ  s   € å˜' 4¤7Ñ+Ô+Ð+r"   c                ó‚   — 	 t          |¦  «        rt          ‚|                      |¦  «         n# t          $ r Y dS w xY wdS )z'Check if ``a`` belongs to this domain. FT)r   r   rX   ©r   Úas     r    Ú__contains__zDomain.__contains__Ú  sU   € ð	Ý˜A‰Œð %Ý$Ð$Ø�LŠL˜‰OŒOˆOˆOøÝð 	ð 	ð 	Ø�5�5ð	øøøð ˆts   ‚+. ®
<»<c                ó   — t           ‚)aö	  Convert domain element *a* to a SymPy expression (Expr).

        Explanation
        ===========

        Convert a :py:class:`~.Domain` element *a* to :py:class:`~.Expr`. Most
        public SymPy functions work with objects of type :py:class:`~.Expr`.
        The elements of a :py:class:`~.Domain` have a different internal
        representation. It is not possible to mix domain elements with
        :py:class:`~.Expr` so each domain has :py:meth:`~.Domain.to_sympy` and
        :py:meth:`~.Domain.from_sympy` methods to convert its domain elements
        to and from :py:class:`~.Expr`.

        Parameters
        ==========

        a: domain element
            An element of this :py:class:`~.Domain`.

        Returns
        =======

        expr: Expr
            A normal SymPy expression of type :py:class:`~.Expr`.

        Examples
        ========

        Construct an element of the :ref:`QQ` domain and then convert it to
        :py:class:`~.Expr`.

        >>> from sympy import QQ, Expr
        >>> q_domain = QQ(2)
        >>> q_domain
        2
        >>> q_expr = QQ.to_sympy(q_domain)
        >>> q_expr
        2

        Although the printed forms look similar these objects are not of the
        same type.

        >>> isinstance(q_domain, Expr)
        False
        >>> isinstance(q_expr, Expr)
        True

        Construct an element of :ref:`K[x]` and convert to
        :py:class:`~.Expr`.

        >>> from sympy import Symbol
        >>> x = Symbol('x')
        >>> K = QQ[x]
        >>> x_domain = K.gens[0]  # generator x as a domain element
        >>> p_domain = x_domain**2/3 + 1
        >>> p_domain
        1/3*x**2 + 1
        >>> p_expr = K.to_sympy(p_domain)
        >>> p_expr
        x**2/3 + 1

        The :py:meth:`~.Domain.from_sympy` method is used for the opposite
        conversion from a normal SymPy expression to a domain element.

        >>> p_domain == p_expr
        False
        >>> K.from_sympy(p_expr) == p_domain
        True
        >>> K.to_sympy(p_domain) == p_expr
        True
        >>> K.from_sympy(K.to_sympy(p_domain)) == p_domain
        True
        >>> K.to_sympy(K.from_sympy(p_expr)) == p_expr
        True

        The :py:meth:`~.Domain.from_sympy` method makes it easier to construct
        domain elements interactively.

        >>> from sympy import Symbol
        >>> x = Symbol('x')
        >>> K = QQ[x]
        >>> K.from_sympy(x**2/3 + 1)
        1/3*x**2 + 1

        See also
        ========

        from_sympy
        convert_from
        r   r_   s     r    Úto_sympyzDomain.to_sympyå  s   € õv "Ð!r"   c                ó   — t           ‚)aê  Convert a SymPy expression to an element of this domain.

        Explanation
        ===========

        See :py:meth:`~.Domain.to_sympy` for explanation and examples.

        Parameters
        ==========

        expr: Expr
            A normal SymPy expression of type :py:class:`~.Expr`.

        Returns
        =======

        a: domain element
            An element of this :py:class:`~.Domain`.

        See also
        ========

        to_sympy
        convert_from
        r   r_   s     r    rZ   zDomain.from_sympyB  s
   € õ4 "Ð!r"   c                ó.   — t          || j        ¬¦  «        S )N)Ústart)Úsumr   r/   s     r    rg   z
Domain.sum^  s   € Ý�4˜tœyÐ)Ñ)Ô)Ð)r"   c                ó   — dS ©z.Convert ``ModularInteger(int)`` to ``dtype``. N© ©ÚK1r`   ÚK0s      r    Úfrom_FFzDomain.from_FFa  ó   € àˆtr"   c                ó   — dS ri   rj   rk   s      r    Úfrom_FF_pythonzDomain.from_FF_pythone  ro   r"   c                ó   — dS )z.Convert a Python ``int`` object to ``dtype``. Nrj   rk   s      r    Úfrom_ZZ_pythonzDomain.from_ZZ_pythoni  ro   r"   c                ó   — dS )z3Convert a Python ``Fraction`` object to ``dtype``. Nrj   rk   s      r    Úfrom_QQ_pythonzDomain.from_QQ_pythonm  ro   r"   c                ó   — dS )z.Convert ``ModularInteger(mpz)`` to ``dtype``. Nrj   rk   s      r    Úfrom_FF_gmpyzDomain.from_FF_gmpyq  ro   r"   c                ó   — dS )z,Convert a GMPY ``mpz`` object to ``dtype``. Nrj   rk   s      r    Úfrom_ZZ_gmpyzDomain.from_ZZ_gmpyu  ro   r"   c                ó   — dS )z,Convert a GMPY ``mpq`` object to ``dtype``. Nrj   rk   s      r    Úfrom_QQ_gmpyzDomain.from_QQ_gmpyy  ro   r"   c                ó   — dS )z,Convert a real element object to ``dtype``. Nrj   rk   s      r    Úfrom_RealFieldzDomain.from_RealField}  ro   r"   c                ó   — dS )z(Convert a complex element to ``dtype``. Nrj   rk   s      r    Úfrom_ComplexFieldzDomain.from_ComplexField�  ro   r"   c                ó   — dS )z*Convert an algebraic number to ``dtype``. Nrj   rk   s      r    Úfrom_AlgebraicFieldzDomain.from_AlgebraicField…  ro   r"   c                óT   — |j         r |                      |j        |j        ¦  «        S dS )ú#Convert a polynomial to ``dtype``. N)rN   rX   rY   Údomrk   s      r    Úfrom_PolynomialRingzDomain.from_PolynomialRing‰  s.   € àŒ;ð 	,Ø—:’:˜aœd B¤FÑ+Ô+Ð+ð	,ð 	,r"   c                ó   — dS )z*Convert a rational function to ``dtype``. Nrj   rk   s      r    Úfrom_FractionFieldzDomain.from_FractionFieldŽ  ro   r"   c                óB   — |                       |j        |j        ¦  «        S )z.Convert an ``ExtensionElement`` to ``dtype``. )rE   r   Úringrk   s      r    Úfrom_MonogenicFiniteExtensionz$Domain.from_MonogenicFiniteExtension’  s   € à�Š˜qœu b¤gÑ.Ô.Ð.r"   c                ó6   — |                       |j        ¦  «        S ©z&Convert a ``EX`` object to ``dtype``. )rZ   Úexrk   s      r    Úfrom_ExpressionDomainzDomain.from_ExpressionDomain–  s   € à�}Š}˜QœTÑ"Ô"Ð"r"   c                ó,   — |                       |¦  «        S rŒ   )rZ   rk   s      r    Úfrom_ExpressionRawDomainzDomain.from_ExpressionRawDomainš  s   € à�}Š}˜QÑÔÐr"   c                ó�   — |                      ¦   «         dk    r-|                      |                     ¦   «         |j        ¦  «        S dS )rƒ   r   N)ÚdegreerX   rY   r„   rk   s      r    Úfrom_GlobalPolynomialRingz Domain.from_GlobalPolynomialRingž  s8   € à�8Š8‰:Œ:˜Š?ˆ?Ø—:’:˜aŸdšd™fœf b¤fÑ-Ô-Ð-ð ˆ?r"   c                ó.   — |                       ||¦  «        S r   )r‡   rk   s      r    Úfrom_GeneralizedPolynomialRingz%Domain.from_GeneralizedPolynomialRing£  s   € Ø×$Ò$ Q¨Ñ+Ô+Ð+r"   c           
     ó$  — | j         r$t          | j        ¦  «        t          |¦  «        z  s+|j         rJt          |j        ¦  «        t          |¦  «        z  r&t          d| ›d|›dt	          |¦  «        ›d�¦  «        ‚|                      |¦  «        S )NúCannot unify ú with z, given z generators)Úis_CompositeÚsetÚsymbolsr   ÚtupleÚunify)rm   rl   r›   s      r    Úunify_with_symbolszDomain.unify_with_symbols¦  sœ   € ØŒOð 	o¥ R¤Z¡¤µ3°w±<´<Ñ!?ð 	oÀbÄoð 	oÕ[^Ð_aÔ_iÑ[jÔ[jÕmpÐqxÑmyÔmyÑ[yð 	oÝ#Ð#ÐVXÐVXÐVXÐZ\ÐZ\ÐZ\Õ^cÐdkÑ^lÔ^lÐ^lÐ^lÐ$mÑnÔnÐnà�xŠx˜‰|Œ|Ðr"   c                ó.  — | j         r| j        n| }|j         r|j        n|}| j         r| j        nd}|j         r|j        nd}|                     |¦  «        }t	          ||¦  «        }| j         r| j        n|j        }| j        r|j        s|j        r7| j        r0|j        r|j        s"|j        r|j	        r| 
                    ¦   «         }| j         r|j         r| j        s|j        r| j        }	n|j        }	ddlm}
 |	|
k    r |	||¦  «        S  |	|||¦  «        S )z2Unify two domains where at least one is composite.rj   r   )ÚGlobalPolynomialRing)r™   r„   r›   r�   r   ÚorderÚis_FractionFieldÚis_PolynomialRingÚis_FieldÚhas_assoc_RingÚget_ringr*   Ú&sympy.polys.domains.old_polynomialringr    )rm   rl   Ú	K0_groundÚ	K1_groundÚ
K0_symbolsÚ
K1_symbolsÚdomainr›   r¡   Úclsr    s              r    Úunify_compositezDomain.unify_composite¬  sg  € à œoÐ5�B”F�F°2ˆ	Ø œoÐ5�B”F�F°2ˆ	à#%¤?Ð:�R”Z�Z¸ˆ
Ø#%¤?Ð:�R”Z�Z¸ˆ
à—’ Ñ+Ô+ˆÝ˜j¨*Ñ5Ô5ˆØœOÐ9�”�°´ˆð Ô ð 	' RÔ%9ð 	'ØÔ ð	'Ø%'Ô%9ð	'àÔ$ð	'à,5Ô,>ð	'àDJÄOð	'ð Ô&ð	'ð —_’_Ñ&Ô&ˆFàŒ?ð 	 B¤Oð 	°rÔ7Jð 	ÈbÔNbð 	Ø”,ˆCˆCà”,ˆCð
 	PÐOÐOÐOÐOÐOØÐ&Ò&Ð&Ø�3�v˜wÑ'Ô'Ð'àˆs�6˜7 EÑ*Ô*Ð*r"   c                óx  — |�|                       ||¦  «        S | |k    r| S | j        r|j        sT|                      ¦   «         |                     ¦   «         k    rt          d| ›d|›�¦  «        ‚|                      |¦  «        S | j        r| S |j        r|S | j        r| S |j        r|S | j        s|j        r«|j        r|| }} |j        rPt          t          | j
        |j
        g¦  «        ¦  «        d         | j
        k    r|| }} |                     | ¦  «        S |                     | j        ¦  «        }| j                             |¦  «        }|                      |¦  «        S | j        s|j        r|                      |¦  «        S |j        r|| }} | j        r9|j        s|j        r)| j        |j        k    r| S ddlm}  ||j        ¬¦  «        S | S |j        r|| }} | j        rB|j        r| j        |j        k    r| S |S |j        s|j        rddlm}  || j        ¬¦  «        S | S |j        r|| }} | j        r‚|j        r|                     ¦   «         }|j        r|                     ¦   «         }|j        rC | j        | j                             |j        ¦  «        gt;          | j        |j        ¦  «        ¢R Ž S | S | j        r| S |j        r|S | j        r|j        r|                      ¦   «         } | S |j        r| j        r|                     ¦   «         }|S | j        r| S |j        r|S | j         r| S |j         r|S ddl!m"} |S )	aZ  
        Construct a minimal domain that contains elements of ``K0`` and ``K1``.

        Known domains (from smallest to largest):

        - ``GF(p)``
        - ``ZZ``
        - ``QQ``
        - ``RR(prec, tol)``
        - ``CC(prec, tol)``
        - ``ALG(a, b, c)``
        - ``K[x, y, z]``
        - ``K(x, y, z)``
        - ``EX``

        Nr—   r˜   é   r   )rJ   )Úprec)ÚEX)#rž   Úhas_CharacteristicZeroÚcharacteristicr   r®   Úis_EXRAWÚis_EXÚis_FiniteExtensionÚlistr   ÚmodulusÚ
set_domainÚdropÚsymbolr¬   r�   r™   Úis_ComplexFieldÚis_RealFieldÚ	precisionÚ sympy.polys.domains.complexfieldrJ   Úis_GaussianRingÚis_GaussianFieldÚis_AlgebraicFieldÚ	get_fieldÚas_AlgebraicFieldr*   r„   r   Úorig_extÚis_RationalFieldÚis_IntegerRingrQ   r²   )rm   rl   r›   rJ   r²   s        r    r�   zDomain.unifyÍ  s  € ð" ÐØ×(Ò(¨¨WÑ5Ô5Ð5à�Š8ˆ8ØˆIàÔ)ð 	*¨bÔ.Gð 	*à× Ò Ñ"Ô" b×&7Ò&7Ñ&9Ô&9Ò9Ð9Ý'Ð'ÀRÀRÀRÈÈÐ(LÑMÔMÐMð
 ×%Ò% bÑ)Ô)Ð)ð
 Œ;ð 	ØˆIØŒ;ð 	ØˆIàŒ8ð 	ØˆIØŒ8ð 	ØˆIàÔ ð 	) BÔ$9ð 	)ØÔ$ð  Ø˜R�B�ØÔ$ð 
)õ � ¤¨R¬ZÐ 8Ñ9Ô9Ñ:Ô:¸1Ô=ÀÄÒKÐKØ ˜�BØ—}’} RÑ(Ô(Ð(ð —W’W˜RœYÑ'Ô'�Ø”Y—_’_ RÑ(Ô(�Ø—}’} RÑ(Ô(Ð(àŒ?ð 	*˜bœoð 	*Ø×%Ò% bÑ)Ô)Ð)àÔð 	Ø˜�ˆBØÔð 	ØÔ!ð  R¤_ð Ø”< 2¤<Ò/Ð/Ø�IàMÐMÐMÐMÐMÐMØ'˜<¨R¬\Ð:Ñ:Ô:Ð:à�	àŒ?ð 	Ø˜�ˆBØŒ?ð 
	ØŒð 	Ø”< 2¤<Ò/Ð/Ø�Ià�IØÔ#ð  rÔ':ð ØIÐIÐIÐIÐIÐIØ#�|¨¬Ð6Ñ6Ô6Ð6à�	àÔð 	Ø˜�ˆBØÔð 	ØÔ!ð $Ø—\’\‘^”^�ØÔ"ð ,Ø×)Ò)Ñ+Ô+�ØÔ#ð Ø#�r”| B¤F§L¢L°´Ñ$8Ô$8Ða½;ÀrÄ{ÐTVÔT_Ñ;`Ô;`ÐaÐaÐaÐaà�	àÔð 	ØˆIØÔð 	ØˆIàÔð 	ØÔ"ð $Ø—\’\‘^”^�ØˆIØÔð 	ØÔ"ð $Ø—\’\‘^”^�ØˆIàÔð 	ØˆIØÔð 	ØˆIàÔð 	ØˆIØÔð 	ØˆIà*Ð*Ð*Ð*Ð*Ð*Øˆ	r"   c                óL   — t          |t          ¦  «        o| j        |j        k    S )z0Returns ``True`` if two domains are equivalent. )rR   r   r   ©r   Úothers     r    Ú__eq__zDomain.__eq__N  s"   € õ ˜%¥Ñ(Ô(ÐF¨T¬Z¸5¼;Ò-FÐFr"   c                ó   — | |k     S )z1Returns ``False`` if two domains are equivalent. rj   rÊ   s     r    Ú__ne__zDomain.__ne__S  s   € à˜5’=Ð Ð r"   c                óÌ   — g }|D ]^}t          |t          ¦  «        r)|                     |                      |¦  «        ¦  «         Œ@|                      | |¦  «        ¦  «         Œ_|S )z5Rersively apply ``self`` to all elements of ``seq``. )rR   r¸   ÚappendÚmap)r   ÚseqrD   Úelts       r    rÑ   z
Domain.mapW  si   € àˆàð 	)ð 	)ˆCÝ˜#�tÑ$Ô$ð )Ø—’˜dŸhšh s™mœmÑ,Ô,Ð,Ð,à—’˜d˜d 3™iœiÑ(Ô(Ð(Ð(àˆr"   c                ó&   — t          d| z  ¦  «        ‚)z)Returns a ring associated with ``self``. z#there is no ring associated with %s©r   r   s    r    r¦   zDomain.get_ringc  s   € åÐ?À$ÑFÑGÔGÐGr"   c                ó&   — t          d| z  ¦  «        ‚)z*Returns a field associated with ``self``. z$there is no field associated with %srÕ   r   s    r    rÄ   zDomain.get_fieldg  s   € åÐ@À4ÑGÑHÔHÐHr"   c                ó   — | S )z2Returns an exact domain associated with ``self``. rj   r   s    r    Ú	get_exactzDomain.get_exactk  s   € àˆr"   c                ó`   — t          |d¦  «        r
 | j        |Ž S |                      |¦  «        S )z0The mathematical way to make a polynomial ring. Ú__iter__)ÚhasattrÚ	poly_ring©r   r›   s     r    Ú__getitem__zDomain.__getitem__o  s5   € å�7˜JÑ'Ô'ð 	+Ø!�4”> 7Ð+Ð+à—>’> 'Ñ*Ô*Ð*r"   )r¡   c               ó(   — ddl m}  || ||¦  «        S ©z(Returns a polynomial ring, i.e. `K[X]`. r   )ÚPolynomialRing)Ú"sympy.polys.domains.polynomialringrá   )r   r¡   r›   rá   s       r    rÜ   zDomain.poly_ringv  s(   € àEÐEÐEÐEÐEÐEØˆ~˜d G¨UÑ3Ô3Ð3r"   c               ó(   — ddl m}  || ||¦  «        S ©z'Returns a fraction field, i.e. `K(X)`. r   )ÚFractionField)Ú!sympy.polys.domains.fractionfieldrå   )r   r¡   r›   rå   s       r    Ú
frac_fieldzDomain.frac_field{  s(   € àCÐCÐCÐCÐCÐCØˆ}˜T 7¨EÑ2Ô2Ð2r"   c                ó&   — ddl m}  || g|¢R i |¤ŽS rà   )r§   rá   )r   r›   Úkwargsrá   s       r    Úold_poly_ringzDomain.old_poly_ring€  s4   € àIÐIÐIÐIÐIÐIØˆ~˜dÐ7 WÐ7Ð7Ð7°Ð7Ð7Ð7r"   c                ó&   — ddl m}  || g|¢R i |¤ŽS rä   )Ú%sympy.polys.domains.old_fractionfieldrå   )r   r›   ré   rå   s       r    Úold_frac_fieldzDomain.old_frac_field…  s4   € àGÐGÐGÐGÐGÐGØˆ}˜TÐ6 GÐ6Ð6Ð6¨vÐ6Ð6Ð6r"   ©r   c               ó&   — t          d| z  ¦  «        ‚)z6Returns an algebraic field, i.e. `K(\alpha, \ldots)`. z%Cannot create algebraic field over %srÕ   )r   r   Ú	extensions      r    Úalgebraic_fieldzDomain.algebraic_fieldŠ  s   € åÐAÀDÑHÑIÔIÐIr"   éÿÿÿÿc                óv   — ddl m}  |||¦  «        }t          ||¬¦  «        }|                      ||¬¦  «        S )aï  
        Convenience method to construct an algebraic extension on a root of a
        polynomial, chosen by root index.

        Parameters
        ==========

        poly : :py:class:`~.Poly`
            The polynomial whose root generates the extension.
        alias : str, optional (default=None)
            Symbol name for the generator of the extension.
            E.g. "alpha" or "theta".
        root_index : int, optional (default=-1)
            Specifies which root of the polynomial is desired. The ordering is
            as defined by the :py:class:`~.ComplexRootOf` class. The default of
            ``-1`` selects the most natural choice in the common cases of
            quadratic and cyclotomic fields (the square root on the positive
            real or imaginary axis, resp. $\mathrm{e}^{2\pi i/n}$).

        Examples
        ========

        >>> from sympy import QQ, Poly
        >>> from sympy.abc import x
        >>> f = Poly(x**2 - 2)
        >>> K = QQ.alg_field_from_poly(f)
        >>> K.ext.minpoly == f
        True
        >>> g = Poly(8*x**3 - 6*x - 1)
        >>> L = QQ.alg_field_from_poly(g, "alpha")
        >>> L.ext.minpoly == g
        True
        >>> L.to_sympy(L([1, 1, 1]))
        alpha**2 + alpha + 1

        r   )ÚCRootOfrî   )Úsympy.polys.rootoftoolsrô   r   rñ   )r   Úpolyr   Ú
root_indexrô   ÚrootÚalphas          r    Úalg_field_from_polyzDomain.alg_field_from_polyŽ  sS   € ðJ 	4Ð3Ð3Ð3Ð3Ð3Øˆw�t˜ZÑ(Ô(ˆÝ ¨EÐ2Ñ2Ô2ˆØ×#Ò# E°Ð#Ñ7Ô7Ð7r"   Úzetac                óz   — ddl m} |r|t          |¦  «        z  }|                       |||¦  «        ||¬¦  «        S )a¢  
        Convenience method to construct a cyclotomic field.

        Parameters
        ==========

        n : int
            Construct the nth cyclotomic field.
        ss : boolean, optional (default=False)
            If True, append *n* as a subscript on the alias string.
        alias : str, optional (default="zeta")
            Symbol name for the generator.
        gen : :py:class:`~.Symbol`, optional (default=None)
            Desired variable for the cyclotomic polynomial that defines the
            field. If ``None``, a dummy variable will be used.
        root_index : int, optional (default=-1)
            Specifies which root of the polynomial is desired. The ordering is
            as defined by the :py:class:`~.ComplexRootOf` class. The default of
            ``-1`` selects the root $\mathrm{e}^{2\pi i/n}$.

        Examples
        ========

        >>> from sympy import QQ, latex
        >>> K = QQ.cyclotomic_field(5)
        >>> K.to_sympy(K([-1, 1]))
        1 - zeta
        >>> L = QQ.cyclotomic_field(7, True)
        >>> a = L.to_sympy(L([-1, 1]))
        >>> print(a)
        1 - zeta7
        >>> print(latex(a))
        1 - \zeta_{7}

        r   )Úcyclotomic_poly)r   r÷   )Úsympy.polys.specialpolysrý   r&   rú   )r   ÚnÚssr   Úgenr÷   rý   s          r    Úcyclotomic_fieldzDomain.cyclotomic_field¸  s^   € ðH 	=Ð<Ð<Ð<Ð<Ð<Øð 	Ø•S˜‘V”V‰OˆEØ×'Ò'¨¨¸¸3Ñ(?Ô(?ÀuØ3=ð (ñ ?ô ?ð 	?r"   c                ó   — t           ‚)z$Inject generators into this domain. r   rÝ   s     r    ÚinjectzDomain.injectâ  ó   € å!Ð!r"   c                ó"   — | j         r| S t          ‚)z"Drop generators from this domain. )Ú	is_Simpler   rÝ   s     r    r»   zDomain.dropæ  s   € àŒ>ð 	ØˆKÝ!Ð!r"   c                ó   — | S )zReturns True if ``a`` is zero. rj   r_   s     r    Úis_zerozDomain.is_zeroì  s	   € àˆuˆr"   c                ó   — || j         k    S )zReturns True if ``a`` is one. )r   r_   s     r    Úis_onezDomain.is_oneð  s   € à�D”HŠ}Ðr"   c                ó   — |dk    S )z#Returns True if ``a`` is positive. r   rj   r_   s     r    Úis_positivezDomain.is_positiveô  ó   € à�1Šuˆr"   c                ó   — |dk     S )z#Returns True if ``a`` is negative. r   rj   r_   s     r    Úis_negativezDomain.is_negativeø  r  r"   c                ó   — |dk    S )z'Returns True if ``a`` is non-positive. r   rj   r_   s     r    Úis_nonpositivezDomain.is_nonpositiveü  ó   € à�AŠvˆr"   c                ó   — |dk    S )z'Returns True if ``a`` is non-negative. r   rj   r_   s     r    Úis_nonnegativezDomain.is_nonnegative   r  r"   c                óJ   — |                       |¦  «        r| j         S | j        S r   )r  r   r_   s     r    Úcanonical_unitzDomain.canonical_unit  s)   € Ø×Ò˜AÑÔð 	Ø”H�9Ðà”8ˆOr"   c                ó    — t          |¦  «        S )z.Absolute value of ``a``, implies ``__abs__``. )Úabsr_   s     r    r  z
Domain.abs
  s   € å�1‰vŒvˆr"   c                ó   — | S )z,Returns ``a`` negated, implies ``__neg__``. rj   r_   s     r    Únegz
Domain.neg  ó	   € àˆrˆ	r"   c                ó   — |
 S )z-Returns ``a`` positive, implies ``__pos__``. rj   r_   s     r    Úposz
Domain.pos  r  r"   c                ó   — ||z   S )z.Sum of ``a`` and ``b``, implies ``__add__``.  rj   ©r   r`   Úbs      r    Úaddz
Domain.add  ó   € à�1‰uˆr"   c                ó   — ||z
  S )z5Difference of ``a`` and ``b``, implies ``__sub__``.  rj   r   s      r    Úsubz
Domain.sub  r#  r"   c                ó   — ||z  S )z2Product of ``a`` and ``b``, implies ``__mul__``.  rj   r   s      r    Úmulz
Domain.mul  r#  r"   c                ó   — ||z  S )z2Raise ``a`` to power ``b``, implies ``__pow__``.  rj   r   s      r    Úpowz
Domain.pow"  s   € à�A‰vˆr"   c                ó   — t           ‚)a
  Exact quotient of *a* and *b*. Analogue of ``a / b``.

        Explanation
        ===========

        This is essentially the same as ``a / b`` except that an error will be
        raised if the division is inexact (if there is any remainder) and the
        result will always be a domain element. When working in a
        :py:class:`~.Domain` that is not a :py:class:`~.Field` (e.g. :ref:`ZZ`
        or :ref:`K[x]`) ``exquo`` should be used instead of ``/``.

        The key invariant is that if ``q = K.exquo(a, b)`` (and ``exquo`` does
        not raise an exception) then ``a == b*q``.

        Examples
        ========

        We can use ``K.exquo`` instead of ``/`` for exact division.

        >>> from sympy import ZZ
        >>> ZZ.exquo(ZZ(4), ZZ(2))
        2
        >>> ZZ.exquo(ZZ(5), ZZ(2))
        Traceback (most recent call last):
            ...
        ExactQuotientFailed: 2 does not divide 5 in ZZ

        Over a :py:class:`~.Field` such as :ref:`QQ`, division (with nonzero
        divisor) is always exact so in that case ``/`` can be used instead of
        :py:meth:`~.Domain.exquo`.

        >>> from sympy import QQ
        >>> QQ.exquo(QQ(5), QQ(2))
        5/2
        >>> QQ(5) / QQ(2)
        5/2

        Parameters
        ==========

        a: domain element
            The dividend
        b: domain element
            The divisor

        Returns
        =======

        q: domain element
            The exact quotient

        Raises
        ======

        ExactQuotientFailed: if exact division is not possible.
        ZeroDivisionError: when the divisor is zero.

        See also
        ========

        quo: Analogue of ``a // b``
        rem: Analogue of ``a % b``
        div: Analogue of ``divmod(a, b)``

        Notes
        =====

        Since the default :py:attr:`~.Domain.dtype` for :ref:`ZZ` is ``int``
        (or ``mpz``) division as ``a / b`` should not be used as it would give
        a ``float`` which is not a domain element.

        >>> ZZ(4) / ZZ(2) # doctest: +SKIP
        2.0
        >>> ZZ(5) / ZZ(2) # doctest: +SKIP
        2.5

        On the other hand with `SYMPY_GROUND_TYPES=flint` elements of :ref:`ZZ`
        are ``flint.fmpz`` and division would raise an exception:

        >>> ZZ(4) / ZZ(2) # doctest: +SKIP
        Traceback (most recent call last):
        ...
        TypeError: unsupported operand type(s) for /: 'fmpz' and 'fmpz'

        Using ``/`` with :ref:`ZZ` will lead to incorrect results so
        :py:meth:`~.Domain.exquo` should be used instead.

        r   r   s      r    ÚexquozDomain.exquo&  s   € õr "Ð!r"   c                ó   — t           ‚)aG  Quotient of *a* and *b*. Analogue of ``a // b``.

        ``K.quo(a, b)`` is equivalent to ``K.div(a, b)[0]``. See
        :py:meth:`~.Domain.div` for more explanation.

        See also
        ========

        rem: Analogue of ``a % b``
        div: Analogue of ``divmod(a, b)``
        exquo: Analogue of ``a / b``
        r   r   s      r    Úquoz
Domain.quo�  ó
   € õ "Ð!r"   c                ó   — t           ‚)aN  Modulo division of *a* and *b*. Analogue of ``a % b``.

        ``K.rem(a, b)`` is equivalent to ``K.div(a, b)[1]``. See
        :py:meth:`~.Domain.div` for more explanation.

        See also
        ========

        quo: Analogue of ``a // b``
        div: Analogue of ``divmod(a, b)``
        exquo: Analogue of ``a / b``
        r   r   s      r    Úremz
Domain.rem�  r.  r"   c                ó   — t           ‚)a[	  Quotient and remainder for *a* and *b*. Analogue of ``divmod(a, b)``

        Explanation
        ===========

        This is essentially the same as ``divmod(a, b)`` except that is more
        consistent when working over some :py:class:`~.Field` domains such as
        :ref:`QQ`. When working over an arbitrary :py:class:`~.Domain` the
        :py:meth:`~.Domain.div` method should be used instead of ``divmod``.

        The key invariant is that if ``q, r = K.div(a, b)`` then
        ``a == b*q + r``.

        The result of ``K.div(a, b)`` is the same as the tuple
        ``(K.quo(a, b), K.rem(a, b))`` except that if both quotient and
        remainder are needed then it is more efficient to use
        :py:meth:`~.Domain.div`.

        Examples
        ========

        We can use ``K.div`` instead of ``divmod`` for floor division and
        remainder.

        >>> from sympy import ZZ, QQ
        >>> ZZ.div(ZZ(5), ZZ(2))
        (2, 1)

        If ``K`` is a :py:class:`~.Field` then the division is always exact
        with a remainder of :py:attr:`~.Domain.zero`.

        >>> QQ.div(QQ(5), QQ(2))
        (5/2, 0)

        Parameters
        ==========

        a: domain element
            The dividend
        b: domain element
            The divisor

        Returns
        =======

        (q, r): tuple of domain elements
            The quotient and remainder

        Raises
        ======

        ZeroDivisionError: when the divisor is zero.

        See also
        ========

        quo: Analogue of ``a // b``
        rem: Analogue of ``a % b``
        exquo: Analogue of ``a / b``

        Notes
        =====

        If ``gmpy`` is installed then the ``gmpy.mpq`` type will be used as
        the :py:attr:`~.Domain.dtype` for :ref:`QQ`. The ``gmpy.mpq`` type
        defines ``divmod`` in a way that is undesirable so
        :py:meth:`~.Domain.div` should be used instead of ``divmod``.

        >>> a = QQ(1)
        >>> b = QQ(3, 2)
        >>> a               # doctest: +SKIP
        mpq(1,1)
        >>> b               # doctest: +SKIP
        mpq(3,2)
        >>> divmod(a, b)    # doctest: +SKIP
        (mpz(0), mpq(1,1))
        >>> QQ.div(a, b)    # doctest: +SKIP
        (mpq(2,3), mpq(0,1))

        Using ``//`` or ``%`` with :ref:`QQ` will lead to incorrect results so
        :py:meth:`~.Domain.div` should be used instead.

        r   r   s      r    Údivz
Domain.divŸ  s   € õh "Ð!r"   c                ó   — t           ‚)z5Returns inversion of ``a mod b``, implies something. r   r   s      r    ÚinvertzDomain.invertõ  r  r"   c                ó   — t           ‚)z!Returns ``a**(-1)`` if possible. r   r_   s     r    ÚrevertzDomain.revertù  r  r"   c                ó   — t           ‚)zReturns numerator of ``a``. r   r_   s     r    ÚnumerzDomain.numerý  r  r"   c                ó   — t           ‚)zReturns denominator of ``a``. r   r_   s     r    ÚdenomzDomain.denom  r  r"   c                ó>   — |                       ||¦  «        \  }}}||fS )z&Half extended GCD of ``a`` and ``b``. )Úgcdex)r   r`   r!  ÚsÚtÚhs         r    Ú
half_gcdexzDomain.half_gcdex  s$   € à—*’*˜Q Ñ"Ô"‰ˆˆ1ˆaØ�!ˆtˆr"   c                ó   — t           ‚)z!Extended GCD of ``a`` and ``b``. r   r   s      r    r<  zDomain.gcdex
  r  r"   c                ó�   — |                       ||¦  «        }|                      ||¦  «        }|                      ||¦  «        }|||fS )z.Returns GCD and cofactors of ``a`` and ``b``. )Úgcdr-  )r   r`   r!  rC  ÚcfaÚcfbs         r    Ú	cofactorszDomain.cofactors  sE   € à�hŠh�q˜!‰nŒnˆØ�hŠh�q˜#ÑÔˆØ�hŠh�q˜#ÑÔˆØ�C˜ˆ}Ðr"   c                ó   — t           ‚)z Returns GCD of ``a`` and ``b``. r   r   s      r    rC  z
Domain.gcd  r  r"   c                ó   — t           ‚)z Returns LCM of ``a`` and ``b``. r   r   s      r    Úlcmz
Domain.lcm  r  r"   c                ó   — t           ‚)z#Returns b-base logarithm of ``a``. r   r   s      r    Úlogz
Domain.log  r  r"   c                ó   — t           ‚)aJ  Returns a (possibly inexact) square root of ``a``.

        Explanation
        ===========
        There is no universal definition of "inexact square root" for all
        domains. It is not recommended to implement this method for domains
        other then :ref:`ZZ`.

        See also
        ========
        exsqrt
        r   r_   s     r    ÚsqrtzDomain.sqrt!  r.  r"   c                ó   — t           ‚)aŽ  Returns whether ``a`` is a square in the domain.

        Explanation
        ===========
        Returns ``True`` if there is an element ``b`` in the domain such that
        ``b * b == a``, otherwise returns ``False``. For inexact domains like
        :ref:`RR` and :ref:`CC`, a tiny difference in this equality can be
        tolerated.

        See also
        ========
        exsqrt
        r   r_   s     r    Ú	is_squarezDomain.is_square0  s
   € õ "Ð!r"   c                ó   — t           ‚)a'  Principal square root of a within the domain if ``a`` is square.

        Explanation
        ===========
        The implementation of this method should return an element ``b`` in the
        domain such that ``b * b == a``, or ``None`` if there is no such ``b``.
        For inexact domains like :ref:`RR` and :ref:`CC`, a tiny difference in
        this equality can be tolerated. The choice of a "principal" square root
        should follow a consistent rule whenever possible.

        See also
        ========
        sqrt, is_square
        r   r_   s     r    ÚexsqrtzDomain.exsqrt@  s
   € õ "Ð!r"   c                óD   —  |                       |¦  «        j        |fi |¤ŽS )z*Returns numerical approximation of ``a``. )rc   Úevalf)r   r`   r±   Úoptionss       r    rS  zDomain.evalfQ  s)   € à%ˆt�}Š}˜QÑÔÔ% dÐ6Ð6¨gÐ6Ð6Ð6r"   c                ó   — |S r   rj   r_   s     r    ÚrealzDomain.realW  s   € Øˆr"   c                ó   — | j         S r   )r   r_   s     r    ÚimagzDomain.imagZ  s
   € ØŒyÐr"   c                ó   — ||k    S )z+Check if ``a`` and ``b`` are almost equal. rj   )r   r`   r!  Ú	tolerances       r    ÚalmosteqzDomain.almosteq]  r  r"   c                ó    — t          d¦  «        ‚)z*Return the characteristic of this domain. zcharacteristic()r   r   s    r    r´   zDomain.characteristica  s   € å!Ð"4Ñ5Ô5Ð5r"   r   )Nrò   )Frû   Nrò   )‡r+   Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   r   Úis_Ringr¤   r¥   Úhas_assoc_FieldÚis_FiniteFieldÚis_FFrÈ   Úis_ZZrÇ   Úis_QQrÁ   Úis_ZZ_IrÂ   Úis_QQ_Ir¾   Úis_RRr½   Úis_CCrÃ   Úis_Algebraicr£   Úis_Polyr¢   Úis_FracÚis_SymbolicDomainr¶   Úis_SymbolicRawDomainrµ   r·   Úis_ExactrW   r  r™   Úis_PIDr³   r   r   r!   r$   r'   r,   r1   Úpropertyr4   r6   r8   rE   rX   rP   ra   rc   rZ   rg   rn   rq   rs   ru   rw   ry   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	  r  r  r  r  r  r  r  r  r  r"  r%  r'  r)  r+  r-  r0  r2  r4  r6  r8  r:  r@  r<  rF  rC  rI  rK  rM  rO  rQ  rS  rÿ   rV  rX  r[  r´   rj   r"   r    r   r      s  € € € € € € ðhð hðT €EÐÐÐÑðð, €DÐÐÐÑðð €C€O€O€O�Oðð €Gðð$ €Hðð" €Nðð  €Oðð  #Ð"€N�UØ"Ð"€N�UØ$Ð$Ð�uØ %Ð%€O�gØ!&Ð&Ð�wØ Ð €L�5Ø#Ð#€O�eØ',Ð,Ð˜Ø"'Ð'Ð˜Ø!&Ð&Ð�wØ %Ð%Ð˜Ø&+Ð+Ð˜8ØÐà€HØ€Là€IØ€Là€Fðð" #Ðà€CÐÐÐÑØ€EÐÐÐÑð"ð "ð "ðð ð ðð ð ð;ð ;ð ;ð!ð !ð !ð ðð ñ „Xððð ð ð!ð !ð !ðrð rð rð"Adð Adð Adð AdðF,ð ,ð ,ð	ð 	ð 	ð["ð ["ð ["ðz"ð "ð "ð8*ð *ð *ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ð,ð ,ð ,ð
ð ð ð/ð /ð /ð#ð #ð #ð ð  ð  ð.ð .ð .ð
,ð ,ð ,ðð ð ð+ð +ð +ðBð ð ð ðBGð Gð Gð
!ð !ð !ð
ð 
ð 
ðHð Hð HðIð Ið Iðð ð ð+ð +ð +ð ),ð 4ð 4ð 4ð 4ð 4ð
 *-ð 3ð 3ð 3ð 3ð 3ð
8ð 8ð 8ð
7ð 7ð 7ð
 15ð Jð Jð Jð Jð Jð(8ð (8ð (8ð (8ðT(?ð (?ð (?ð (?ðT"ð "ð "ð"ð "ð "ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ðð ð ðY"ð Y"ð Y"ðv"ð "ð "ð"ð "ð "ðT"ð T"ð T"ðl"ð "ð "ð"ð "ð "ð"ð "ð "ð"ð "ð "ðð ð ð
"ð "ð "ðð ð ð"ð "ð "ð"ð "ð "ð"ð "ð "ð"ð "ð "ð"ð "ð "ð "ð "ð "ð"7ð 7ð 7ð 7ð 	€Aðð ð ðð ð ðð ð ð ð6ð 6ð 6ð 6ð 6r"   r   N)r_  Ú
__future__r   Útypingr   Úsympy.core.numbersr   Ú
sympy.corer   r   Úsympy.core.sortingr   Úsympy.external.gmpyr	   Ú!sympy.polys.domains.domainelementr
   Úsympy.polys.orderingsr   Úsympy.polys.polyerrorsr   r   r   Úsympy.polys.polyutilsr   r   Úsympy.utilitiesr   Úsympy.utilities.iterablesr   r   Ú__all__rj   r"   r    ú<module>r€     sE  ðØ /Ð /à "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð à .Ð .Ð .Ð .Ð .Ð .Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %Ø &Ð &Ð &Ð &Ð &Ð &Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø %Ð %Ð %Ð %Ð %Ð %Ø QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QÐ QØ ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø "Ð "Ð "Ð "Ð "Ð "Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1ð ðP6ð P6ð P6ð P6ð P6ñ P6ô P6ñ „ðP6ðf* ˆ*€€€r"   