ó
    ‰*£h% ã                  óX  • S SK Jr  S SKJr  S SKrS SKrS SKrS SKrSSKJ	r	  SSK
JrJrJ
r
JrJrJr  SSKJrJr  SSKJr  SS	KJrJr  SS
KJr  SSKJrJr  SSKJr  SSKJ r J!r!J"r"J#r#J$r$  SSK%J&r&  SSK'J(r(  SSK)J*r*  S SK+J,r,J-r-J.r.  S SK/J0r0  S SK1r1S SK2J3r4  S SK2J5r5J6r7  S SK8J9r9  S SK2J:r:J;r;J<r<J=r=  S SK>J?r?  S SK@JArBJCrDJErFJGrGJHrIJJrJJKrK  S SKLJMrM  S SKNJOrO  SSKPJQrQ  \R¤                  " S5      rSSdS jrTS rUSS0rVSeS  jrWS! rXS" rY\ZR·                  \\R»                  S#5      5      r^S$ r_ " S% S&\5      r` " S' S(\`5      ra\a=\\b'   \\RÆ                  '   \ard " S) S*\`5      re " S+ S,\e5      rf\f\\g'    " S- S.\5      rh " S/ S0\e5      ri " S1 S2\f5      rj " S3 S4\j\S59rk " S6 S7\j\S59rl " S8 S9\j\S59rm " S: S;\i\S59rn " S< S=\`\S59ro\RÞ                  rp " S> S?\`\S59rq " S@ SA\`\S59rr\Rä                  rs\0" \r\5      SB 5       rt " SC SD\\S59ru\Rê                  rv " SE SF\5      rw " SG SH\w\S59rx\Rð                  ry " SI SJ\w\S59rz\Rô                  r{ " SK SL\w\S59r| " SM SN\w\S59r} " SO SP\w\S59r~ " SQ SR\w\S59r " SS ST\\S59r€\GR                   r�SU r‚SV rƒSfSW jr„\0" \	\`5      SX 5       rtSY r…\…\\GR                  '   \-b?  SZ r‡S[ rˆ\‡\\‰" \-GR                  " S5      5      '   \ˆ\\‰" \-GR                  " SS5      5      '   \.b?  S\ rŒS] r�\Œ\\‰" \.GR                  " S5      5      '   \�\\‰" \.GR                  " SS5      5      '   S^ r�\�\\?'   S_ r‘\‘\\’'   SS`K“J”r”  SSaK•J–r–  \l" 5       \–l—        SSbK˜J™r™  \k" 5       \™l—        Sc rš\š" 5         \Rä                  \RÞ                  \Râ                  \Rê                  4r›g)gé    )Úannotations)ÚoverloadNé   )ÚTuple)ÚSympifyErrorÚ_sympy_converterÚsympifyÚ_convert_numpy_typesÚ_sympifyÚ_is_numpy_instance)ÚSÚ	Singleton)ÚBasic)ÚExprÚ
AtomicExpr)Úpure_complex)ÚcacheitÚclear_cache)Ú
_sympifyit)Ú
num_digitsÚigcdÚilcmÚmod_inverseÚinteger_nthroot)Ú	fuzzy_not)Ú
NumberKind)Úordered)Ú
SYMPY_INTSÚgmpyÚflint)Údispatch)ÚbitcountÚround_nearest©ÚMPZ)Úmpf_powÚmpf_piÚmpf_eÚ	phi_fixed)Ú	mpnumeric)ÚfinfÚfninfÚfnanÚfzeroÚ
_normalizeÚprec_to_dpsÚdps_to_prec)Údebug)Úsympy_deprecation_warning)Úglobal_parametersé   c                óÂ  • [        U[        5      (       a(  [        U SS9(       d  [        S5      e[        U 5      U:H  $ U (       d  XpU (       d  gU(       GdÚ  XpCUS:X  a  [        U5      [        U5      :H  $ UGc·  [	        U5      [	        U5      pC[        S X44 5       5      (       d  [        S5      eUR                  [        5      nUR                  [        5      nU(       d  U(       d  X4:H  $ [        S5       HW  n[        USS9nU(       a  M  U(       a6  UR                  [        [        S U 5       5      5      5      n[        USS9n  OXepeXCpCMY     [        U5      n	U	(       d;  U(       a4  UR                  [        [        S	 U 5       5      5      5      n[        USS9n	W(       a6  U	(       a/  US
   (       d
  U	S
   (       a  [        S [        X‰5       5       5      $ S[        [        UR                  [        USUR                  5      5      5      -  n[        [!        X4-
  5      U-  5      S:*  $ [!        X-
  5      n
[!        U 5      nU(       a  US
:”  a  X«-  U:*  $ X¢:*  $ )a  Return a bool indicating whether the error between z1 and z2
is $\le$ ``tol``.

Examples
========

If ``tol`` is ``None`` then ``True`` will be returned if
:math:`|z1 - z2|\times 10^p \le 5` where $p$ is minimum value of the
decimal precision of each value.

>>> from sympy import comp, pi
>>> pi4 = pi.n(4); pi4
3.142
>>> comp(_, 3.142)
True
>>> comp(pi4, 3.141)
False
>>> comp(pi4, 3.143)
False

A comparison of strings will be made
if ``z1`` is a Number and ``z2`` is a string or ``tol`` is ''.

>>> comp(pi4, 3.1415)
True
>>> comp(pi4, 3.1415, '')
False

When ``tol`` is provided and $z2$ is non-zero and
:math:`|z1| > 1` the error is normalized by :math:`|z1|`:

>>> abs(pi4 - 3.14)/pi4
0.000509791731426756
>>> comp(pi4, 3.14, .001)  # difference less than 0.1%
True
>>> comp(pi4, 3.14, .0005)  # difference less than 0.1%
False

When :math:`|z1| \le 1` the absolute error is used:

>>> 1/pi4
0.3183
>>> abs(1/pi4 - 0.3183)/(1/pi4)
3.07371499106316e-5
>>> abs(1/pi4 - 0.3183)
9.78393554684764e-6
>>> comp(1/pi4, 0.3183, 1e-5)
True

To see if the absolute error between ``z1`` and ``z2`` is less
than or equal to ``tol``, call this as ``comp(z1 - z2, 0, tol)``
or ``comp(z1 - z2, tol=tol)``:

>>> abs(pi4 - 3.14)
0.00160156249999988
>>> comp(pi4 - 3.14, 0, .002)
True
>>> comp(pi4 - 3.14, 0, .001)
False
T)Úor_realz$when z2 is a str z1 must be a NumberÚ c              3  ó8   #   • U  H  oR                   v •  M     g 7f©N)Ú	is_number©Ú.0Úis     ÚO/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/core/numbers.pyÚ	<genexpr>Úcomp.<locals>.<genexpr>u   s   é € Ð3ªF q—{–{ªFùó   ‚zexpecting 2 numbersr5   c              3  ó8   #   • U  H  oR                   v •  M     g 7fr:   ©Ú_precr<   s     r?   r@   rA   �   s   é € Ð/DÂ¸A·¶ÂùrB   c              3  ó8   #   • U  H  oR                   v •  M     g 7fr:   rD   r<   s     r?   r@   rA   ‰   s   é € Ð'<º°A¯®ºùrB   r   c              3  ó<   #   • U  H  u  p[        X5      v •  M     g 7fr:   )Úcomp)r=   r>   Újs      r?   r@   rA   Œ   s   é € Ð>²+©$¨!œ4 Ÿ:˜:²+ùs   ‚é
   rE   é   )Ú
isinstanceÚstrr   Ú
ValueErrorr	   ÚallÚatomsÚFloatÚrangeÚnr0   ÚminÚziprE   ÚgetattrÚintÚabs)Úz1Úz2ÚtolÚaÚbÚfaÚfbÚ_ÚcaÚcbÚdiffÚaz1s               r?   rH   rH   *   sê  € ôz �"”c×ÑÜ˜B¨×-ÜÐCÓDÐDÜ�2‹w˜"‰}ÐÞØˆBÞØßØˆ1Ø�"‹9Ü�q“6œS ›VÑ#Ð#ØŠ;Ü˜1“:œw q›zˆqÜÑ3¨Q©FÓ3×3Ñ3Ü Ð!6Ó7Ð7Ø—‘œ“ˆBØ—‘œ“ˆBÞžbà‘v�ä˜1–X�Ü! !¨TÑ2�ß�rÞØŸC™C¤¬CÑ/DÁÓ/DÓ,DÓ EÓF˜Ü)¨!°TÑ:˜Ùà!#˜BØ š1ñ ô ˜a“ˆBÞž"Ø—C‘Cœ¤CÑ'<¹Ó'<Ó$<Ó=Ó>�Ü! !¨TÑ2�Þ–b˜b Ÿe r¨!§uÜÑ>´#°b´+Ó>Ó>Ð>Ø”k¤# a§g¡g¬w°q¸'À1Ç7Á7Ó/KÓ"LÓMÑMˆCÜ”s˜1™5“z #‘~Ó&¨!Ñ+Ð+Üˆr‰w‹<€DÜ
ˆb‹'€CÞ	ˆc�A‹gØ‰x˜3‰Ðà‰{Ðó    c                óx   • U u  p#pEU(       d  U(       d  [         $ U $ SSKJn  [        X&" U5      XEU[        5      nU$ )aA  Return the mpf tuple normalized appropriately for the indicated
precision after doing a check to see if zero should be returned or
not when the mantissa is 0. ``mpf_normlize`` always assumes that this
is zero, but it may not be since the mantissa for mpf's values "+inf",
"-inf" and "nan" have a mantissa of zero, too.

Note: this is not intended to validate a given mpf tuple, so sending
mpf tuples that were not created by mpmath may produce bad results. This
is only a wrapper to ``mpf_normalize`` which provides the check for non-
zero mpfs that have a 0 for the mantissa.
r   r$   )r.   Úmpmath.libmp.backendr%   Úmpf_normalizeÚrnd)ÚmpfÚprecÚsignÚmanÚexptÚbcr%   Úrvs           r?   Úmpf_normrq   —   sB   € ð Ñ€DˆtÞö ÜˆLð ˆJõ )Ü	�t˜S ›X t°´sÓ	;€BØ€Ire   ÚdivideFc                óF   • [         S   U :w  a  [        5         U [         S'   gg)z€
Should SymPy raise an exception on 0/0 or return a nan?

divide == True .... raise an exception
divide == False ... return nan
rr   N)Ú_errdictr   )rr   s    r?   Úseterrru   ¸   s%   € ô �Ñ˜VÓ#ÜŒØ#Œ�Òð $re   c                óÒ   • [        U S[        R                  " U 5      R                  5      u  pp4SS/US-     U-  n US:  a  SU* -  nO
SnU SU-  -  n [	        U 5      [	        U5      4$ )NÚ_mpf_r   éÿÿÿÿr5   r   )rV   Úmpmathrj   rw   rW   )ÚpÚneg_powrm   rn   r`   Úqs         r?   Ú_as_integer_ratior}   Ä   sp   € Ü# A w´·
²
¸1³×0CÑ0CÓDÑ€G�$Ø	
ˆBˆ�˜!‘Ñ˜SÑ €AØˆaƒxØ�ˆu‰H‰àˆØ	ˆQ�‰W‰ˆÜˆq‹6”3�q“6ˆ>Ðre   c                ó:  • U R                  5       (       d  [        SU -  5      eU R                  5       u  pn[        U5      nUS:¼  a  [	        [        U 5      5      nXT4$ SU-  n[        S [        [        U5      5       5       5      n[        X-  SU* -  5      nXT4$ )z3Convert an ordinary decimal instance to a Rational.zdec must be finite, got %s.r   rx   c              3  ó6   #   • U  H  u  pUS U-  -  v •  M     g7f)rJ   N© )r=   r>   Údis      r?   r@   Ú,_decimal_to_Rational_prec.<locals>.<genexpr>Ù   s   é € Ð=Ò&<™U˜Q��2�q‘5–Ò&<ùs   ‚rJ   )
Ú	is_finiteÚ	TypeErrorÚas_tupleÚlenÚIntegerrW   ÚsumÚ	enumerateÚreversedÚRational)ÚdecÚsÚdÚerk   rp   s         r?   Ú_decimal_to_Rational_precr�   Ï   s“   € à�=‰=�?‰?ÜÐ5¸Ñ;Ó<Ð<Ø�l‰l‹n�G€Aˆ!Üˆq‹6€DØˆAƒvÜ”S˜“XÓˆð
 ˆ8€Oð �!‰GˆÜÑ=¤i´¸³Ô&<Ó=Ó=ˆÜ�a‘c˜2 ˜r™6Ó"ˆØˆ8€Ore   Ú
1234567890c                ó:  • U R                  S5      n[        U5      S:”  a  g[        U5      S:X  a1  Uu  p#UR                  [        S5      5      (       a  USS nU(       d  gOU Sp2UR                  S5      n[        U5      S:”  a  g[        U5      S:X  a  Uu  pEOUSpTU(       d  U(       d  gU(       a  US	   S;   a  USS nU(       d  SnU=(       d    SnXEU4 H?  nUR                  S
5       H'  nU(       a  UR	                  [
        5      (       d  M&      g   MA     g)a9  return True if s is space-trimmed number literal else False

Python allows underscore as digit separators: there must be a
digit on each side. So neither a leading underscore nor a
double underscore are valid as part of a number. A number does
not have to precede the decimal point, but there must be a
digit before the optional "e" or "E" that begins the signs
exponent of the number which must be an integer, perhaps with
underscore separators.

SymPy allows space as a separator; if the calling routine replaces
them with underscores then the same semantics will be enforced
for them as for underscores: there can only be 1 *between* digits.

We don't check for error from float(s) because we don't know
whether s is malicious or not. A regex for this could maybe
be written but will it be understood by most who read it?
r�   r5   Fz+-r   NÚ1Ú.r   r`   T)Úsplitr†   Ú
startswithÚtupleÚ	translateÚ_dig)r�   ÚpartsÚmr�   r>   ÚfrS   Úgs           r?   Ú_literal_floatrž   ß   s  € ð( �G‰G�C‹L€EÜ
ˆ5ƒz�Aƒ~ØÜ
ˆ5ƒz�QƒØ‰ˆØ�<‰<œ˜d›×$Ñ$Ø�!�"�ˆAÞØð ð �#ˆ1à�G‰G�C‹L€EÜ
ˆ5ƒz�Aƒ~ØÜ	ˆU‹�q‹Ø‰ˆˆ1à�#ˆ1Þ–QØÞˆQˆq‰T�T‹\ØˆaˆbˆEˆÞØˆØ	�ˆS€Aà�A‹YˆØ—‘˜–ˆAÞ˜Ÿ™¤D×)Ó)Úó ñ ð re   c                  óÚ  ^ • \ rS rSrSrSrSrSrSrSr	\
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 5       r\S0S j5       rS1S jr \!S2S j5       r"\!S3S j5       r"\#" S\$5      S4S j5       r"\#" S\$5      S 5       r%\#" S\$5      S 5       r&\#" S\$5      S 5       r'S  r(S! r)S" r*S# r+S$ r,S% r-U 4S& jr.S' r/SS(.S) jr0S* r1S5S+ jr2S5S, jr3S- r4S. r5S/ r6Sr7U =r8$ )6ÚNumberi  a�  Represents atomic numbers in SymPy.

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

Floating point numbers are represented by the Float class.
Rational numbers (of any size) are represented by the Rational class.
Integer numbers (of any size) are represented by the Integer class.
Float and Rational are subclasses of Number; Integer is a subclass
of Rational.

For example, ``2/3`` is represented as ``Rational(2, 3)`` which is
a different object from the floating point number obtained with
Python division ``2/3``. Even for numbers that are exactly
represented in binary, there is a difference between how two forms,
such as ``Rational(1, 2)`` and ``Float(0.5)``, are used in SymPy.
The rational form is to be preferred in symbolic computations.

Other kinds of numbers, such as algebraic numbers ``sqrt(2)`` or
complex numbers ``3 + 4*I``, are not instances of Number class as
they are not atomic.

See Also
========

Float, Integer, Rational
Tr€   rx   c                ó  • [        U5      S:X  a  US   n[        U[        5      (       a  U$ [        U[        5      (       a  [	        U5      $ [        U[
        5      (       a  [        U5      S:X  a  [        U6 $ [        U[        [        R                  [        R                  45      (       a  [        U5      $ [        U[        5      (       a˜  UR                  5       nUS:X  a  [        R                   $ US:X  a  [        R"                  $ US:X  a  [        R"                  $ US:X  a  [        R$                  $ ['        U5      n[        U[        5      (       a  U$ [)        SU-  5      eS	n[+        U[-        U5      R.                  -  5      e)
Nr   r   r5   ÚnanÚinfú+infú-infz$String "%s" does not denote a Numberz<expected str|int|long|float|Decimal|Number object but got %r)r†   rL   r    r   r‡   r—   r‹   Úfloatry   rj   ÚdecimalÚDecimalrQ   rM   Úlowerr   ÚNaNÚInfinityÚNegativeInfinityr	   rN   r„   ÚtypeÚ__name__)ÚclsÚobjÚ_objÚvalÚmsgs        r?   Ú__new__ÚNumber.__new__@  s.  € Üˆs‹8�q‹=Ø�a‘&ˆCä�cœ6×"Ñ"ØˆJÜ�cœ:×&Ñ&Ü˜3“<ÐÜ�cœ5×!Ñ!¤c¨#£h°!£mÜ˜S�>Ð!Ü�cœE¤6§:¡:¬w¯©Ð?×@Ñ@Ü˜“:ÐÜ�cœ3×ÑØ—9‘9“;ˆDØ�u‹}Ü—u‘u�Ø˜“Ü—z‘zÐ!Ø˜“Ü—z‘zÐ!Ø˜“Ü×)Ñ)Ð)Ü˜#“,ˆCÜ˜#œv×&Ñ&Ø�
ä Ð!GÈ#Ñ!MÓNÐNØLˆÜ˜œd 3›i×0Ñ0Ñ0Ó1Ð1re   c                ó,   • [        U R                  5      $ r:   )ÚboolÚis_extended_negative©Úselfs    r?   Úcould_extract_minus_signÚNumber.could_extract_minus_sign^  s   € Ü�D×-Ñ-Ó.Ð.re   c                ó`   • SSK Jn  [        USS5      (       a  [        X5      $ U" X/UQ70 UD6$ )Nr   )Úinvertr;   T)Úsympy.polys.polytoolsr¾   rV   r   )rº   ÚotherÚgensÚargsr¾   s        r?   r¾   ÚNumber.inverta  s4   € Ý0Ü�5˜+ t×,Ñ,Ü˜tÓ+Ð+Ù�dÐ1 DÒ1¨DÑ1Ð1re   c                óP  • SSK Jn   [        U5      nU R                  (       d  [        R
                  X4;   a   [        R
                  [        R
                  4$  U(       d  [        S5      eU R                  (       a7  UR                  (       a&  [        [        U R                  UR                  5      6 $ [        U[        5      (       a  U [        U5      -  nOX-  nUR                   (       ar  US:¼  a  [#        U5      O[#        U5      S-
  nXU-  -
  nU[        U5      :X  a  US-  nSn[        U [        5      (       d  [        U[        5      (       a  [        U5      nO(U (       a  U" U 5      U" U5      :X  a  SOSnU(       a  UOU n[        XE5      $ ! [         a	    [        s $ f = f)Nr   )rl   zmodulo by zeror   rx   )Ú$sympy.functions.elementary.complexesrl   r    Úis_infiniter   rª   r„   ÚNotImplementedÚZeroDivisionErrorÚ
is_Integerr   Údivmodrz   rL   rQ   r‹   rƒ   rW   )rº   rÀ   rl   ÚratÚwÚrs         r?   Ú
__divmod__ÚNumber.__divmod__g  sF  € Ý=ð	"Ü˜5“MˆEØ××¤1§5¡5¨T¨MÓ#9ÜŸ™œqŸu™u�~Ð%ð $:ö Ü#Ð$4Ó5Ð5Ø�?�?˜u×/×/Üœ& §¡¨¯©Ó1Ð2Ð2Ü˜œu×%Ñ%Ø”x “Ñ&‰Cà‘*ˆCØ�?�?Ø 1›H”�C”¬#¨c«(°Q©,ˆAØ˜Q‘w‘ˆAØ”E˜%“LÓ Ø�Q‘�Ø�Ü˜$¤×&Ñ&¬*°U¼E×*BÑ*BÜ˜!“H�øæ¡$ t£*±°U³Ó";‘À"ˆAÞ‘ ˆAÜ�Q‹{Ðøô+ ó 	"Ü!Ò!ð	"ús   ˆAF ÆF%Æ$F%c                ó\   •  [        U5      n[        X5      $ ! [         a	    [        s $ f = fr:   )r    r„   rÇ   rÊ   ©rº   rÀ   s     r?   Ú__rdivmod__ÚNumber.__rdivmod__…  s4   € ð	"Ü˜5“MˆEô �eÓ"Ð"øô ó 	"Ü!Ò!ð	"ús   ‚ ˜+ª+c                óF   • [        SU R                  R                  -  5      e)z7Evaluation of mpf tuple accurate to at least prec bits.z%s needs ._as_mpf_val() method©ÚNotImplementedErrorÚ	__class__r®   ©rº   rk   s     r?   Ú_as_mpf_valÚNumber._as_mpf_valŒ  s$   € ä!Ð"BØ�^‰^×$Ñ$ñ#&ó 'ð 	're   c                óL   • [         R                  U R                  U5      U5      $ r:   ©rQ   Ú_newrÙ   rØ   s     r?   Ú_eval_evalfÚNumber._eval_evalf‘  ó   € Ü�z‰z˜$×*Ñ*¨4Ó0°$Ó7Ð7re   c                óR   • [        XR                  5      nU R                  U5      U4$ r:   )ÚmaxrE   rÙ   rØ   s     r?   Ú
_as_mpf_opÚNumber._as_mpf_op”  s&   € Ü�4Ÿ™Ó$ˆØ×Ñ Ó% tÐ+Ð+re   c                óL   • [         R                  " U R                  S5      5      $ )Né5   )ÚmlibÚto_floatrÙ   r¹   s    r?   Ú	__float__ÚNumber.__float__˜  s   € Ü�}Š}˜T×-Ñ-¨bÓ1Ó2Ð2re   c                óF   • [        SU R                  R                  -  5      e)Nz%s needs .floor() methodrÕ   r¹   s    r?   ÚfloorÚNumber.floor›  s$   € Ü!Ð"<Ø�^‰^×$Ñ$ñ#&ó 'ð 	're   c                óF   • [        SU R                  R                  -  5      e)Nz%s needs .ceiling() methodrÕ   r¹   s    r?   ÚceilingÚNumber.ceilingŸ  s$   € Ü!Ð">Ø�^‰^×$Ñ$ñ#&ó 'ð 	're   c                ó"   • U R                  5       $ r:   ©rì   r¹   s    r?   Ú	__floor__ÚNumber.__floor__£  ó   € Ø�z‰z‹|Ðre   c                ó"   • U R                  5       $ r:   ©rï   r¹   s    r?   Ú__ceil__ÚNumber.__ceil__¦  ó   € Ø�|‰|‹~Ðre   c                ó   • U $ r:   r€   r¹   s    r?   Ú_eval_conjugateÚNumber._eval_conjugate©  ó   € Øˆre   c                ó<   • SSK Jn  U" [        R                  /UQ76 $ )Nr   )ÚOrder)Úsympy.series.orderr   r   ÚOne)rº   Úsymbolsr   s      r?   Ú_eval_orderÚNumber._eval_order¬  s   € Ý,á”Q—U‘UÐ%˜WÒ%Ð%re   c                ó   • X* :X  a  U* $ U $ r:   r€   ©rº   ÚoldÚnews      r?   Ú
_eval_subsÚNumber._eval_subs±  s   € Ø�%‹<Ø�4ˆKØˆre   c                ó   • g)N)r   r   r    r€   ©r¯   s    r?   Ú	class_keyÚNumber.class_key¶  s   € àre   c                ó*   • U R                  5       SSU 4$ )N)r   r€   r€   )r  )rº   Úorders     r?   Úsort_keyÚNumber.sort_keyº  s   € à�~‰~Ó ¨"¨dÐ2Ð2re   c                ó   • [         er:   ©rÖ   r¹   s    r?   Ú__neg__ÚNumber.__neg__¾  s   € Ü!Ð!re   rÀ   c                ó   • g r:   r€   rÑ   s     r?   Ú__add__ÚNumber.__add__Á  s   € Ø>Are   c                ó   • g r:   r€   rÑ   s     r?   r  r  Ã  s   € Ø,/re   c                óT  • [        U[        5      (       a~  [        R                  (       ai  U[        R
                  L a  [        R
                  $ U[        R                  L a  [        R                  $ U[        R                  L a  [        R                  $ [        R                  " X5      $ r:   )
rL   r    r4   Úevaluater   rª   r«   r¬   r   r  rÑ   s     r?   r  r  Æ  sm   € ä�eœV×$Ñ$Ô):×)C×)CØœŸ™Š~Ü—u‘u�Øœ!Ÿ*™*Ò$Ü—z‘zÐ!Øœ!×,Ñ,Ò,Ü×)Ñ)Ð)Ü×!Ò! $Ó.Ð.re   c                óT  • [        U[        5      (       a~  [        R                  (       ai  U[        R
                  L a  [        R
                  $ U[        R                  L a  [        R                  $ U[        R                  L a  [        R                  $ [        R                  " X5      $ r:   )
rL   r    r4   r  r   rª   r«   r¬   r   Ú__sub__rÑ   s     r?   r  ÚNumber.__sub__Ñ  sm   € ä�eœV×$Ñ$Ô):×)C×)CØœŸ™Š~Ü—u‘u�Øœ!Ÿ*™*Ò$Ü×)Ñ)Ð)Øœ!×,Ñ,Ò,Ü—z‘zÐ!Ü×!Ò! $Ó.Ð.re   c                ó–  • [        U[        5      (       Ga  [        R                  (       aî  U[        R
                  L a  [        R
                  $ U[        R                  L aR  U R                  (       a  [        R
                  $ U R                  (       a  [        R                  $ [        R                  $ U[        R                  L aR  U R                  (       a  [        R
                  $ U R                  (       a  [        R                  $ [        R                  $ O[        U[        5      (       a  [        $ [        R                  " X5      $ r:   )rL   r    r4   r  r   rª   r«   Úis_zeroÚis_positiver¬   r   rÇ   r   Ú__mul__rÑ   s     r?   r$  ÚNumber.__mul__Ü  sÏ   € ä�eœV×$Ò$Ô):×)C×)CØœŸ™Š~Ü—u‘u�Øœ!Ÿ*™*Ò$Ø—<—<ÜŸ5™5�LØ×%×%ÜŸ:™:Ð%ä×-Ñ-Ð-Øœ!×,Ñ,Ò,Ø—<—<ÜŸ5™5�LØ×%×%Ü×-Ñ-Ð-äŸ:™:Ð%ð -ô ˜œu×%Ñ%Ü!Ð!Ü×!Ò! $Ó.Ð.re   c                ó0  • [        U[        5      (       al  [        R                  (       aW  U[        R
                  L a  [        R
                  $ U[        R                  [        R                  4;   a  [        R                  $ [        R                  " X5      $ r:   )rL   r    r4   r  r   rª   r«   r¬   ÚZeror   Ú__truediv__rÑ   s     r?   r(  ÚNumber.__truediv__ó  s]   € ä�eœV×$Ñ$Ô):×)C×)CØœŸ™Š~Ü—u‘u�Øœ1Ÿ:™:¤q×'9Ñ'9Ð:Ó:Ü—v‘v�Ü×%Ò% dÓ2Ð2re   c                óF   • [        SU R                  R                  -  5      e)Nz%s needs .__eq__() methodrÕ   rÑ   s     r?   Ú__eq__ÚNumber.__eq__ü  ó$   € Ü!Ð"=Ø�^‰^×$Ñ$ñ#&ó 'ð 	're   c                óF   • [        SU R                  R                  -  5      e)Nz%s needs .__ne__() methodrÕ   rÑ   s     r?   Ú__ne__ÚNumber.__ne__   r-  re   c                ó    •  [        U5      n[        SU R                  R
                  -  5      e! [         a    [        SU < SU< 35      ef = f)NúInvalid comparison z < z%s needs .__lt__() method©r   r   r„   rÖ   r×   r®   rÑ   s     r?   Ú__lt__ÚNumber.__lt__  sX   € ð	JÜ˜U“OˆEô "Ð"=Ø�^‰^×$Ñ$ñ#&ó 'ð 	'øô ó 	JÝ»DÂ%ÐHÓIÐIð	Júó	   ‚/ ¯Ac                ó    •  [        U5      n[        SU R                  R
                  -  5      e! [         a    [        SU < SU< 35      ef = f)Nr2  z <= z%s needs .__le__() methodr3  rÑ   s     r?   Ú__le__ÚNumber.__le__  sX   € ð	KÜ˜U“OˆEô "Ð"=Ø�^‰^×$Ñ$ñ#&ó 'ð 	'øô ó 	KÝ»TÂ5ÐIÓJÐJð	Kúr6  c                ó�   •  [        U5      n[        U5      R                  U 5      $ ! [         a    [        SU < SU< 35      ef = f)Nr2  z > )r   r   r„   r4  rÑ   s     r?   Ú__gt__ÚNumber.__gt__  sK   € ð	JÜ˜U“OˆEô ˜‹×%Ñ% dÓ+Ð+øô ó 	JÝ»DÂ%ÐHÓIÐIð	Júó	   ‚' §Ac                ó�   •  [        U5      n[        U5      R                  U 5      $ ! [         a    [        SU < SU< 35      ef = f)Nr2  z >= )r   r   r„   r8  rÑ   s     r?   Ú__ge__ÚNumber.__ge__  sK   € ð	KÜ˜U“OˆEô ˜‹×%Ñ% dÓ+Ð+øô ó 	KÝ»TÂ5ÐIÓJÐJð	Kúr=  c                ó    >• [         TU ]  5       $ r:   ©ÚsuperÚ__hash__©rº   r×   s    €r?   rD  ÚNumber.__hash__"  ó   ø€ Ü‰wÑÓ!Ð!re   c                ó   • g)NTr€   )rº   ÚwrtÚflagss      r?   Úis_constantÚNumber.is_constant%  ó   € Øre   ©Úrationalc               óª   • U R                   (       d  U(       d  U S4$ U R                  (       a  [        R                  U * 44$ [        R                  U 44$ ©Nr€   )Úis_RationalÚis_negativer   ÚNegativeOner  )rº   rO  ÚdepsÚkwargss       r?   Úas_coeff_mulÚNumber.as_coeff_mul(  sB   € à××¦8Ø˜�8ˆOØ××Ü—=‘= D 5 (Ð*Ð*Ü�u‰u�t�gˆ~Ðre   c                óR   • U R                   (       a  U S4$ [        R                  U 44$ rQ  )rR  r   r'  )rº   rU  s     r?   Úas_coeff_addÚNumber.as_coeff_add0  s$   € à××Ø˜�8ˆOÜ�v‰v˜�wˆÐre   c                óX   • U(       d  U [         R                  4$ [         R                  U 4$ ©z1Efficiently extract the coefficient of a product.©r   r  ©rº   rO  s     r?   Úas_coeff_MulÚNumber.as_coeff_Mul6  s!   € æØœŸ™�;ÐÜ�u‰u�dˆ{Ðre   c                óX   • U(       d  U [         R                  4$ [         R                  U 4$ ©z3Efficiently extract the coefficient of a summation.©r   r'  r_  s     r?   Úas_coeff_AddÚNumber.as_coeff_Add<  s!   € æØœŸ™�<ÐÜ�v‰v�tˆ|Ðre   c                ó   • SSK Jn  U" X5      $ )z#Compute GCD of `self` and `other`. r   )Úgcd)r¿   rh  )rº   rÀ   rh  s      r?   rh  Ú
Number.gcdB  ó   € å-Ù�4ÓÐre   c                ó   • SSK Jn  U" X5      $ )z#Compute LCM of `self` and `other`. r   )Úlcm)r¿   rl  )rº   rÀ   rl  s      r?   rl  Ú
Number.lcmG  rj  re   c                ó   • SSK Jn  U" X5      $ )z1Compute GCD and cofactors of `self` and `other`. r   )Ú	cofactors)r¿   ro  )rº   rÀ   ro  s      r?   ro  ÚNumber.cofactorsL  s   € å3Ù˜Ó%Ð%re   r:   )Úreturnr    )rÀ   zNumber | int | floatrq  r    )rÀ   r   rq  r   )rq  r   ©F)9r®   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úis_commutativer;   Ú	is_NumberÚ	__slots__rE   r   Úkindr´   r»   r¾   rÎ   rÒ   rÙ   rÞ   rã   ré   rì   rï   ró   rø   rü   r  r
  Úclassmethodr  r   r  r  r   r  r   rÇ   r  r$  r(  r+  r/  r4  r8  r;  r?  rD  rK  rW  rZ  r`  re  rh  rl  ro  Ú__static_attributes__Ú__classcell__©r×   s   @r?   r    r      s„  ø† ñð6 €NØ€IØ€Ià€Ið €Eà€Dò2ò</ò2òò<#ò'ò
8ò,ò3ò'ò'òòòò&ò
ð
 ñó ðð ó3ó ð3ô"ð ÛAó ØAØÛ/ó Ø/á�˜Ó(ó/ó )ð/ñ �˜Ó(ñ/ó )ð/ñ �˜Ó(ñ/ó )ð/ñ, �˜Ó(ñ3ó )ð3ò'ò'ò'ò'ò,ò,õ"òð ,0õ òôôò ò
 ÷
&ð &re   r    c                  ó   • \ rS rSr% SrSrS\S'   SrSrSr	Sr
SrSr\R                  \R!                  S5      5      rS3S	 jr\S4S
 j5       rS rS rS rS rS rS r\S 5       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\*5      S 5       r+\)" S\*5      S  5       r,\)" S\*5      S! 5       r-\)" S\*5      S" 5       r.\)" S\*5      S# 5       r/\)" S\*5      S$ 5       r0S% r1S& r2S' r3S( r4S) r5S* r6S+ r7S, r8S- r9S. r:S/ r;S5S0 jr<S1 r=S2r>g)6rQ   iR  aa  Represent a floating-point number of arbitrary precision.

Examples
========

>>> from sympy import Float
>>> Float(3.5)
3.50000000000000
>>> Float(3)
3.00000000000000

Creating Floats from strings (and Python ``int`` and ``long``
types) will give a minimum precision of 15 digits, but the
precision will automatically increase to capture all digits
entered.

>>> Float(1)
1.00000000000000
>>> Float(10**20)
100000000000000000000.
>>> Float('1e20')
100000000000000000000.

However, *floating-point* numbers (Python ``float`` types) retain
only 15 digits of precision:

>>> Float(1e20)
1.00000000000000e+20
>>> Float(1.23456789123456789)
1.23456789123457

It may be preferable to enter high-precision decimal numbers
as strings:

>>> Float('1.23456789123456789')
1.23456789123456789

The desired number of digits can also be specified:

>>> Float('1e-3', 3)
0.00100
>>> Float(100, 4)
100.0

Float can automatically count significant figures if a null string
is sent for the precision; spaces or underscores are also allowed. (Auto-
counting is only allowed for strings, ints and longs).

>>> Float('123 456 789.123_456', '')
123456789.123456
>>> Float('12e-3', '')
0.012
>>> Float(3, '')
3.

If a number is written in scientific notation, only the digits before the
exponent are considered significant if a decimal appears, otherwise the
"e" signifies only how to move the decimal:

>>> Float('60.e2', '')  # 2 digits significant
6.0e+3
>>> Float('60e2', '')  # 4 digits significant
6000.
>>> Float('600e-2', '')  # 3 digits significant
6.00

Notes
=====

Floats are inexact by their nature unless their value is a binary-exact
value.

>>> approx, exact = Float(.1, 1), Float(.125, 1)

For calculation purposes, evalf needs to be able to change the precision
but this will not increase the accuracy of the inexact value. The
following is the most accurate 5-digit approximation of a value of 0.1
that had only 1 digit of precision:

>>> approx.evalf(5)
0.099609

By contrast, 0.125 is exact in binary (as it is in base 10) and so it
can be passed to Float or evalf to obtain an arbitrary precision with
matching accuracy:

>>> Float(exact, 5)
0.12500
>>> exact.evalf(20)
0.12500000000000000000

Trying to make a high-precision Float from a float is not disallowed,
but one must keep in mind that the *underlying float* (not the apparent
decimal value) is being obtained with high precision. For example, 0.3
does not have a finite binary representation. The closest rational is
the fraction 5404319552844595/2**54. So if you try to obtain a Float of
0.3 to 20 digits of precision you will not see the same thing as 0.3
followed by 19 zeros:

>>> Float(0.3, 20)
0.29999999999999998890

If you want a 20-digit value of the decimal 0.3 (not the floating point
approximation of 0.3) you should send the 0.3 as a string. The underlying
representation is still binary but a higher precision than Python's float
is used:

>>> Float('0.3', 20)
0.30000000000000000000

Although you can increase the precision of an existing Float using Float
it will not increase the accuracy -- the underlying value is not changed:

>>> def show(f): # binary rep of Float
...     from sympy import Mul, Pow
...     s, m, e, b = f._mpf_
...     v = Mul(int(m), Pow(2, int(e), evaluate=False), evaluate=False)
...     print('%s at prec=%s' % (v, f._prec))
...
>>> t = Float('0.3', 3)
>>> show(t)
4915/2**14 at prec=13
>>> show(Float(t, 20)) # higher prec, not higher accuracy
4915/2**14 at prec=70
>>> show(Float(t, 2)) # lower prec
307/2**10 at prec=10

The same thing happens when evalf is used on a Float:

>>> show(t.evalf(20))
4915/2**14 at prec=70
>>> show(t.evalf(2))
307/2**10 at prec=10

Finally, Floats can be instantiated with an mpf tuple (n, c, p) to
produce the number (-1)**n*c*2**p:

>>> n, c, p = 1, 5, 0
>>> (-1)**n*c*2**p
-5
>>> Float((1, 5, 0))
-5.00000000000000

An actual mpf tuple also contains the number of bits in c as the last
element of the tuple:

>>> _._mpf_
(1, 5, 0, 3)

This is not needed for instantiation and is not the same thing as the
precision. The mpf tuple and the precision are two separate quantities
that Float tracks.

In SymPy, a Float is a number that can be computed with arbitrary
precision. Although floating point 'inf' and 'nan' are not such
numbers, Float can create these numbers:

>>> Float('-inf')
-oo
>>> _.is_Float
False

Zero in Float only has a single value. Values are not separate for
positive and negative zeroes.
©rw   rE   ztuple[int, int, int, int]rw   NTz-+_.c           	     óÒ  • Ub  Ub  [        S5      e[        U[        5      (       aî  UR                  5       =pAUR	                  SS5      R                  5       nUR                  S5      (       a  [        U5      S:”  a  SU-   nGO!UR                  S5      (       a  [        U5      S:”  a
  S	USS  -   nGOòUS
;   a  [        R                  $ US:X  a  [        R                  $ US:X  a  [        R                  $ [        U5      (       d  [        SU-  5      eGO�[        U[        5      (       a
  US:X  a  SnGOq[        U[        5      (       a  U[        S5      :X  a  [        R                  $ [        U[        5      (       a  U[        S5      :X  a  [        R                  $ [        U[        5      (       a+  [        R                  " U5      (       a  [        R                  $ [        U[         ["        45      (       a  [        U5      nO¢U[        R                  L a  U$ U[        R                  L a  U$ U[        R                  L a  U$ [%        U5      (       a  ['        U5      nOG[        U[(        R*                  5      (       a(  Uc  Uc  UR,                  R.                  nUR0                  nUc   Uc�  Sn[        U[2        5      (       a  U$ [        U[        5      (       an   [4        R6                  " U5      nSU;  n[9        U5      u  pUR:                  (       a  U(       a  [=        U[?        U5      5      n[=        SU5      n[A        U5      nO”O“US:X  a  Ub	  Uc‡  US:X  a�  [        U[        5      (       d  [        S5      e [4        R6                  " U5      nSU;  n[9        U5      u  pUR:                  (       a'  U(       a   [=        U[?        U5      5      n[A        U5      nUb  US:X  a  [A        U5      n[E        U5      n[        U[        5      (       a  [F        RH                  " X[J        5      nGOl[        U[        5      (       a  [F        RL                  " X[J        5      nGO:[        U[4        R6                  5      (       a³  URO                  5       (       a'  [F        RL                  " [        U5      U[J        5      nGOßURQ                  5       (       a  [        R                  $ URS                  5       (       a&  US:”  a  [        R                  $ [        R                  $ [        S[        U5      -  5      e[        U[T        5      (       Ga  [        U5      S;   aø  [        US   [        5      (       aO  [W        U5      nUS   RY                  S5      R[                  S5      US'   []        US   S5      US'   [U        U5      nOÜ[        U5      S:X  a  [2        R_                  X5      $ [a        US   S;   US   S:¬  [a        S U 5       5      45      (       d  [        SU< 35      e[2        R_                  US   US   US   [c        US   5      4U5      $ [        U[d        [f        45      (       a  URi                  U5      nO[(        R*                  " XS9R0                  nU R_                  XsSS9$ ! [4        RB                   a     GNäf = f! [4        RB                   a    [        SU-  5      ef = f) Nz=Both decimal and binary precision supplied. Supply only one. Ú r`   r”   r   Ú0z-.r5   z-0.)r£   r¤   r¥   r¢   zstring-float not recognized: %sr   r£   é   r8   z^The null string can only be used when the number to Float is passed as a string or an integer.z*string-float not recognized by Decimal: %szunexpected decimal value %s)é   é   Ú0xÚLé   r†  )r   r   c              3  óR   #   • U  H  n[        U5      [        [        4;   v •  M     g 7fr:   )r­   rW   r<   s     r?   r@   Ú Float.__new__.<locals>.<genexpr>‹  s   é € ÐCºs¸!¤ Q£¬C´¨:Ö 5ºsùs   ‚%'zmalformed mpf: )rk   F)Úzero)5rN   rL   rM   ÚstripÚreplacer©   r–   r†   r   r«   r¬   rª   rž   r¦   ÚmathÚisnanr   r‡   r   r
   ry   rj   Úcontextrk   rw   rQ   r§   r¨   r�   rÉ   râ   r   r1   ÚInvalidOperationrW   rç   Ú
from_floatri   Úfrom_strrƒ   Úis_nanrÆ   r—   ÚlistÚremoveprefixÚremovesuffixr%   rÝ   rO   r"   r    ÚNumberSymbolrÙ   )r¯   ÚnumÚdpsÚ	precisionÚ_numÚNumÚisintrw   s           r?   r´   ÚFloat.__new__  s™  € Ø‰?˜yÑ4Üð 1ó 2ð 2ô �cœ3×ÑØŸ™›Ð$ˆDØ—+‘+˜c 3Ó'×-Ñ-Ó/ˆCØ�~‰~˜c×"Ñ"¤s¨3£x°!£|Ø˜C‘i’Ø—‘ ×%Ñ%¬#¨c«(°Q«,Ø˜c ! "˜g‘o’Ø˜Ó'Ü—z‘zÐ!Ø˜“Ü×)Ñ)Ð)Ø˜“Ü—u‘u�Ü# C×(Ñ(Ü Ð!BÀTÑ!IÓJÐJñ )ä˜œU×#Ñ#¨¨q«ØŠCÜ˜œU×#Ñ#¨¬u°U«|Ó(;Ü—:‘:ÐÜ˜œU×#Ñ#¨¬u°V«}Ó(<Ü×%Ñ%Ð%Ü˜œU×#Ñ#¬¯
ª
°3¯©Ü—5‘5ˆLÜ˜œj¬'Ð2×3Ñ3Ü�c“(‰CØ”A—J‘JÒØˆJØ”A×&Ñ&Ò&ØˆJØ”A—E‘EŠ\ØˆJÜ ×$Ñ$Ü& sÓ+‰CÜ˜œVŸZ™Z×(Ñ(ØÑ Ø‘;Ø #§¡× 0Ñ 0�IØ—)‘)ˆCà‰;˜9Ñ,ØˆCÜ˜#œu×%Ñ%Ø�
Ü˜#œs×#Ñ#ð1Ü!Ÿ/š/¨#Ó.�Cð   s™N�EÜ8¸Ó=‘H�CØ—~—~®%ô " #¤z°#£Ó7˜Ü˜b #›,�CÜ +¨CÓ 0‘Ið $ð ˜"‹_ ¡°	Ñ0AÀcÈRÃiÜ˜c¤3×'Ñ'Ü ð "Kó Lð Lð
1Ü—o’o cÓ*�ð  3™�Ü4°SÓ9‘�Ø—>—>¦eä˜c¤:¨c£?Ó3�CÜ +¨CÓ 0�Ið Ñ 	¨R£Ü# CÓ(ˆIä˜	“Nˆ	ä�cœ5×!Ñ!Ü—O’O C´CÓ8ŠEÜ˜œS×!Ñ!Ü—M’M #´#Ó6ŠEÜ˜œWŸ_™_×-Ñ-Ø�}‰}�‰ÜŸš¤c¨#£h°	¼3Ó?’Ø—‘—‘Ü—u‘u�Ø—‘×"Ñ"Ø˜“7ÜŸ:™:Ð%Ü×)Ñ)Ð)ä Ð!>ÄÀSÃÑ!IÓJÐJÜ˜œU×#Ò#¬¨C«°FÓ(:Ü˜#˜a™&¤#×&Ñ&ä˜3“i�ð ˜Q™×,Ñ,¨TÓ2×?Ñ?ÀÓD��A‘ä˜S ™V R›��A‘Ü˜c›
‘ä�s“8˜q“=ä Ÿ:™: cÓ5Ð5äØ ™F fÑ,Ø ™F a™KÜÑC¹sÓCÓCð ÷ ñ õ
 )ÂÐ)EÓFÐFô !Ÿ:™:Ø˜Q™  Q¡¨¨Q©´¸#¸a¹&Ó1AÐBØ!ó#ð #ô ˜œf¤lÐ3×4Ñ4Ø—O‘O IÓ.‰Eä—J’J˜sÑ3×9Ñ9ˆEà�x‰x˜¨uˆxÐ5Ð5øôs ×/Ñ/ó Úðûô" ×+Ñ+ó UÜ Ð!MÐPSÑ!SÓTÐTðUús   ËZ( Í;[ Ú([ Ú?[ Û#[&c                ó<  • U(       a  U[         :X  a  [        R                  $ U[        :X  a  [        R                  $ U[
        :X  a  [        R                  $ U[        :X  a  [        R                  $ [        R                  " U 5      n[        X5      Ul        X$l        U$ r:   )r.   r   r'  Ú_mpf_nanrª   Ú_mpf_infr«   Ú	_mpf_ninfr¬   r   r´   rq   rw   rE   )r¯   rw   rE   rŒ  r°   s        r?   rÝ   Ú
Float._newš  sq   € ö �EœU“NÜ—6‘6ˆMØ”hÓÜ—5‘5ˆLØ”hÓÜ—:‘:ÐØ”iÓÜ×%Ñ%Ð%ä�lŠl˜3ÓˆÜ˜UÓ*ˆŒ	ØŒ	Øˆ
re   c                óh   • U R                   u  pp4U[        U5      SS  X44nSU R                  0nU4U4$ )Nr5   rœ  )rw   ÚhexrE   )rº   rl   rm   Úexpro   ÚargrV  s          r?   Ú__getnewargs_ex__ÚFloat.__getnewargs_ex__«  sA   € Ø!ŸZ™ZÑˆ�3Ø”S˜“X˜a˜b�\ 3Ð+ˆØ˜tŸz™zÐ*ˆØ�˜ÐÐre   c                ó2   • U R                   U R                  4$ r:   r€  r¹   s    r?   Ú_hashable_contentÚFloat._hashable_content±  s   € Ø—
‘
˜DŸJ™JÐ'Ð're   c           
     ó¤   • [        [        [        R                  " [        R                  " U R
                  U R                  5      5      5      5      $ r:   )r‡   rW   rç   Úto_intÚ	mpf_floorrw   rE   r¹   s    r?   rì   ÚFloat.floor´  s7   € Ü”sœ4Ÿ;š;Ü�NŠN˜4Ÿ:™: t§z¡zÓ2ó4ó 5ó 6ð 	6re   c           
     ó¤   • [        [        [        R                  " [        R                  " U R
                  U R                  5      5      5      5      $ r:   )r‡   rW   rç   r°  Úmpf_ceilrw   rE   r¹   s    r?   rï   ÚFloat.ceiling¸  s7   € Ü”sœ4Ÿ;š;Ü�MŠM˜$Ÿ*™* d§j¡jÓ1ó3ó 4ó 5ð 	5re   c                ó"   • U R                  5       $ r:   rò   r¹   s    r?   ró   ÚFloat.__floor__¼  rõ   re   c                ó"   • U R                  5       $ r:   r÷   r¹   s    r?   rø   ÚFloat.__ceil__¿  rú   re   c                óB   • [         R                  " U R                  5      $ r:   )ry   rj   rw   r¹   s    r?   rš  Ú	Float.numÂ  s   € ä�zŠz˜$Ÿ*™*Ó%Ð%re   c                óœ   • [        U R                  U5      nX R                  :w  a&  U R                  U:X  a  [        U R                  U5        U$ r:   )rq   rw   rE   r2   ©rº   rk   rp   s      r?   rÙ   ÚFloat._as_mpf_valÆ  s:   € Ü�d—j‘j $Ó'ˆØ—‘Ó §
¡
¨dÓ 2Ü�$—*‘*˜bÔ!Øˆ	re   c                óD   • U R                   [        XR                  5      4$ r:   )rw   râ   rE   rØ   s     r?   rã   ÚFloat._as_mpf_opÌ  s   € Ø�z‰zœ3˜t§Z¡ZÓ0Ð0Ð0re   c                ó:   • U R                   [        [        4;   a  gg)NFT©rw   r£  r¤  r¹   s    r?   Ú_eval_is_finiteÚFloat._eval_is_finiteÏ  s   € Ø�:‰:œ(¤IÐ.Ó.ØØre   c                ó:   • U R                   [        [        4;   a  gg©NTFrÂ  r¹   s    r?   Ú_eval_is_infiniteÚFloat._eval_is_infiniteÔ  s   € Ø�:‰:œ(¤IÐ.Ó.ØØre   c                óP   • U R                   [        :X  a  g[        U 5      (       d  gg rÆ  )rw   r.   Ú
int_valuedr¹   s    r?   Ú_eval_is_integerÚFloat._eval_is_integerÙ  s$   € Ø�:‰:œÓØÜ˜$×ÑØð  re   c                óV   • U R                   [        [        4;   a  gU R                  S:  $ ©NFr   ©rw   r¤  r£  rš  r¹   s    r?   Ú_eval_is_negativeÚFloat._eval_is_negativeß  ó$   € Ø�:‰:œ)¤XÐ.Ó.ØØ�x‰x˜!‰|Ðre   c                óV   • U R                   [        [        4;   a  gU R                  S:„  $ rÎ  rÏ  r¹   s    r?   Ú_eval_is_positiveÚFloat._eval_is_positiveä  rÒ  re   c                ót   • U R                   [        :X  a  gU R                   [        :X  a  gU R                  S:  $ ©NTFr   rÏ  r¹   s    r?   Ú_eval_is_extended_negativeÚ Float._eval_is_extended_negativeé  s.   € Ø�:‰:œÓ"ØØ�:‰:œÓ!ØØ�x‰x˜!‰|Ðre   c                ót   • U R                   [        :X  a  gU R                   [        :X  a  gU R                  S:„  $ r×  )rw   r£  r¤  rš  r¹   s    r?   Ú_eval_is_extended_positiveÚ Float._eval_is_extended_positiveð  s.   € Ø�:‰:œÓ!ØØ�:‰:œÓ"ØØ�x‰x˜!‰|Ðre   c                ó(   • U R                   [        :H  $ r:   ©rw   r.   r¹   s    r?   Ú_eval_is_zeroÚFloat._eval_is_zero÷  ó   € Ø�z‰zœUÑ"Ð"re   c                ó(   • U R                   [        :g  $ r:   rÞ  r¹   s    r?   Ú__bool__ÚFloat.__bool__ú  rá  re   c                ó�   • U (       d  U $ [         R                  [        R                  " U R                  5      U R
                  5      $ r:   )rQ   rÝ   rç   Úmpf_negrw   rE   r¹   s    r?   r  ÚFloat.__neg__ý  s,   € ÞØˆKÜ�z‰zœ$Ÿ,š, t§z¡zÓ2°D·J±JÓ?Ð?re   rÀ   c                ó.  • [        U[        5      (       al  [        R                  (       aW  UR	                  U R
                  5      u  p#[        R                  [        R                  " U R                  X#[        5      U5      $ [        R                  X5      $ r:   )rL   r    r4   r  rã   rE   rQ   rÝ   rç   Úmpf_addrw   ri   r  ©rº   rÀ   Úrhsrk   s       r?   r  ÚFloat.__add__  ó_   € ä�eœV×$Ñ$Ô):×)C×)CØ×(Ñ(¨¯©Ó4‰IˆCÜ—:‘:œdŸlšl¨4¯:©:°sÄ#ÓFÈÓMÐMÜ�~‰~˜dÓ*Ð*re   c                ó.  • [        U[        5      (       al  [        R                  (       aW  UR	                  U R
                  5      u  p#[        R                  [        R                  " U R                  X#[        5      U5      $ [        R                  X5      $ r:   )rL   r    r4   r  rã   rE   rQ   rÝ   rç   Úmpf_subrw   ri   r  rê  s       r?   r  ÚFloat.__sub__	  rí  re   c                ó.  • [        U[        5      (       al  [        R                  (       aW  UR	                  U R
                  5      u  p#[        R                  [        R                  " U R                  X#[        5      U5      $ [        R                  X5      $ r:   )rL   r    r4   r  rã   rE   rQ   rÝ   rç   Úmpf_mulrw   ri   r$  rê  s       r?   r$  ÚFloat.__mul__  rí  re   c                ó:  • [        U[        5      (       ar  US:w  al  [        R                  (       aW  UR	                  U R
                  5      u  p#[        R                  [        R                  " U R                  X#[        5      U5      $ [        R                  X5      $ ©Nr   )rL   r    r4   r  rã   rE   rQ   rÝ   rç   Úmpf_divrw   ri   r(  rê  s       r?   r(  ÚFloat.__truediv__  sg   € ä�eœV×$Ñ$¨°!«Ô8I×8R×8RØ×(Ñ(¨¯©Ó4‰IˆCÜ—:‘:œdŸlšl¨4¯:©:°sÄ#ÓFÈÓMÐMÜ×!Ñ! $Ó.Ð.re   c                óÐ  • [        U[        5      (       aV  UR                  S:w  aF  [        R                  (       a1  [        [        R                  [        U 5      U5      U R                  S9$ [        U[
        5      (       aQ  [        R                  (       a<  X-  n[        U5      (       a(  [        S[        U R                  UR                  5      S9$ [        U[        5      (       al  [        R                  (       aW  UR                  U R                  5      u  p4[
        R                  [        R                  " U R                  X4[         5      U5      $ [        R                  X5      $ )Nr   ©rœ  r   )rL   r‹   r|   r4   r  rQ   Ú__mod__rE   rÊ  râ   r    rã   rÝ   rç   Úmpf_modrw   ri   )rº   rÀ   rÍ   rë  rk   s        r?   rú  ÚFloat.__mod__  sè   € ä�eœX×&Ñ&¨5¯7©7°a«<Ô<M×<V×<Väœ×)Ñ)¬(°4«.¸%Ó@Ø#'§:¡:ñ/ð /ä�eœU×#Ñ#Ô(9×(B×(BØ‘
ˆAÜ˜!�}‰}Ü˜Q¬#¨d¯j©j¸%¿+¹+Ó*FÑGÐGÜ�eœV×$Ñ$Ô):×)C×)CØ×(Ñ(¨¯©Ó4‰IˆCÜ—:‘:œdŸlšl¨4¯:©:°sÄ#ÓFÈÓMÐMÜ�~‰~˜dÓ*Ð*re   c                ó¤  • [        U[        5      (       a&  [        R                  (       a  UR	                  U 5      $ [        U[
        5      (       al  [        R                  (       aW  UR                  U R                  5      u  p#[        R                  [        R                  " X R                  U[        5      U5      $ [
        R                  X5      $ r:   )rL   rQ   r4   r  rú  r    rã   rE   rÝ   rç   rû  rw   ri   Ú__rmod__rê  s       r?   rþ  ÚFloat.__rmod__-  s„   € ä�eœU×#Ñ#Ô(9×(B×(BØ—=‘= Ó&Ð&Ü�eœV×$Ñ$Ô):×)C×)CØ×(Ñ(¨¯©Ó4‰IˆCÜ—:‘:œdŸlšl¨3·
±
¸DÄ#ÓFÈÓMÐMÜ�‰˜tÓ+Ð+re   c                ó  • [        U S5      (       a4  UR                  (       a  U $ UR                  (       a  [        R                  $ [        U[        5      (       Ga,  [        U[        5      (       aQ  U R                  n[        R                  [        R                  " U R                  UR                  U[        5      U5      $ [        U[         5      (       aa  UR                  S:X  aQ  UR"                  S-  (       a=  U R$                  (       a,  ['        [        R(                  USS9U * R+                  U5      -  $ UR-                  U R                  5      u  pU R                  n [/        X1U[        5      n[        R                  XB5      $ g! [        R0                   aj    [        R2                  " U[4        4U[4        4U[        5      u  pV[        R                  XR5      [        R                  Xb5      [        R6                  -  -   s $ f = f)z“
expt is symbolic object but not equal to 0, 1

(-p)**r -> exp(r*log(-p)) -> exp(r*(log(p) + I*Pi)) ->
          -> p**r*(sin(Pi*r) + cos(Pi*r)*I)
r   r   r5   F©r  N)Úequal_valuedÚis_extended_positiver¸   r   ÚComplexInfinityrL   r    r‡   rE   rQ   rÝ   rç   Úmpf_pow_intrw   rz   ri   r‹   r|   rS  ÚPowrT  Ú_eval_powerrã   r&   ÚComplexResultÚmpc_powr.   ÚImaginaryUnit)rº   rn   rk   ÚmpfselfÚyÚreÚims          r?   r  ÚFloat._eval_power6  sƒ  € ô ˜˜a× Ñ Ø×(×(Ø�Ø×(×(Ü×(Ñ(Ð(Ü�dœF×#Ò#Ü˜$¤×(Ñ(Ø—z‘z�Ü—z‘zÜ×$Ò$ T§Z¡Z°·±¸¼sÓCÀTóKð Kä˜D¤(×+Ñ+Ø—F‘F˜a“K D§F¡F¨Q§J°4×3C×3CÜœ1Ÿ=™=¨$¸Ñ?Ø�EŸ;™; tÓ,ñ-ð -àŸ™¨¯©Ó4‰JˆDØ—j‘jˆGð9Ü˜G¨4´Ó5�Ü—z‘z !Ó*Ð*ð $øô ×%Ñ%ó 9ÜŸšØœeÐ$ t¬U m°T¼3ó@‘�ä—z‘z "Ó+Ü—J‘J˜rÓ(¬¯©Ñ8ñ9ò 9ð9ús   Å"%F	 Æ	A;HÈHc                ó~   • [         R                  [        R                  " U R                  5      U R
                  5      $ r:   )rQ   rÝ   rç   Úmpf_absrw   rE   r¹   s    r?   Ú__abs__ÚFloat.__abs__V  s$   € Ü�z‰zœ$Ÿ,š, t§z¡zÓ2°D·J±JÓ?Ð?re   c                ó~   • U R                   [        :X  a  g[        [        R                  " U R                   5      5      $ rõ  )rw   r.   rW   rç   r°  r¹   s    r?   Ú__int__ÚFloat.__int__Y  s)   € Ø�:‰:œÓØÜ”4—;’;˜tŸz™zÓ*Ó+Ð+re   c                ón   • [        U[        5      (       a  [        U5      n[        R                  " X5      $ r:   )rL   r¦   rQ   r   r+  rÑ   s     r?   r+  ÚFloat.__eq__^  s'   € Ü�eœU×#Ñ#Ü˜%“LˆEÜ�|Š|˜DÓ(Ð(re   c                óH   • U R                  U5      nU[        L a  U$ U(       + $ r:   )r+  rÇ   )rº   rÀ   Úeqs      r?   r/  ÚFloat.__ne__c  s$   € Ø�[‰[˜ÓˆØ”ÒØˆIà”6ˆMre   c                ó�   • [        U 5      n[        R                  " U5      (       d  [        U5      $ [        R
                  " U 5      $ r:   )r¦   r�  ÚisinfÚhashr   rD  )rº   Ú	float_vals     r?   rD  ÚFloat.__hash__j  s3   € Ü˜$“Kˆ	Ü�zŠz˜)×$Ñ$Ü˜	“?Ð"Ü�~Š~˜dÓ#Ð#re   c           
     óT  •  [        U5      nUR                  (       az   [        R
                  " U R                  [        R                  " UR                  5      5      n[        R                  " UR                  5      n[        [        U" X45      5      5      $ UR                  (       a/  [        [        U" U R                  UR                  5      5      5      $ UR                  (       aª  U[        R                  [        R                  4;  a…  UR!                  [#        U R$                  5      5      nUR$                  S:”  aP  UR&                  (       a>  [        [        U" U R                  UR)                  U R$                  5      5      5      5      $ g g g g ! [         a	    [        s $ f = f©Nr   )r   r   rÇ   rR  rç   rò  rw   Úfrom_intr|   rz   r·   Úis_FloatÚis_comparabler   r«   r¬   Úevalfr0   rE   rx  rÙ   )rº   rÀ   ÚopÚsmpfÚompfs        r?   Ú_FrelÚFloat._Frelp  s@  € ð	"Ü˜U“OˆEð ××ðô —<’< §
¡
¬D¯MªM¸%¿'¹'Ó,BÓCˆDÜ—=’= §¡Ó)ˆDÜœD¡ D£Ó0Ó1Ð1Ø�^�^ÜœDÙ˜4Ÿ:™: u§{¡{Ó3ó5ó 6ð 6à× ×  UÜ—
‘
œA×.Ñ.ð30ó &0à—K‘K¤¨D¯J©JÓ 7Ó8ˆEØ�{‰{˜Q‹Ø—?—?Ü#¤DÙ˜4Ÿ:™: u×'8Ñ'8¸¿¹Ó'DÓEó%Gó Hð Hð #ð ð&0Ð øô% ó 	"Ü!Ò!ð	"ús   ‚F ÆF'Æ&F'c                óÄ   • [        U[        5      (       a  UR                  U 5      $ U R                  U[        R
                  5      nUc  [        R                  " X5      $ U$ r:   )rL   r™  r4  r*  rç   Úmpf_gtr   r;  ©rº   rÀ   rp   s      r?   r;  ÚFloat.__gt__�  óK   € Ü�eœ\×*Ñ*Ø—<‘< Ó%Ð%Ø�Z‰Z˜œtŸ{™{Ó+ˆØ‰:Ü—;’;˜tÓ+Ð+Øˆ	re   c                óÄ   • [        U[        5      (       a  UR                  U 5      $ U R                  U[        R
                  5      nUc  [        R                  " X5      $ U$ r:   )rL   r™  r8  r*  rç   Úmpf_ger   r?  r.  s      r?   r?  ÚFloat.__ge__•  r0  re   c                óÄ   • [        U[        5      (       a  UR                  U 5      $ U R                  U[        R
                  5      nUc  [        R                  " X5      $ U$ r:   )rL   r™  r;  r*  rç   Úmpf_ltr   r4  r.  s      r?   r4  ÚFloat.__lt__�  r0  re   c                óÄ   • [        U[        5      (       a  UR                  U 5      $ U R                  U[        R
                  5      nUc  [        R                  " X5      $ U$ r:   )rL   r™  r?  r*  rç   Úmpf_ler   r8  r.  s      r?   r8  ÚFloat.__le__¥  r0  re   c                ó4   • [        X-
  5      [        U5      :  $ r:   )rX   rQ   )rº   rÀ   Úepsilons      r?   Ú
epsilon_eqÚFloat.epsilon_eq­  s   € Ü�4‘<Ó ¤5¨£>Ñ1Ð1re   c                óT   • [        [        R                  " [        U 5      5      U5      $ r:   )Úformatr§   r¨   rM   )rº   Úformat_specs     r?   Ú
__format__ÚFloat.__format__°  s   € Ü”g—o’o¤c¨$£iÓ0°+Ó>Ð>re   r€   ©NN©T)z1e-15)?r®   rs  rt  ru  rv  ry  Ú__annotations__Úis_rationalÚis_irrationalr;   Úis_realÚis_extended_realr$  rM   Ú	maketransÚdictÚfromkeysÚ_remove_non_digitsr´   r{  rÝ   rª  r­  rì   rï   ró   rø   Úpropertyrš  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/  rD  r*  r;  r?  r4  r8  r<  rA  r|  r€   re   r?   rQ   rQ   R  s¿  ‡ ñdðJ #€Ià$Ó$ð €KØ€MØ€Ià€GØÐà€HàŸ™ t§}¡}°VÓ'<Ó=ÐôL6ð\ óó ðò  ò(ò6ò5òòð ñ&ó ð&òò1òò
ò
òò
ò
òò#ò#ò@ñ
 �˜Ó(ñ+ó )ð+ñ �˜Ó(ñ+ó )ð+ñ �˜Ó(ñ+ó )ð+ñ �˜Ó(ñ/ó )ð/ñ �˜Ó(ñ+ó )ð+ñ �˜Ó(ñ,ó )ð,ò9ò@@ò,ò
)ò
ò$òHò:òòòô2õ?re   rQ   c                  ó¤  ^ • \ rS rSr% SrSrSrSrSrSr	S\
S'   S\
S'   Sr\S6S	 j5       r\S7S
 j5       r\S8S j5       rS9S jrS rS rS rS rS r\" S\5      S 5       r\r\" S\5      S 5       r\" S\5      S 5       r\" S\5      S 5       r\r\" S\5      S 5       r\" S\5      S 5       r \" S\5      S 5       r!\" S\5      S 5       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* r2U 4S+ jr3  S:S, jr4\5S- 5       r6\5S. 5       r7\" S\5      S/ 5       r8\" S\5      S0 5       r9S1 r:S;S2 jr;S<S3 jr<S<S4 jr=S5r>U =r?$ )=r‹   i»  a}  Represents rational numbers (p/q) of any size.

Examples
========

>>> from sympy import Rational, nsimplify, S, pi
>>> Rational(1, 2)
1/2

Rational is unprejudiced in accepting input. If a float is passed, the
underlying value of the binary representation will be returned:

>>> Rational(.5)
1/2
>>> Rational(.2)
3602879701896397/18014398509481984

If the simpler representation of the float is desired then consider
limiting the denominator to the desired value or convert the float to
a string (which is roughly equivalent to limiting the denominator to
10**12):

>>> Rational(str(.2))
1/5
>>> Rational(.2).limit_denominator(10**12)
1/5

An arbitrarily precise Rational is obtained when a string literal is
passed:

>>> Rational("1.23")
123/100
>>> Rational('1e-2')
1/100
>>> Rational(".1")
1/10
>>> Rational('1e-2/3.2')
1/320

The conversion of other types of strings can be handled by
the sympify() function, and conversion of floats to expressions
or simple fractions can be handled with nsimplify:

>>> S('.[3]')  # repeating digits in brackets
1/3
>>> S('3**2/10')  # general expressions
9/10
>>> nsimplify(.3)  # numbers that have a simple form
3/10

But if the input does not reduce to a literal Rational, an error will
be raised:

>>> Rational(pi)
Traceback (most recent call last):
...
TypeError: invalid input: pi


Low-level
---------

Access numerator and denominator as .p and .q:

>>> r = Rational(3, 4)
>>> r
3/4
>>> r.p
3
>>> r.q
4

Note that p and q return integers (not SymPy Integers) so some care
is needed when using them in expressions:

>>> r.p/r.q
0.75

See Also
========
sympy.core.sympify.sympify, sympy.simplify.simplify.nsimplify
TF©rz   r|   rW   rz   r|   c                ó¸  • UGci  [        U[        5      (       a  U$ [        U[        5      (       a  GO9[        U[        [        45      (       a  [        [        U5      6 $ [        U[        5      (       d   [        U5      nOÈUR                  S5      S:”  a  [        SU-  5      eUR                  SS5      nUR                  SS5      n[        U5      S:X  a4  Uu  p[        R                   " U5      n[        R                   " U5      nXV-  n [        R                   " U5      nU R#                  UR$                  UR&                  S5      $ [        U[        5      (       d  [        SU-  5      eSnSn[        U[        5      (       d&  [        U5      nXqR*                  -  nUR,                  nO[/        U5      n[        U[        5      (       d(  [        U5      nXR*                  -  nXrR,                  -  nOU[/        U5      -  nUnUb  [1        SSS	S
S9  U R#                  XU5      $ U R#                  X5      $ ! [        [        4 a     Nþf = f! [(         a     GNf = f)NÚ/r   zinvalid input: %sr‚  r8   r5   z4gcd is deprecated in Rational, use nsimplify insteadz1.11zdeprecated-rational-gcdr†  )Údeprecated_since_versionÚactive_deprecations_targetÚ
stacklevel)rL   r‹   r   r¦   rQ   r}   rM   r	   r   ÚSyntaxErrorÚcountr„   rŽ  Úrsplitr†   Ú	fractionsÚFractionrÝ   Ú	numeratorÚdenominatorrN   r|   rz   rW   r3   )r¯   rz   r|   rh  ÚpqÚfpÚfqÚQs           r?   r´   ÚRational.__new__  s  € àŠ9Ü˜!œX×&Ñ&Ø�ä˜!œZ×(Ñ(Ùä˜a¤%¬ ×0Ñ0Ü#Ô%6°qÓ%9Ð:Ð:ä! !¤S×)Ñ)ðÜ# A›J™ð —w‘w˜s“| aÓ'Ü'Ð(;¸aÑ(?Ó@Ð@ØŸ	™	 # rÓ*�AØŸ™ # qÓ)�BÜ˜2“w !“|Ø!™˜Ü&×/Ò/°Ó2˜Ü&×/Ò/°Ó2˜Ø™E˜ðGÜ%×.Ò.¨qÓ1˜ð  #Ÿx™x¨¯©°Q·]±]ÀAÓFÐFä! !¤X×.Ñ.Ü#Ð$7¸!Ñ$;Ó<Ð<àˆAàˆä˜!œZ×(Ñ(Ü˜“ˆAØ—‘‰HˆAØ—‘‰Aä�A“ˆAä˜!œZ×(Ñ(Ü˜“ˆAØ—‘‰HˆAØ—‘‰H‰Aà”�Q“‰KˆAØˆà‰?Ü%ØFØ)/Ø+DØò	ð —8‘8˜A #Ó&Ð&ð �x‰x˜‹~Ðøôg )¬+Ð6ó Ùðûô &ó Úðús$   Á5H5 ÄI È5IÉIÉ
IÉIc                ó  • US:X  a?  US:X  a)  [         S   (       a  [        S5      e[        R                  $ [        R                  $ US:  a  U* nU* nUc  [        [        U5      U5      nUS:”  a  X-  nX#-  nU R                  X5      $ )Nr   rr   zIndeterminate 0/0r   )rt   rN   r   rª   r  r   rX   Úfrom_coprime_ints)r¯   rz   r|   rh  s       r?   rÝ   ÚRational._new^  sˆ   € à�‹6Ø�A‹vÜ˜H×%Ü$Ð%8Ó9Ð9äŸ5™5�LÜ×$Ñ$Ð$àˆq‹5Ø�ˆAØ�ˆAà‰;Ü”s˜1“v˜q“/ˆCà�‹7Ø‰IˆAØ‰IˆAà×$Ñ$ QÓ*Ð*re   c                ó¤   • US:X  a  [        U5      $ US:X  a  US:X  a  [        R                  $ [        R                  " U 5      nXl        X#l        U$ )au  Create a Rational from a pair of coprime integers.

Both ``p`` and ``q`` should be strictly of type ``int``.

The caller should ensure that ``gcd(p,q) == 1`` and ``q > 0``.

This may be more efficient than ``Rational(p, q)``. The validity of the
arguments may or may not be checked so it should not be relied upon to
pass unvalidated or invalid arguments to this function.
r   r5   )r‡   r   ÚHalfr   r´   rz   r|   )r¯   rz   r|   r°   s       r?   rc  ÚRational.from_coprime_intsu  sH   € ð �‹6Ü˜1“:ÐØ�‹6�a˜1“fÜ—6‘6ˆMä�lŠl˜3ÓˆØŒØŒØˆ
re   c           	     óÆ   • [         R                  " U R                  U R                  5      n[	        UR                  [         R                  " [        U5      5      5      5      $ )zôClosest Rational to self with denominator at most max_denominator.

Examples
========

>>> from sympy import Rational
>>> Rational('3.141592653589793').limit_denominator(10)
22/7
>>> Rational('3.141592653589793').limit_denominator(100)
311/99

)rY  rZ  rz   r|   r‹   Úlimit_denominatorrW   )rº   Úmax_denominatorrœ   s      r?   ri  ÚRational.limit_denominator‹  sD   € ô ×Ò˜tŸv™v t§v¡vÓ.ˆÜ˜×+Ñ+¬I×,>Ò,>¼sÀ?Ó?SÓ,TÓUÓVÐVre   c                ó2   • U R                   U R                  4$ r:   rP  r¹   s    r?   Ú__getnewargs__ÚRational.__getnewargs__›  ó   € Ø—‘˜Ÿ™ÐÐre   c                ó2   • U R                   U R                  4$ r:   rP  r¹   s    r?   r­  ÚRational._hashable_contentž  ro  re   c                ó    • U R                   S:„  $ rõ  ©rz   r¹   s    r?   rÔ  ÚRational._eval_is_positive¡  s   € Ø�v‰v˜‰zÐre   c                ó    • U R                   S:H  $ rõ  rs  r¹   s    r?   rß  ÚRational._eval_is_zero¤  s   € Ø�v‰v˜‰{Ðre   c                óD   • [        U R                  * U R                  5      $ r:   )r‹   rz   r|   r¹   s    r?   r  ÚRational.__neg__§  s   € Ü˜Ÿ™˜ §¡Ó(Ð(re   rÀ   c                ó8  • [         R                  (       añ  [        U[        5      (       aE  [        R                  U R                  U R                  UR                  -  -   U R                  S5      $ [        U[        5      (       aT  [	        U R                  UR                  -  U R                  UR                  -  -   U R                  UR                  -  5      $ [        U[        5      (       a  X-   $ [        R                  X5      $ [        R                  X5      $ r"  )r4   r  rL   r‡   r‹   rÝ   rz   r|   rQ   r    r  rÑ   s     r?   r  ÚRational.__add__ª  sº   € ä×%×%Ü˜%¤×)Ñ)Ü—}‘} T§V¡V¨d¯f©f°U·W±W©nÑ%<¸d¿f¹fÀaÓHÐHÜ˜E¤8×,Ñ,ä §¡ u§w¡w¡°·±¸¿¹±Ñ ?ÀÇÁÈÏÉÁÓPÐPÜ˜E¤5×)Ñ)Ø‘|Ð#ä—~‘~ dÓ2Ð2Ü�~‰~˜dÓ*Ð*re   c                ó<  • [         R                  (       aó  [        U[        5      (       aE  [        R                  U R                  U R                  UR                  -  -
  U R                  S5      $ [        U[        5      (       aT  [	        U R                  UR                  -  U R                  UR                  -  -
  U R                  UR                  -  5      $ [        U[        5      (       a  U* U -   $ [        R                  X5      $ [        R                  X5      $ r"  )r4   r  rL   r‡   r‹   rÝ   rz   r|   rQ   r    r  rÑ   s     r?   r  ÚRational.__sub__¹  s¾   € ä×%×%Ü˜%¤×)Ñ)Ü—}‘} T§V¡V¨d¯f©f°U·W±W©nÑ%<¸d¿f¹fÀaÓHÐHÜ˜E¤8×,Ñ,Ü §¡ u§w¡w¡°·±¸¿¹±Ñ ?ÀÇÁÈÏÉÁÓPÐPÜ˜E¤5×)Ñ)Ø�v ‘}Ð$ä—~‘~ dÓ2Ð2Ü�~‰~˜dÓ*Ð*re   c                ó<  • [         R                  (       aó  [        U[        5      (       aE  [        R                  U R                  UR                  -  U R                  -
  U R                  S5      $ [        U[        5      (       aT  [	        U R                  UR                  -  U R                  UR                  -  -
  U R                  UR                  -  5      $ [        U[        5      (       a  U * U-   $ [        R                  X5      $ [        R                  X5      $ r"  )r4   r  rL   r‡   r‹   rÝ   r|   rz   rQ   r    Ú__rsub__rÑ   s     r?   r~  ÚRational.__rsub__Å  s¾   € ä×%×%Ü˜%¤×)Ñ)Ü—}‘} T§V¡V¨E¯G©G¡^°d·f±fÑ%<¸d¿f¹fÀaÓHÐHÜ˜E¤8×,Ñ,Ü §¡ u§w¡w¡°·±¸¿¹±Ñ ?ÀÇÁÈÏÉÁÓPÐPÜ˜E¤5×)Ñ)Ø�u˜u‘}Ð$ä—‘ tÓ3Ð3Ü�‰˜tÓ+Ð+re   c           	     ó¼  • [         R                  (       Ga2  [        U[        5      (       aV  [        R                  U R                  UR                  -  U R                  [        UR                  U R                  5      5      $ [        U[        5      (       a„  [        R                  U R                  UR                  -  U R                  UR                  -  [        U R                  UR                  5      [        U R                  UR                  5      -  5      $ [        U[        5      (       a  X-  $ [        R                  X5      $ [        R                  X5      $ r:   )r4   r  rL   r‡   r‹   rÝ   rz   r|   r   rQ   r    r$  rÑ   s     r?   r$  ÚRational.__mul__Ñ  så   € ä×%×%Ð%Ü˜%¤×)Ñ)Ü—}‘} T§V¡V¨E¯G©G¡^°T·V±V¼TÀ%Ç'Á'È4Ï6É6Ó=RÓSÐSÜ˜E¤8×,Ñ,Ü—}‘} T§V¡V¨E¯G©G¡^°T·V±V¸E¿G¹G±^ÄTÈ$Ï&É&ÐRW×RYÑRYÓEZÔ[_Ð`d×`fÑ`fÐhm×hoÑhoÓ[pÑEpÓqÐqÜ˜E¤5×)Ñ)Ø‘zÐ!ä—~‘~ dÓ2Ð2Ü�~‰~˜dÓ*Ð*re   c           	     óB  • [         R                  (       Gau  [        U[        5      (       a•  U R                  (       a.  UR                  [
        R                  :X  a  [
        R                  $ [        R                  U R                  U R                  UR                  -  [        U R                  UR                  5      5      $ [        U[        5      (       a„  [        R                  U R                  UR                  -  U R                  UR                  -  [        U R                  UR                  5      [        U R                  UR                  5      -  5      $ [        U[        5      (       a  U SU-  -  $ [        R                  X5      $ [        R                  X5      $ r"  )r4   r  rL   r‡   rz   r   r'  r  r‹   rÝ   r|   r   rQ   r    r(  rÑ   s     r?   r(  ÚRational.__truediv__ß  s  € ä×%×%Ð%Ü˜%¤×)Ñ)Ø—6—6˜eŸg™g¬¯©Ó/Ü×,Ñ,Ð,ä#Ÿ=™=¨¯©°·±¸¿¹±ÄÀdÇfÁfÈeÏgÉgÓAVÓWÐWÜ˜E¤8×,Ñ,Ü—}‘} T§V¡V¨E¯G©G¡^°T·V±V¸E¿G¹G±^ÄTÈ$Ï&É&ÐRW×RYÑRYÓEZÔ[_Ð`d×`fÑ`fÐhm×hoÑhoÓ[pÑEpÓqÐqÜ˜E¤5×)Ñ)Ø˜Q˜u™W‘~Ð%ä×)Ñ)¨$Ó6Ð6Ü×!Ñ! $Ó.Ð.re   c           	     óÄ  • [         R                  (       Ga6  [        U[        5      (       aV  [        R                  UR                  U R                  -  U R                  [        U R                  UR                  5      5      $ [        U[        5      (       a„  [        R                  UR                  U R                  -  UR                  U R                  -  [        U R                  UR                  5      [        U R                  UR                  5      -  5      $ [        U[        5      (       a  USU -  -  $ [        R                  X5      $ [        R                  X5      $ r"  )r4   r  rL   r‡   r‹   rÝ   rz   r|   r   rQ   r    Ú__rtruediv__rÑ   s     r?   r…  ÚRational.__rtruediv__î  sï   € ä×%×%Ð%Ü˜%¤×)Ñ)Ü—}‘} U§W¡W¨T¯V©V¡^°T·V±V¼TÀ$Ç&Á&È%Ï'É'Ó=RÓSÐSÜ˜E¤8×,Ñ,Ü—}‘} U§W¡W¨T¯V©V¡^°U·W±W¸T¿V¹V±^ÄTÈ$Ï&É&ÐRW×RYÑRYÓEZÔ[_Ð`d×`fÑ`fÐhm×hoÑhoÓ[pÑEpÓqÐqÜ˜E¤5×)Ñ)Ø˜a ™f‘~Ð%ä×*Ñ*¨4Ó7Ð7Ü×"Ñ" 4Ó/Ð/re   c                ó>  • [         R                  (       aô  [        U[        5      (       a‰  U R                  UR
                  -  UR                  U R
                  -  -  n[        U R                  UR
                  -  X!R                  -  U R
                  -  -
  U R
                  UR
                  -  5      $ [        U[        5      (       a,  [        U R                  [        U5      5      UR                  S9$ [        R                  X5      $ [        R                  X5      $ )Nrù  )
r4   r  rL   r‹   rz   r|   rQ   rú  rE   r    )rº   rÀ   rS   s      r?   rú  ÚRational.__mod__û  sÁ   € ä×%×%Ü˜%¤×*Ñ*Ø—V‘V˜EŸG™G‘^¨¯©°·±©Ñ8�Ü §¡ u§w¡w¡°·7±7±¸4¿6¹6Ñ1AÑ AÀ4Ç6Á6È%Ï'É'Á>ÓRÐRÜ˜%¤×'Ñ'ä˜TŸ\™\¬(°5«/Ó:Ø',§{¡{ñ4ð 4ä—>‘> $Ó.Ð.Ü�~‰~˜dÓ*Ð*re   c                ó€   • [        U[        5      (       a  [        R                  X5      $ [        R	                  X5      $ r:   )rL   r‹   rú  r    rþ  rÑ   s     r?   rþ  ÚRational.__rmod__  s/   € ä�eœX×&Ñ&Ü×#Ñ# EÓ0Ð0Ü�‰˜tÓ+Ð+re   c                óæ  • [        U[        5      (       Ga³  [        U[        5      (       a  U R                  UR                  5      U-  $ UR
                  (       a¢  U* nU[        R                  L a   [        U R                  U R                  5      $ U R                  (       a8  [        R                  U-  [        U R                  U R                  * 5      U-  -  $ [        U R                  U R                  5      U-  $ U[        R                  L a‡  U R                  U R                  :”  a  [        R                  $ U R                  U R                  * :  a2  [        R                  [        R                  [        R                  -  -   $ [        R                  $ [        U[         5      (       aE  [        R#                  U R                  UR                  -  U R                  UR                  -  S5      $ [        U[        5      (       GaÃ  UR                  UR                  -  nU(       aØ  US-  nX1R                  -  UR                  -
  n[        XAR                  5      nU R                  S:w  aV  [!        U R                  5      U-  [!        U R                  5      U-  -  [        R#                  SU R                  U-  S5      -  $ [!        U R                  5      U-  [        R#                  SU R                  U-  S5      -  $ UR                  UR                  -
  n[        XAR                  5      nU R                  S:w  aS  [!        U R                  5      U-  [!        U R                  5      U-  -  [        R#                  SU R                  S5      -  $ [!        U R                  5      U-  [        R#                  SU R                  S5      -  $ U R
                  (       a  UR$                  (       a  U * U-  $ g r"  )rL   r    rQ   rÞ   rE   r¸   r   r  r‹   r|   rz   rS  rT  r«   r
  r'  r‡   rÝ   Úis_even)rº   rn   ÚneÚintpartÚremfracpartÚratfracparts         r?   r  ÚRational._eval_power  sÌ  € Ü�dœF×#Ò#Ü˜$¤×&Ñ&Ø×'Ñ'¨¯
©
Ó3°TÑ9Ð9Ø×(×(à�U�Øœ!Ÿ%™%’KÜ# D§F¡F¨D¯F©FÓ3Ð3Ø×#×#ÜŸ=™=¨$Ñ.¬x¸¿¹ÀÇÁÀÓ/HÈ"Ñ/LÑLÐLä# D§F¡F¨D¯F©FÓ3°RÑ7Ð7Ø”q—z‘zÒ!Ø—6‘6˜DŸF™F“?äŸ:™:Ð%Ø—6‘6˜TŸV™V˜GÓ#äŸ:™:¬¯
©
´1·?±?Ñ(BÑBÐBÜ—v‘v�Ü˜$¤×(Ñ(ä—}‘} T§V¡V¨T¯V©V¡^°T·V±V¸T¿V¹V±^ÀQÓGÐGÜ˜$¤×)Ò)ØŸ&™& D§F¡FÑ*�ÞØ˜q‘L�GØ")¯&©&¡.°4·6±6Ñ"9�KÜ"*¨;¿¹Ó"?�KØ—v‘v “{Ü& t§v¡v›°Ñ4´W¸T¿V¹V³_ÀkÑ5QÑQÔRZ×R_ÑR_Ð`aÐcg×ciÑciÐkrÑcrÐtuÓRvÑvÐvÜ" 4§6¡6›?¨KÑ7¼¿¹ÀaÈÏÉÐQXÉÐZ[Ó8\Ñ\Ð\à"&§&¡&¨4¯6©6¡/�KÜ"*¨;¿¹Ó"?�KØ—v‘v “{Ü& t§v¡v›°Ñ4´W¸T¿V¹V³_ÀkÑ5QÑQÔRZ×R_ÑR_Ð`aÐcg×ciÑciÐklÓRmÑmÐmÜ" 4§6¡6›?¨KÑ7¼¿¹ÀaÈÏÉÐQRÓ8SÑSÐSà×$×$¨¯¯Ø�E˜D‘=Ð àre   c                ód   • [         R                  " U R                  U R                  U[        5      $ r:   )rç   Úfrom_rationalrz   r|   ri   rØ   s     r?   rÙ   ÚRational._as_mpf_val;  s!   € Ü×!Ò! $§&¡&¨$¯&©&°$¼Ó<Ð<re   c                ó‚   • [         R                  " [        R                  " U R                  U R
                  X5      5      $ r:   )ry   Úmake_mpfrç   r“  rz   r|   ©rº   rk   ri   s      r?   Ú_mpmath_ÚRational._mpmath_>  s(   € Ü�Šœt×1Ò1°$·&±&¸$¿&¹&À$ÓLÓMÐMre   c                óT   • [        [        U R                  5      U R                  5      $ r:   )r‹   rX   rz   r|   r¹   s    r?   r  ÚRational.__abs__A  s   € Üœ˜DŸF™F› T§V¡VÓ,Ð,re   c                óv   • U R                   U R                  p!US:  a  [        U* U-  5      * $ [        X-  5      $ rõ  )rz   r|   rW   )rº   rz   r|   s      r?   r  ÚRational.__int__D  s6   € Ø�v‰v�t—v‘vˆ1Øˆq‹5Ü˜˜˜A™“J�;ÐÜ�1‘4‹yÐre   c                óF   • [        U R                  U R                  -  5      $ r:   ©r‡   rz   r|   r¹   s    r?   rì   ÚRational.floorJ  s   € Ü�t—v‘v §¡Ñ'Ó(Ð(re   c                óJ   • [        U R                  * U R                  -  5      * $ r:   rŸ  r¹   s    r?   rï   ÚRational.ceilingM  s   € Ü˜Ÿ™˜ 4§6¡6Ñ)Ó*Ð*Ð*re   c                ó"   • U R                  5       $ r:   rò   r¹   s    r?   ró   ÚRational.__floor__P  rõ   re   c                ó"   • U R                  5       $ r:   r÷   r¹   s    r?   rø   ÚRational.__ceil__S  rú   re   c                óp  •  [        U5      n[        U[        5      (       d  gUR
                  (       a#  UR                  (       a  gUR                  U 5      $ UR                  (       a9  U R                  UR                  :H  =(       a    U R                  UR                  :H  $ g! [         a	    [        s $ f = f©NF)r   r   rÇ   rL   r    Úis_NumberSymbolrG  r+  rR  rz   r|   rÑ   s     r?   r+  ÚRational.__eq__V  s’   € ð	"Ü˜U“OˆEô ˜%¤×(Ñ(ð Ø× × Ø×"×"ØØ—<‘< Ó%Ð%Ø××ð —6‘6˜UŸW™WÑ$×:¨¯©°5·7±7Ñ):Ð:Øøô ó 	"Ü!Ò!ð	"ús   ‚B" Â"B5Â4B5c                ó   • X:X  + $ r:   r€   rÑ   s     r?   r/  ÚRational.__ne__i  ó   € ØÒ Ð re   c                óR  •  [        U5      nUR                  (       aô  S nXpTUR                  (       a  [        XR5      nO|UR                  (       a  [        XR5      nO_UR                  (       aN  [        UR                  UR                  -  5      [        UR                  UR                  -  5      pT[        XR5      nU(       a  U" U5      $ UR                  (       a6  UR                  (       a$  [        UR                  5      UR                  U-  4$ g g g ! [         a	    [        s $ f = fr:   )r   r   rÇ   rx  r©  rV   r$  rR  r‡   rz   r|   r;   rI  )rº   rÀ   Úattrr'  r�   Úos         r?   Ú_RrelÚRational._Rrell  sÜ   € ð	"Ü˜U“OˆEð �?�?ØˆBØˆqØ×$×$Ü˜QÓ%‘Ø——Ü˜QÓ%‘Ø×"×"Ü˜qŸs™s 1§3¡3™wÓ'¬°·±°Q·S±S±Ó)9�1Ü˜QÓ%�ÞÙ˜!“u�Ø�{�{˜q×1×1Ü˜qŸs™s“| Q§S¡S¨¡UÐ*Ð*ð  2ˆ{ð øô ó 	"Ü!Ò!ð	"ús   ‚D ÄD&Ä%D&c                óˆ   • U R                  US5      nUc  X4nO[        U[        5      (       d  U$ [        R                  " U6 $ )Nr4  )r±  rL   r—   r   r;  r.  s      r?   r;  ÚRational.__gt__�  ó?   € Ø�Z‰Z˜˜xÓ(ˆØ‰:Ø�‰BÜ˜B¤×&Ñ&ØˆIÜ�{Š{˜BÐÐre   c                óˆ   • U R                  US5      nUc  X4nO[        U[        5      (       d  U$ [        R                  " U6 $ )Nr8  )r±  rL   r—   r   r?  r.  s      r?   r?  ÚRational.__ge__‰  rµ  re   c                óˆ   • U R                  US5      nUc  X4nO[        U[        5      (       d  U$ [        R                  " U6 $ )Nr;  )r±  rL   r—   r   r4  r.  s      r?   r4  ÚRational.__lt__‘  rµ  re   c                óˆ   • U R                  US5      nUc  X4nO[        U[        5      (       d  U$ [        R                  " U6 $ )Nr?  )r±  rL   r—   r   r8  r.  s      r?   r8  ÚRational.__le__™  rµ  re   c                ó    >• [         TU ]  5       $ r:   rB  rE  s    €r?   rD  ÚRational.__hash__¡  rG  re   c           	     ó<   • SSK Jn  U" XUX4US9R                  5       $ )zÁA wrapper to factorint which return factors of self that are
smaller than limit (or cheap to compute). Special methods of
factoring are disabled by default so that only trial division is used.
r   )Ú	factorrat)ÚlimitÚ	use_trialÚuse_rhoÚuse_pm1Úverbose)Úsympy.ntheory.factor_r¿  Úcopy)rº   rÀ  rÁ  rÂ  rÃ  rÄ  Úvisualr¿  s           r?   ÚfactorsÚRational.factors¤  s%   € õ 	4á˜°iØ%Ø%ñ'ç'+¡t£vð	.re   c                ó   • U R                   $ r:   rs  r¹   s    r?   r[  ÚRational.numerator°  ó   € à�v‰vˆre   c                ó   • U R                   $ r:   )r|   r¹   s    r?   r\  ÚRational.denominator´  rÌ  re   c                ó  • [        U[        5      (       a^  U[        R                  :X  a  U$ [        [	        U R
                  UR
                  5      [        U R                  UR                  5      5      $ [        R                  X5      $ r:   )
rL   r‹   r   r'  r   rz   r   r|   r    rh  rÑ   s     r?   rh  ÚRational.gcd¸  sa   € ä�eœX×&Ñ&ØœŸ™‹Ø�ÜÜ�T—V‘V˜UŸW™WÓ%Ü�T—V‘V˜UŸW™WÓ%ó'ð 'ô �z‰z˜$Ó&Ð&re   c                ó  • [        U[        5      (       ab  [        U R                  [        U R                  UR                  5      -  UR                  -  [        U R                  UR                  5      5      $ [
        R                  X5      $ r:   )rL   r‹   rz   r   r|   r    rl  rÑ   s     r?   rl  ÚRational.lcmÂ  sc   € ä�eœX×&Ñ&ÜØ—‘œ$˜tŸv™v u§w¡wÓ/Ñ/°%·'±'Ñ9Ü�T—V‘V˜UŸW™WÓ%ó'ð 'ô �z‰z˜$Ó&Ð&re   c                óV   • [        U R                  5      [        U R                  5      4$ r:   rŸ  r¹   s    r?   Úas_numer_denomÚRational.as_numer_denomÊ  s   € Ü�t—v‘v‹¤¨¯©£Ð/Ð/re   c                ó    • U (       a6  U R                   (       a  U [        R                  4$ U * [        R                  4$ [        R                  U 4$ )zíReturn the tuple (R, self/R) where R is the positive Rational
extracted from self.

Examples
========

>>> from sympy import S
>>> (S(-3)/2).as_content_primitive()
(3/2, -1)

See docstring of Expr.as_content_primitive for more examples.
)r#  r   r  rT  )rº   ÚradicalÚclears      r?   Úas_content_primitiveÚRational.as_content_primitiveÍ  s=   € ö Ø××ØœQŸU™U�{Ð"Ø�5œ!Ÿ-™-Ð'Ð'Ü�u‰u�dˆ{Ðre   c                ó&   • U [         R                  4$ r]  r^  r_  s     r?   r`  ÚRational.as_coeff_Mulá  s   € à”Q—U‘Uˆ{Ðre   c                ó&   • U [         R                  4$ rc  rd  r_  s     r?   re  ÚRational.as_coeff_Addå  s   € à”Q—V‘Vˆ|Ðre   r€   rC  r:   )rz   rW   r|   rW   rq  r‹   )i@B ©NTFFFF)FTrr  )@r®   rs  rt  ru  rv  rH  Ú
is_integerrF  r;   ry  rE  rR  r   r´   r{  rÝ   rc  ri  rm  r­  rÔ  rß  r  r   rÇ   r  Ú__radd__r  r~  r$  Ú__rmul__r(  r…  rú  rþ  r  rÙ   r˜  r  r  rì   rï   ró   rø   r+  r/  r±  r;  r?  r4  r8  rD  rÈ  rN  r[  r\  rh  rl  rÔ  rÙ  r`  re  r|  r}  r~  s   @r?   r‹   r‹   »  sN  ø‡ ñQðd €GØ€JØ€KØ€Ià€Ià
ƒFØ
ƒFà€KàóAó ðAðF ó+ó ð+ð, óó ðô*Wò  ò òòò)ñ �˜Ó(ñ+ó )ð+ð €Há�˜Ó(ñ
+ó )ð
+ñ �˜Ó(ñ
,ó )ð
,ñ �˜Ó(ñ
+ó )ð
+ð €Há�˜Ó(ñ/ó )ð/ñ �˜Ó(ñ
0ó )ð
0ñ �˜Ó(ñ
+ó )ð
+ñ �˜Ó(ñ,ó )ð,ò
+òZ=òNò-òò)ò+òòòò&!ò+ò* ò ò ò õ"ð ;@Ø5:ô
.ð ñó ðð ñó ðñ �˜Ó(ñ'ó )ð'ñ �˜Ó(ñ'ó )ð'ò0ôô(÷ò re   r‹   c                  óv  ^ • \ rS rSrSrSrSrSrSrSr	S r
S r\S 5       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(U 4S$ jr)S% r*S& r+S' r,\-" S(\.5      S) 5       r/S* r0S+ r1S, r2S- r3S. r4S/ r5S0 r6S1 r7S2 r8S3 r9S4 r:S5 r;Sr<U =r=$ )6r‡   iê  a"  Represents integer numbers of any size.

Examples
========

>>> from sympy import Integer
>>> Integer(3)
3

If a float or a rational is passed to Integer, the fractional part
will be discarded; the effect is of rounding toward zero.

>>> Integer(3.8)
3
>>> Integer(-3.8)
-3

A string is acceptable input if it can be parsed as an integer:

>>> Integer("9" * 20)
99999999999999999999

It is rarely needed to explicitly instantiate an Integer, because
Python integers are automatically converted to Integer when they
are used in SymPy expressions.
r   Tr€   c                óN   • [         R                  " U R                  U[        5      $ r:   )rç   r#  rz   ri   rØ   s     r?   rÙ   ÚInteger._as_mpf_val  s   € Ü�}Š}˜TŸV™V T¬3Ó/Ð/re   c                óL   • [         R                  " U R                  U5      5      $ r:   )ry   r–  rÙ   r—  s      r?   r˜  ÚInteger._mpmath_  s   € Ü�Š˜t×/Ñ/°Ó5Ó6Ð6re   c                ó`  • [        U[        5      (       a  UR                  SS5      n [        U5      nUS:X  a  [
        R                  $ US:X  a  [
        R                  $ US:X  a  [
        R                  $ [        R                  " U 5      nX#l        U$ ! [         a    [	        SU-  5      ef = f)Nr‚  r8   z6Argument of Integer should be of numeric type, got %s.r   rx   r   )rL   rM   rŽ  rW   r„   r   r  rT  r'  r   r´   rz   )r¯   r>   Úivalr°   s       r?   r´   ÚInteger.__new__  s£   € ä�aœ×ÑØ—	‘	˜#˜rÓ"ˆAð	NÜ�q“6ˆDð �1‹9Ü—5‘5ˆLØ�2‹:Ü—=‘=Ð Ø�1‹9Ü—6‘6ˆMÜ�lŠl˜3ÓˆØŒØˆ
øô ó 	NÜØHÈ1ÑLóNð Nð	Nús   ©B ÂB-c                ó   • U R                   4$ r:   rs  r¹   s    r?   rm  ÚInteger.__getnewargs__.  s   € Ø—‘ˆyÐre   c                ó   • U R                   $ r:   rs  r¹   s    r?   r  ÚInteger.__int__2  ó   € Ø�v‰vˆre   c                ó,   • [        U R                  5      $ r:   ©r‡   rz   r¹   s    r?   rì   ÚInteger.floor5  ó   € Ü�t—v‘v‹Ðre   c                ó,   • [        U R                  5      $ r:   rñ  r¹   s    r?   rï   ÚInteger.ceiling8  ró  re   c                ó"   • U R                  5       $ r:   rò   r¹   s    r?   ró   ÚInteger.__floor__;  rõ   re   c                ó"   • U R                  5       $ r:   r÷   r¹   s    r?   rø   ÚInteger.__ceil__>  rú   re   c                ó.   • [        U R                  * 5      $ r:   rñ  r¹   s    r?   r  ÚInteger.__neg__A  ó   € Ü˜Ÿ™�wÓÐre   c                óR   • U R                   S:¼  a  U $ [        U R                   * 5      $ rõ  )rz   r‡   r¹   s    r?   r  ÚInteger.__abs__D  s#   € Ø�6‰6�Q‹;ØˆKä˜DŸF™F˜7Ó#Ð#re   c                óÌ   • [        U[        5      (       a;  [        R                  (       a&  [	        [        U R                  UR                  5      6 $ [        R                  X5      $ r:   )	rL   r‡   r4   r  r   rÊ   rz   r    rÎ   rÑ   s     r?   rÎ   ÚInteger.__divmod__J  sC   € Ü�eœW×%Ñ%Ô*;×*D×*DÜœ6 $§&¡&¨%¯'©'Ó2Ð4Ð4ä×$Ñ$ TÓ1Ð1re   c                ó`  • [        U[        5      (       a0  [        R                  (       a  [	        [        XR                  5      6 $  [        U5      n[        R                  X5      $ ! [         a<    Sn[        U5      R                  n[        U 5      R                  n[        X#U4-  5      ef = f)Nz7unsupported operand type(s) for divmod(): '%s' and '%s')rL   rW   r4   r  r   rÊ   rz   r    r„   r­   r®   rÎ   )rº   rÀ   r³   ÚonameÚsnames        r?   rÒ   ÚInteger.__rdivmod__P  s“   € Ü�eœS×!Ñ!Ô&7×&@×&@Üœ6 %¯©Ó0Ð2Ð2ð6Ü˜u›�ô ×$Ñ$ UÓ1Ð1øô ó 6ØO�Ü˜U›×,Ñ,�Ü˜T›
×+Ñ+�Ü ¨e nÑ 4Ó5Ð5ð	6ús   ÁA' Á'AB-c                óè  • [         R                  (       aÓ  [        U[        5      (       a  [	        U R
                  U-   5      $ [        U[        5      (       a"  [	        U R
                  UR
                  -   5      $ [        U[        5      (       aE  [        R                  U R
                  UR                  -  UR
                  -   UR                  S5      $ [        R                  X5      $ [        X5      $ r"  )r4   r  rL   rW   r‡   rz   r‹   rÝ   r|   r  ÚAddrÑ   s     r?   r  ÚInteger.__add__^  s¥   € Ü×%×%Ü˜%¤×%Ñ%Ü˜tŸv™v¨™~Ó.Ð.Ü˜E¤7×+Ñ+Ü˜tŸv™v¨¯©Ñ/Ó0Ð0Ü˜E¤8×,Ñ,Ü—}‘} T§V¡V¨E¯G©G¡^°e·g±gÑ%=¸u¿w¹wÈÓJÐJÜ×#Ñ# DÓ0Ð0ä�tÓ#Ð#re   c                óŒ  • [         R                  (       a›  [        U[        5      (       a  [	        XR
                  -   5      $ [        U[        5      (       aE  [        R                  UR
                  U R
                  UR                  -  -   UR                  S5      $ [        R                  X5      $ [        R                  X5      $ r"  )
r4   r  rL   rW   r‡   rz   r‹   rÝ   r|   rá  rÑ   s     r?   rá  ÚInteger.__radd__j  ó„   € Ü×%×%Ü˜%¤×%Ñ%Ü˜u§v¡v™~Ó.Ð.Ü˜E¤8×,Ñ,Ü—}‘} U§W¡W¨t¯v©v°e·g±g©~Ñ%=¸u¿w¹wÈÓJÐJÜ×$Ñ$ TÓ1Ð1Ü× Ñ  Ó-Ð-re   c                óü  • [         R                  (       aÓ  [        U[        5      (       a  [	        U R
                  U-
  5      $ [        U[        5      (       a"  [	        U R
                  UR
                  -
  5      $ [        U[        5      (       aE  [        R                  U R
                  UR                  -  UR
                  -
  UR                  S5      $ [        R                  X5      $ [        R                  X5      $ r"  )
r4   r  rL   rW   r‡   rz   r‹   rÝ   r|   r  rÑ   s     r?   r  ÚInteger.__sub__s  s«   € Ü×%×%Ü˜%¤×%Ñ%Ü˜tŸv™v¨™~Ó.Ð.Ü˜E¤7×+Ñ+Ü˜tŸv™v¨¯©Ñ/Ó0Ð0Ü˜E¤8×,Ñ,Ü—}‘} T§V¡V¨E¯G©G¡^°e·g±gÑ%=¸u¿w¹wÈÓJÐJÜ×#Ñ# DÓ0Ð0Ü×Ñ Ó,Ð,re   c                óŒ  • [         R                  (       a›  [        U[        5      (       a  [	        XR
                  -
  5      $ [        U[        5      (       aE  [        R                  UR
                  U R
                  UR                  -  -
  UR                  S5      $ [        R                  X5      $ [        R                  X5      $ r"  )
r4   r  rL   rW   r‡   rz   r‹   rÝ   r|   r~  rÑ   s     r?   r~  ÚInteger.__rsub__~  r
  re   c                ó  • [         R                  (       aä  [        U[        5      (       a  [	        U R
                  U-  5      $ [        U[        5      (       a"  [	        U R
                  UR
                  -  5      $ [        U[        5      (       aV  [        R                  U R
                  UR
                  -  UR                  [        U R
                  UR                  5      5      $ [        R                  X5      $ [        R                  X5      $ r:   )r4   r  rL   rW   r‡   rz   r‹   rÝ   r|   r   r$  rÑ   s     r?   r$  ÚInteger.__mul__‡  s°   € Ü×%×%Ü˜%¤×%Ñ%Ü˜tŸv™v e™|Ó,Ð,Ü˜E¤7×+Ñ+Ü˜tŸv™v e§g¡g™~Ó.Ð.Ü˜E¤8×,Ñ,Ü—}‘} T§V¡V¨E¯G©G¡^°U·W±W¼dÀ4Ç6Á6È5Ï7É7Ó>SÓTÐTÜ×#Ñ# DÓ0Ð0Ü×Ñ Ó,Ð,re   c                ó®  • [         R                  (       a¬  [        U[        5      (       a  [	        XR
                  -  5      $ [        U[        5      (       aV  [        R                  UR
                  U R
                  -  UR                  [        U R
                  UR                  5      5      $ [        R                  X5      $ [        R                  X5      $ r:   )r4   r  rL   rW   r‡   rz   r‹   rÝ   r|   r   râ  rÑ   s     r?   râ  ÚInteger.__rmul__’  sŠ   € Ü×%×%Ü˜%¤×%Ñ%Ü˜u§V¡V™|Ó,Ð,Ü˜E¤8×,Ñ,Ü—}‘} U§W¡W¨T¯V©V¡^°U·W±W¼dÀ4Ç6Á6È5Ï7É7Ó>SÓTÐTÜ×$Ñ$ TÓ1Ð1Ü× Ñ  Ó-Ð-re   c                óH  • [         R                  (       ay  [        U[        5      (       a  [	        U R
                  U-  5      $ [        U[        5      (       a"  [	        U R
                  UR
                  -  5      $ [        R                  X5      $ [        R                  X5      $ r:   )r4   r  rL   rW   r‡   rz   r‹   rú  rÑ   s     r?   rú  ÚInteger.__mod__›  sr   € Ü×%×%Ü˜%¤×%Ñ%Ü˜tŸv™v¨™~Ó.Ð.Ü˜E¤7×+Ñ+Ü˜tŸv™v¨¯©Ñ/Ó0Ð0Ü×#Ñ# DÓ0Ð0Ü×Ñ Ó,Ð,re   c                óF  • [         R                  (       ax  [        U[        5      (       a  [	        XR
                  -  5      $ [        U[        5      (       a"  [	        UR
                  U R
                  -  5      $ [        R                  X5      $ [        R                  X5      $ r:   )r4   r  rL   rW   r‡   rz   r‹   rþ  rÑ   s     r?   rþ  ÚInteger.__rmod__¤  sp   € Ü×%×%Ü˜%¤×%Ñ%Ü˜u§v¡v™~Ó.Ð.Ü˜E¤7×+Ñ+Ü˜uŸw™w¨¯©Ñ/Ó0Ð0Ü×$Ñ$ TÓ1Ð1Ü× Ñ  Ó-Ð-re   c                óÐ   • [        U[        5      (       a  U R                  U:H  $ [        U[        5      (       a  U R                  UR                  :H  $ [        R                  X5      $ r:   )rL   rW   rz   r‡   r‹   r+  rÑ   s     r?   r+  ÚInteger.__eq__­  sL   € Ü�eœS×!Ñ!Ø—F‘F˜e‘OÐ$Ü˜œw×'Ñ'Ø—F‘F˜eŸg™gÑ%Ð&Ü�‰˜tÓ+Ð+re   c                ó   • X:X  + $ r:   r€   rÑ   s     r?   r/  ÚInteger.__ne__´  r­  re   c                óÖ   •  [        U5      nUR                  (       a"  [        U R                  UR                  :„  5      $ [
        R                  X5      $ ! [         a	    [        s $ f = fr:   )r   r   rÇ   rÉ   rz   r‹   r;  rÑ   s     r?   r;  ÚInteger.__gt__·  óY   € ð	"Ü˜U“OˆEð ××Ü˜DŸF™F U§W¡WÑ,Ó-Ð-Ü�‰˜tÓ+Ð+øô	 ó 	"Ü!Ò!ð	"úó   ‚A ÁA(Á'A(c                óÖ   •  [        U5      nUR                  (       a"  [        U R                  UR                  :  5      $ [
        R                  X5      $ ! [         a	    [        s $ f = fr:   )r   r   rÇ   rÉ   rz   r‹   r4  rÑ   s     r?   r4  ÚInteger.__lt__À  r  r  c                óÖ   •  [        U5      nUR                  (       a"  [        U R                  UR                  :¬  5      $ [
        R                  X5      $ ! [         a	    [        s $ f = fr:   )r   r   rÇ   rÉ   rz   r‹   r?  rÑ   s     r?   r?  ÚInteger.__ge__É  óY   € ð	"Ü˜U“OˆEð ××Ü˜DŸF™F e§g¡gÑ-Ó.Ð.Ü�‰˜tÓ+Ð+øô	 ó 	"Ü!Ò!ð	"úr  c                óÖ   •  [        U5      nUR                  (       a"  [        U R                  UR                  :*  5      $ [
        R                  X5      $ ! [         a	    [        s $ f = fr:   )r   r   rÇ   rÉ   rz   r‹   r8  rÑ   s     r?   r8  ÚInteger.__le__Ò  r#  r  c                ó,   • [        U R                  5      $ r:   )r  rz   r¹   s    r?   rD  ÚInteger.__hash__Û  s   € Ü�D—F‘F‹|Ðre   c                ó   • U R                   $ r:   rs  r¹   s    r?   Ú	__index__ÚInteger.__index__Þ  rï  re   c                ó2   • [        U R                  S-  5      $ ©Nr5   )r·   rz   r¹   s    r?   Ú_eval_is_oddÚInteger._eval_is_oddã  s   € Ü�D—F‘F˜Q‘JÓÐre   c           
     ó”  >• SSK Jn  U[        R                  L a`  U R                  [        R
                  :”  a  [        R                  $ [        R                  [        R                  [        R                  -  -   $ U[        R                  L a(  [        R                  SU S5      [        R                  -  $ [        U[        5      (       d(  U R                  (       a  UR                  (       a  U * U-  $ [        U[        5      (       a  [        TU ]A  U5      $ [        U[        5      (       d  gU[        R"                  L a/  U R                  (       a  [        R                  [%        U * U5      -  $ UR                  (       aq  U* nU R                  (       a9  [        R&                  U-  [        R                  SU R                  * S5      U-  -  $ [        R                  SU R                  S5      U-  $ [)        [+        U R                  5      UR,                  5      u  pEU(       aJ  [/        U[+        UR                  5      -  5      nU R                  (       a  U[        R&                  U-  -  nU$ [1        [+        U R                  5      5      nU" U5      nUSLa  [1        US   5      [1        US   5      0n	O[/        U5      R3                  SS9n	Sn
SnSnSn0 nU	R5                  5        H™  u  nnUUR                  -  n[7        UUR,                  5      u  nnUS:”  a  X¯U-  -  n
US:”  d  MC  [9        UUR,                  5      nUS:w  a6  U[%        U[        R                  UU-  UR,                  U-  S5      5      -  nM•  UXï'   M›     UR5                  5        H$  u  nnUS:X  a  UnM  [9        UU5      nUS:X  d  M$    O   UR5                  5        H  u  nnUUUU-  -  -  nM     XÇ:X  a  U
S:X  a
  US:X  a  SnU$ X«-  [%        U[        XÑR,                  5      5      -  nU R                  (       a  U[%        [        R&                  U5      -  nU$ )a  
Tries to do some simplifications on self**expt

Returns None if no further simplifications can be done.

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

When exponent is a fraction (so we have for example a square root),
we try to find a simpler representation by factoring the argument
up to factors of 2**15, e.g.

  - sqrt(4) becomes 2
  - sqrt(-4) becomes 2*I
  - (2**(3+7)*3**(6+7))**Rational(1,7) becomes 6*18**(3/7)

Further simplification would require a special call to factorint on
the argument which is not done here for sake of speed.

r   )Úperfect_powerr   NFi €  )rÀ  )rÅ  r0  r   r«   rz   r  r
  r¬   r‹   rÝ   rL   r    rS  rŒ  rQ   rC  r  rf  r  rT  r   rX   r|   r‡   rW   rÈ  ÚitemsrÊ   r   )rº   rn   r0  r�  ÚxÚxexactÚresultÚb_posrz   rK  Úout_intÚout_radÚsqr_intÚsqr_gcdÚsqr_dictÚprimeÚexponentÚdiv_eÚdiv_mr�   ÚexÚkÚvr×   s                          €r?   r  ÚInteger._eval_poweræ  sx  ø€ õ* 	8à”1—:‘:ÒØ�v‰vœŸ™‹~Ü—z‘zÐ!ä—:‘:¤§¡´·
±
Ñ :Ñ:Ð:Ø”1×%Ñ%Ò%Ü—=‘=  D¨!Ó,¬a¯j©jÑ8Ð8Ü˜$¤×'Ñ'ð ×× D§L§LØ˜ ‘}Ð$Ü�dœE×"Ñ"ä‘7Ñ& tÓ,Ð,Ü˜$¤×)Ñ)ØØ”1—6‘6Š>˜d×.×.ä—?‘?¤3¨ u¨dÓ#3Ñ3Ð3Ø××à�ˆBØ××Ü—}‘} dÑ*¬8¯=©=¸¸T¿V¹V¸GÀQÓ+GÈÑ+KÑKÐKä—}‘} Q¨¯©°Ó2°BÑ6Ð6ä#¤C¨¯©£K°·±Ó8‰	ˆÞä˜Q¤ D§F¡F£™^Ó,ˆFØ××Øœ!Ÿ-™-¨Ñ-Ñ-�ØˆMô ”C˜Ÿ™“KÓ ˆÙ˜%Ó ˆØ�EŠ>ô ˜˜!™“Iœs 1 Q¡4›yÐ)‰Dä˜5“>×)Ñ)°Ð)Ð6ˆDð ˆØˆØˆØˆØˆØ#Ÿz™zž|‰OˆE�8Ø˜Ÿ™ÑˆHä! (¨D¯F©FÓ3‰LˆE�5Ø�q‹yØ %™<Ñ'�Ø�q�yô ˜ §¡Ó'�Ø˜“6Øœs 5¬(¯-©-¸¸q¹À$Ç&Á&È!Á)ÈQÓ*OÓPÑP’Gà&+�H“Oñ  ,ð —^‘^Ö%‰EˆAˆrØ˜!‹|Ø’ä˜w¨Ó+�Ø˜a•<Ùñ &ð —N‘NÖ$‰DˆAˆqØ�q˜1˜g™:‘Ñ&ŠGñ %àÓ ¨1£°¸A³ØˆFð
 ˆð ‘_¤S¨´(¸7ÇFÁFÓ2KÓ%LÑLˆFØ××Øœ#œaŸm™m¨TÓ2Ñ2�Øˆre   c                ó   • SSK Jn  U" U 5      $ )Nr   )Úisprime)Úsympy.ntheory.primetestrD  )rº   rD  s     r?   Ú_eval_is_primeÚInteger._eval_is_primeT  s   € Ý3á�t‹}Ðre   c                ó:   • U S:”  a  [        U R                  5      $ g)Nr   F)r   Úis_primer¹   s    r?   Ú_eval_is_compositeÚInteger._eval_is_compositeY  s   € Ø�!‹8Ü˜TŸ]™]Ó+Ð+àre   c                ó&   • U [         R                  4$ r:   r^  r¹   s    r?   rÔ  ÚInteger.as_numer_denom_  s   € Ø”Q—U‘Uˆ{Ðre   rÀ   c                ó®   • [        U[        5      (       d  [        $ [        U[        5      (       a  [        U R                  U-  5      $ [        X5      S   $ rõ  )rL   r   rÇ   r‡   rz   rÊ   rÑ   s     r?   Ú__floordiv__ÚInteger.__floordiv__b  sE   € ä˜%¤×&Ñ&Ü!Ð!Ü�eœW×%Ñ%Ü˜4Ÿ6™6 U™?Ó+Ð+Ü�dÓ" 1Ñ%Ð%re   c                óX   • [        [        U5      R                  U R                  -  5      $ r:   rñ  rÑ   s     r?   Ú__rfloordiv__ÚInteger.__rfloordiv__j  s    € Ü”w˜u“~×'Ñ'¨4¯6©6Ñ1Ó2Ð2re   c                ó¤   • [        U[        [        [        R                  45      (       a!  [        U R
                  [        U5      -  5      $ [        $ r:   ©rL   rW   r‡   ÚnumbersÚIntegralrz   rÇ   rÑ   s     r?   Ú
__lshift__ÚInteger.__lshift__t  ó:   € Ü�eœc¤7¬G×,<Ñ,<Ð=×>Ñ>Ü˜4Ÿ6™6¤S¨£ZÑ/Ó0Ð0ä!Ð!re   c                óš   • [        U[        [        R                  45      (       a!  [	        [        U5      U R
                  -  5      $ [        $ r:   ©rL   rW   rV  rW  r‡   rz   rÇ   rÑ   s     r?   Ú__rlshift__ÚInteger.__rlshift__z  ó8   € Ü�eœc¤7×#3Ñ#3Ð4×5Ñ5Üœ3˜u›:¨¯©Ñ/Ó0Ð0ä!Ð!re   c                ó¤   • [        U[        [        [        R                  45      (       a!  [        U R
                  [        U5      -	  5      $ [        $ r:   rU  rÑ   s     r?   Ú
__rshift__ÚInteger.__rshift__€  rZ  re   c                óš   • [        U[        [        R                  45      (       a!  [	        [        U5      U R
                  -	  5      $ [        $ r:   r\  rÑ   s     r?   Ú__rrshift__ÚInteger.__rrshift__†  r_  re   c                ó¤   • [        U[        [        [        R                  45      (       a!  [        U R
                  [        U5      -  5      $ [        $ r:   rU  rÑ   s     r?   Ú__and__ÚInteger.__and__Œ  ó:   € Ü�eœc¤7¬G×,<Ñ,<Ð=×>Ñ>Ü˜4Ÿ6™6¤C¨£JÑ.Ó/Ð/ä!Ð!re   c                óš   • [        U[        [        R                  45      (       a!  [	        [        U5      U R
                  -  5      $ [        $ r:   r\  rÑ   s     r?   Ú__rand__ÚInteger.__rand__’  ó8   € Ü�eœc¤7×#3Ñ#3Ð4×5Ñ5Üœ3˜u›:¨¯©Ñ.Ó/Ð/ä!Ð!re   c                ó¤   • [        U[        [        [        R                  45      (       a!  [        U R
                  [        U5      -  5      $ [        $ r:   rU  rÑ   s     r?   Ú__xor__ÚInteger.__xor__˜  ri  re   c                óš   • [        U[        [        R                  45      (       a!  [	        [        U5      U R
                  -  5      $ [        $ r:   r\  rÑ   s     r?   Ú__rxor__ÚInteger.__rxor__ž  rm  re   c                ó¤   • [        U[        [        [        R                  45      (       a!  [        U R
                  [        U5      -  5      $ [        $ r:   rU  rÑ   s     r?   Ú__or__ÚInteger.__or__¤  ri  re   c                óš   • [        U[        [        R                  45      (       a!  [	        [        U5      U R
                  -  5      $ [        $ r:   r\  rÑ   s     r?   Ú__ror__ÚInteger.__ror__ª  rm  re   c                ó.   • [        U R                  ) 5      $ r:   rñ  r¹   s    r?   Ú
__invert__ÚInteger.__invert__°  rü  re   )>r®   rs  rt  ru  rv  r|   rà  r;   rÉ   ry  rÙ   r˜  r   r´   rm  r  rì   rï   ró   rø   r  r  rÎ   rÒ   r  rá  r  r~  r$  râ  rú  rþ  r+  r/  r;  r4  r?  r8  rD  r)  r-  r  rF  rJ  rÔ  r   rÇ   rO  rR  rX  r]  ra  rd  rg  rk  ro  rr  ru  rx  r{  r|  r}  r~  s   @r?   r‡   r‡   ê  s:  ø† ñð4 	
€AØ€JØ€Ià€Jà€Iò0ò7ð ñó ðò4òòòòòò ò$ò2ò2ò
$ò.ò	-ò.ò	-ò.ò-ò.ò,ò!ò,ò,ò,ò,òòò
 õlò\ò
òñ �˜Ó(ñ&ó )ð&ò3ò"ò"ò"ò"ò"ò"ò"ò"ò"ò"÷ ð  re   r‡   c                  óÜ   ^ • \ rS rSr% SrSrSrSrSr\	r
\" 5       rS\S'   SS jrU 4S jrS	 r\S
 5       rSS jrSS jrS rS rS rS rS r\S 5       rS rSS jrS rSS jrSrU =r $ )ÚAlgebraicNumberi·  a   
Class for representing algebraic numbers in SymPy.

Symbolically, an instance of this class represents an element
$\alpha \in \mathbb{Q}(\theta) \hookrightarrow \mathbb{C}$. That is, the
algebraic number $\alpha$ is represented as an element of a particular
number field $\mathbb{Q}(\theta)$, with a particular embedding of this
field into the complex numbers.

Formally, the primitive element $\theta$ is given by two data points: (1)
its minimal polynomial (which defines $\mathbb{Q}(\theta)$), and (2) a
particular complex number that is a root of this polynomial (which defines
the embedding $\mathbb{Q}(\theta) \hookrightarrow \mathbb{C}$). Finally,
the algebraic number $\alpha$ which we represent is then given by the
coefficients of a polynomial in $\theta$.
)ÚrepÚrootÚaliasÚminpolyÚ_own_minpolyTz
set[Basic]Úfree_symbolsc                ó¢  • SSK JnJn  SSKJn  [        U5      nSnSn	[        U[        [        45      (       a$  Uu  p«U
R                  (       d  SSK
Jn  U" U
5      n
OZUR                  (       a2  UR                  UR                  UR                  UR                   4u  p«p‰OU" XR#                  S5      SS9UpºU
R%                  5       nUbm  [        X%5      (       d%  UR'                  [        U5      SU5      n[        U6 nOYUR)                  UR+                  5       SU5      n[        UR+                  5       6 nO!UR)                  S	S/SU5      n[        S	S5      nUbG  SS
KJn  U" UR+                  5       UR+                  5       U5      nUR)                  USU5      n[        U6 nUR1                  5       U
R1                  5       :¼  a  UR3                  U
R                  5      nX¿4nU=(       d    U	nUb%  S	SKJn  [        UU5      (       d  U" U5      nUU4-   n[8        R:                  " U /UQ76 nUUl        UUl        UUl        U
Ul        SUl        U$ )aE  
Construct a new algebraic number $\alpha$ belonging to a number field
$k = \mathbb{Q}(\theta)$.

There are four instance attributes to be determined:

===========  ============================================================================
Attribute    Type/Meaning
===========  ============================================================================
``root``     :py:class:`~.Expr` for $\theta$ as a complex number
``minpoly``  :py:class:`~.Poly`, the minimal polynomial of $\theta$
``rep``      :py:class:`~sympy.polys.polyclasses.DMP` giving $\alpha$ as poly in $\theta$
``alias``    :py:class:`~.Symbol` for $\theta$, or ``None``
===========  ============================================================================

See Parameters section for how they are determined.

Parameters
==========

expr : :py:class:`~.Expr`, or pair $(m, r)$
    There are three distinct modes of construction, depending on what
    is passed as *expr*.

    **(1)** *expr* is an :py:class:`~.AlgebraicNumber`:
    In this case we begin by copying all four instance attributes from
    *expr*. If *coeffs* were also given, we compose the two coeff
    polynomials (see below). If an *alias* was given, it overrides.

    **(2)** *expr* is any other type of :py:class:`~.Expr`:
    Then ``root`` will equal *expr*. Therefore it
    must express an algebraic quantity, and we will compute its
    ``minpoly``.

    **(3)** *expr* is an ordered pair $(m, r)$ giving the
    ``minpoly`` $m$, and a ``root`` $r$ thereof, which together
    define $\theta$. In this case $m$ may be either a univariate
    :py:class:`~.Poly` or any :py:class:`~.Expr` which represents the
    same, while $r$ must be some :py:class:`~.Expr` representing a
    complex number that is a root of $m$, including both explicit
    expressions in radicals, and instances of
    :py:class:`~.ComplexRootOf` or :py:class:`~.AlgebraicNumber`.

coeffs : list, :py:class:`~.ANP`, None, optional (default=None)
    This defines ``rep``, giving the algebraic number $\alpha$ as a
    polynomial in $\theta$.

    If a list, the elements should be integers or rational numbers.
    If an :py:class:`~.ANP`, we take its coefficients (using its
    :py:meth:`~.ANP.to_list()` method). If ``None``, then the list of
    coefficients defaults to ``[1, 0]``, meaning that $\alpha = \theta$
    is the primitive element of the field.

    If *expr* was an :py:class:`~.AlgebraicNumber`, let $g(x)$ be its
    ``rep`` polynomial, and let $f(x)$ be the polynomial defined by
    *coeffs*. Then ``self.rep`` will represent the composition
    $(f \circ g)(x)$.

alias : str, :py:class:`~.Symbol`, None, optional (default=None)
    This is a way to provide a name for the primitive element. We
    described several ways in which the *expr* argument can define the
    value of the primitive element, but none of these methods gave it
    a name. Here, for example, *alias* could be set as
    ``Symbol('theta')``, in order to make this symbol appear when
    $\alpha$ is printed, or rendered as a polynomial, using the
    :py:meth:`~.as_poly()` method.

Examples
========

Recall that we are constructing an algebraic number as a field element
$\alpha \in \mathbb{Q}(\theta)$.

>>> from sympy import AlgebraicNumber, sqrt, CRootOf, S
>>> from sympy.abc import x

Example (1): $\alpha = \theta = \sqrt{2}$

>>> a1 = AlgebraicNumber(sqrt(2))
>>> a1.minpoly_of_element().as_expr(x)
x**2 - 2
>>> a1.evalf(10)
1.414213562

Example (2): $\alpha = 3 \sqrt{2} - 5$, $\theta = \sqrt{2}$. We can
either build on the last example:

>>> a2 = AlgebraicNumber(a1, [3, -5])
>>> a2.as_expr()
-5 + 3*sqrt(2)

or start from scratch:

>>> a2 = AlgebraicNumber(sqrt(2), [3, -5])
>>> a2.as_expr()
-5 + 3*sqrt(2)

Example (3): $\alpha = 6 \sqrt{2} - 11$, $\theta = \sqrt{2}$. Again we
can build on the previous example, and we see that the coeff polys are
composed:

>>> a3 = AlgebraicNumber(a2, [2, -1])
>>> a3.as_expr()
-11 + 6*sqrt(2)

reflecting the fact that $(2x - 1) \circ (3x - 5) = 6x - 11$.

Example (4): $\alpha = \sqrt{2}$, $\theta = \sqrt{2} + \sqrt{3}$. The
easiest way is to use the :py:func:`~.to_number_field()` function:

>>> from sympy import to_number_field
>>> a4 = to_number_field(sqrt(2), sqrt(2) + sqrt(3))
>>> a4.minpoly_of_element().as_expr(x)
x**2 - 2
>>> a4.to_root()
sqrt(2)
>>> a4.primitive_element()
sqrt(2) + sqrt(3)
>>> a4.coeffs()
[1/2, 0, -9/2, 0]

but if you already knew the right coefficients, you could construct it
directly:

>>> a4 = AlgebraicNumber(sqrt(2) + sqrt(3), [S(1)/2, 0, S(-9)/2, 0])
>>> a4.to_root()
sqrt(2)
>>> a4.primitive_element()
sqrt(2) + sqrt(3)

Example (5): Construct the Golden Ratio as an element of the 5th
cyclotomic field, supposing we already know its coefficients. This time
we introduce the alias $\zeta$ for the primitive element of the field:

>>> from sympy import cyclotomic_poly
>>> from sympy.abc import zeta
>>> a5 = AlgebraicNumber(CRootOf(cyclotomic_poly(5), -1),
...                  [-1, -1, 0, 0], alias=zeta)
>>> a5.as_poly().as_expr()
-zeta**3 - zeta**2
>>> a5.evalf()
1.61803398874989

(The index ``-1`` to ``CRootOf`` selects the complex root with the
largest real and imaginary parts, which in this case is
$\mathrm{e}^{2i\pi/5}$. See :py:class:`~.ComplexRootOf`.)

Example (6): Building on the last example, construct the number
$2 \phi \in \mathbb{Q}(\phi)$, where $\phi$ is the Golden Ratio:

>>> from sympy.abc import phi
>>> a6 = AlgebraicNumber(a5.to_root(), coeffs=[2, 0], alias=phi)
>>> a6.as_poly().as_expr()
2*phi
>>> a6.primitive_element().evalf()
1.61803398874989

Note that we needed to use ``a5.to_root()``, since passing ``a5`` as
the first argument would have constructed the number $2 \phi$ as an
element of the field $\mathbb{Q}(\zeta)$:

>>> a6_wrong = AlgebraicNumber(a5, coeffs=[2, 0])
>>> a6_wrong.as_poly().as_expr()
-2*zeta**3 - 2*zeta**2
>>> a6_wrong.primitive_element().evalf()
0.309016994374947 + 0.951056516295154*I

r   )ÚANPÚDMP)Úminimal_polynomialN©ÚPolyÚgenT©Úpolysr   )Údup_compose)ÚSymbol)Úsympy.polys.polyclassesr†  r‡  Úsympy.polys.numberfieldsrˆ  r	   rL   r—   r   Úis_Polyr¿   rŠ  Úis_AlgebraicNumberr‚  r€  r  r�  ÚgetÚ
get_domainÚfrom_sympy_listÚ	from_listÚto_listÚsympy.polys.densetoolsrŽ  ÚdegreeÚremÚsymbolr�  r   r´   rƒ  )r¯   ÚexprÚcoeffsr�  rÂ   r†  r‡  rˆ  Úrep0Úalias0r‚  r€  rŠ  Údomr  ÚscoeffsrŽ  ÚcÚsargsr�  r°   s                        r?   r´   ÚAlgebraicNumber.__new__×  s  € ÷R 	5Ý?ä�t‹}ˆØˆØˆä�dœU¤E˜N×+Ñ+Ø ‰MˆGà—?—?Ý6Ù˜w›-�øØ×$×$Ø+/¯<©<¸¿¹Ø+/¯8©8°T·Z±Zð+AÑ'ˆG˜4 ñ /Ø—h‘h˜u“o¨Tñ3Ø48ð ð × Ñ Ó"ˆàÑÜ˜f×*Ñ*Ø×)Ñ)¬'°&«/¸1¸cÓB�Ü ˜.‘à—m‘m F§N¡NÓ$4°a¸Ó=�Ü §¡Ó!1Ð2‘ð —-‘-  A ¨¨3Ó/ˆCÜ˜A˜q“kˆGàÑÝ:Ù˜CŸK™K›M¨4¯<©<«>¸3Ó?ˆAØ—-‘-  1 cÓ*ˆCÜ˜Q�iˆGà�:‰:‹<˜7Ÿ>™>Ó+Ó+Ø—'‘'˜'Ÿ+™+Ó&ˆCà�ˆà—˜ˆØÑÝ&Ü˜e V×,Ñ,Ù˜u›�Ø˜U˜HÑ$ˆEä�lŠl˜3Ð' Ò'ˆàˆŒØˆŒØˆŒ	ØˆŒàˆÔàˆ
re   c                ó    >• [         TU ]  5       $ r:   rB  rE  s    €r?   rD  ÚAlgebraicNumber.__hash__¿	  rG  re   c                ó@   • U R                  5       R                  U5      $ r:   )Úas_exprÚ_evalfrØ   s     r?   rÞ   ÚAlgebraicNumber._eval_evalfÂ	  s   € Ø�|‰|‹~×$Ñ$ TÓ*Ð*re   c                ó   • U R                   SL$ )z'Returns ``True`` if ``alias`` was set. N)r�  r¹   s    r?   Ú
is_aliasedÚAlgebraicNumber.is_aliasedÅ	  s   € ð �z‰z Ð%Ð%re   c                ó  • SSK JnJn  Ub  UR                  U R                  U5      $ U R
                  b&  UR                  U R                  U R
                  5      $ SSKJn  UR                  U R                  U" S5      5      $ )z&Create a Poly instance from ``self``. r   )rŠ  ÚPurePolyr   ©ÚDummyr2  )r¿   rŠ  r°  r	  r  r�  rœ  r²  )rº   r2  rŠ  r°  r²  s        r?   Úas_polyÚAlgebraicNumber.as_polyÊ	  s^   € ç8Ø‰=Ø—8‘8˜DŸH™H aÓ(Ð(à�z‰zÑ%Ø—x‘x §¡¨$¯*©*Ó5Ð5å)Ø—|‘| D§H¡H©e°C«jÓ9Ð9re   c                ó‚   • U R                  U=(       d    U R                  5      R                  5       R                  5       $ )z)Create a Basic expression from ``self``. )r³  r€  r©  Úexpand)rº   r2  s     r?   r©  ÚAlgebraicNumber.as_exprÖ	  s+   € à�|‰|˜AŸN §¡Ó+×3Ñ3Ó5×<Ñ<Ó>Ð>re   c                ó¦   • U R                   R                  5        Vs/ s H'  oR                   R                  R                  U5      PM)     sn$ s  snf )z7Returns all SymPy coefficients of an algebraic number. )r  Ú
all_coeffsr¡  Úto_sympy©rº   r£  s     r?   rž  ÚAlgebraicNumber.coeffsÚ	  s:   € à37·8±8×3FÑ3FÔ3HÓJÒ3H¨a—‘—‘×&Ñ& qÖ)Ñ3HÑJÐJùÒJs   �.Ac                ó6   • U R                   R                  5       $ )z8Returns all native coefficients of an algebraic number. )r  r¹  r¹   s    r?   Únative_coeffsÚAlgebraicNumber.native_coeffsÞ	  s   € à�x‰x×"Ñ"Ó$Ð$re   c                óv  • SSK Jn  U R                  nUR                  5       S:X  a  U $ UR                  5       UR	                  5       S-
  -  nUR                  U" UR                  UR                  5       -  5      5      nXC-  nUR                  5       U R                  -  n[        XV4U R                  5       5      $ )z*Convert ``self`` to an algebraic integer. r   r‰  r   )
r¿   rŠ  r‚  ÚLCrš  Úcomposer‹  r€  r~  rž  )rº   rŠ  rœ   ÚcoeffÚpolyr‚  r€  s          r?   Úto_algebraic_integerÚ$AlgebraicNumber.to_algebraic_integerâ	  s‹   € å.à�L‰Lˆà�4‰4‹6�Q‹;ØˆKà—‘“˜Ÿ™› a™Ñ(ˆØ�y‰y™˜aŸe™e A§D¡D£F™lÓ+Ó,ˆà‘*ˆØ�t‰t‹v�d—i‘iÑˆä ˜°·±³Ó>Ð>re   c                ób  • SSK Jn  SSKJn  US   US   pTU R                  R	                  5        Vs/ s H  ofR
                  U:w  d  M  UPM     sn HT  nU" U R                  U-
  5      R                  (       d  M)  U" U5      XT" U R                  5      -  :  d  MI  [        U5      s  $    U $ s  snf )Nr   )ÚCRootOf©r‚  ÚmeasureÚratio)	Úsympy.polys.rootoftoolsrÈ  Úsympy.polysr‚  Ú	all_rootsÚfuncr€  Ú	is_Symbolr~  )rº   rV  rÈ  r‚  rÊ  rË  rÍ   s          r?   Ú_eval_simplifyÚAlgebraicNumber._eval_simplifyó	  s•   € Ý3Ý'Ø 	Ñ*¨F°7©O�Ø!Ÿ\™\×3Ñ3Ô5ÓKÒ5˜¿¹À7Ñ9J—!Ñ5ÔKˆAÙ�t—y‘y 1‘}Ó%×/×/Ñ/á˜1“:  g¨d¯i©iÓ&8Ñ 8Õ8Ü*¨1Ó-Ò-ñ	 Lð
 ˆùò Ls   ²B,Á	B,c                óV   • [        U R                  U R                  4XR                  S9$ )at  
Form another element of the same number field.

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

If we represent $\alpha \in \mathbb{Q}(\theta)$, form another element
$\beta \in \mathbb{Q}(\theta)$ of the same number field.

Parameters
==========

coeffs : list, :py:class:`~.ANP`
    Like the *coeffs* arg to the class
    :py:meth:`constructor<.AlgebraicNumber.__new__>`, defines the
    new element as a polynomial in the primitive element.

    If a list, the elements should be integers or rational numbers.
    If an :py:class:`~.ANP`, we take its coefficients (using its
    :py:meth:`~.ANP.to_list()` method).

Examples
========

>>> from sympy import AlgebraicNumber, sqrt
>>> a = AlgebraicNumber(sqrt(5), [-1, 1])
>>> b = a.field_element([3, 2])
>>> print(a)
1 - sqrt(5)
>>> print(b)
2 + 3*sqrt(5)
>>> print(b.primitive_element() == a.primitive_element())
True

See Also
========

AlgebraicNumber
)rž  r�  )r~  r‚  r€  r�  )rº   rž  s     r?   Úfield_elementÚAlgebraicNumber.field_elementþ	  s*   € ôP Ø�\‰\˜4Ÿ9™9Ð%¨f¿J¹JñHð 	Hre   c                ó\   • U R                  5       nUSS/:H  =(       d    XR                  /:H  $ )z}
Say whether this algebraic number $\alpha \in \mathbb{Q}(\theta)$ is
equal to the primitive element $\theta$ for its field.
r   r   )rž  r€  r»  s     r?   Úis_primitive_elementÚ$AlgebraicNumber.is_primitive_element)
  s+   € ð �K‰K‹Mˆà�Q˜�F‰{×.˜a§I¡I ;Ñ.Ð.re   c                óN   • U R                   (       a  U $ U R                  SS/5      $ )z¢
Get the primitive element $\theta$ for the number field
$\mathbb{Q}(\theta)$ to which this algebraic number $\alpha$ belongs.

Returns
=======

AlgebraicNumber

r   r   )r×  rÔ  r¹   s    r?   Úprimitive_elementÚ!AlgebraicNumber.primitive_element3
  s'   € ð ×$×$ØˆKØ×!Ñ! 1 a &Ó)Ð)re   c                ó~   • U R                   (       a  U $ U R                  5       nU R                  US9n[        X#45      $ )aÇ  
Convert ``self`` to an :py:class:`~.AlgebraicNumber` instance that is
equal to its own primitive element.

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

If we represent $\alpha \in \mathbb{Q}(\theta)$, $\alpha \neq \theta$,
construct a new :py:class:`~.AlgebraicNumber` that represents
$\alpha \in \mathbb{Q}(\alpha)$.

Examples
========

>>> from sympy import sqrt, to_number_field
>>> from sympy.abc import x
>>> a = to_number_field(sqrt(2), sqrt(2) + sqrt(3))

The :py:class:`~.AlgebraicNumber` ``a`` represents the number
$\sqrt{2}$ in the field $\mathbb{Q}(\sqrt{2} + \sqrt{3})$. Rendering
``a`` as a polynomial,

>>> a.as_poly().as_expr(x)
x**3/2 - 9*x/2

reflects the fact that $\sqrt{2} = \theta^3/2 - 9 \theta/2$, where
$\theta = \sqrt{2} + \sqrt{3}$.

``a`` is not equal to its own primitive element. Its minpoly

>>> a.minpoly.as_poly().as_expr(x)
x**4 - 10*x**2 + 1

is that of $\theta$.

Converting to a primitive element,

>>> a_prim = a.to_primitive_element()
>>> a_prim.minpoly.as_poly().as_expr(x)
x**2 - 2

we obtain an :py:class:`~.AlgebraicNumber` whose ``minpoly`` is that of
the number itself.

Parameters
==========

radicals : boolean, optional (default=True)
    If ``True``, then we will try to return an
    :py:class:`~.AlgebraicNumber` whose ``root`` is an expression
    in radicals. If that is not possible (or if *radicals* is
    ``False``), ``root`` will be a :py:class:`~.ComplexRootOf`.

Returns
=======

AlgebraicNumber

See Also
========

is_primitive_element

©Úradicals)r×  Úminpoly_of_elementÚto_rootr~  )rº   rÞ  r›   rÍ   s       r?   Úto_primitive_elementÚ$AlgebraicNumber.to_primitive_elementB
  s>   € ðB ×$×$ØˆKØ×#Ñ#Ó%ˆØ�L‰L (ˆLÐ+ˆÜ ˜vÓ&Ð&re   c                óò   • U R                   c_  U R                  (       a  U R                  U l         U R                   $ SSKJn  U R	                  5       nU" U R                  U5      SS9U l         U R                   $ )a;  
Compute the minimal polynomial for this algebraic number.

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

Recall that we represent an element $\alpha \in \mathbb{Q}(\theta)$.
Our instance attribute ``self.minpoly`` is the minimal polynomial for
our primitive element $\theta$. This method computes the minimal
polynomial for $\alpha$.

r   rÉ  TrŒ  )rƒ  r×  r‚  Ú sympy.polys.numberfields.minpolyrÚ  r©  )rº   r‚  Úthetas      r?   rß  Ú"AlgebraicNumber.minpoly_of_element‰
  sk   € ð ×ÑÑ$Ø×(×(Ø$(§L¡L�Ô!ð
 × Ñ Ð õ EØ×.Ñ.Ó0�Ù$+¨D¯L©L¸Ó,?ÀtÑ$L�Ô!Ø× Ñ Ð re   c                óZ  • U R                   (       a+  [        U R                  [        5      (       d  U R                  $ U=(       d    U R	                  5       nUR                  US9n[        U5      S:X  a  US   $ U R                  5       nU H  nUR                  Xe5      (       d  M  Us  $    g)a3  
Convert to an :py:class:`~.Expr` that is not an
:py:class:`~.AlgebraicNumber`, specifically, either a
:py:class:`~.ComplexRootOf`, or, optionally and where possible, an
expression in radicals.

Parameters
==========

radicals : boolean, optional (default=True)
    If ``True``, then we will try to return the root as an expression
    in radicals. If that is not possible, we will return a
    :py:class:`~.ComplexRootOf`.

minpoly : :py:class:`~.Poly`
    If the minimal polynomial for `self` has been pre-computed, it can
    be passed in order to save time.

rÝ  r   r   N)	r×  rL   r€  r~  rß  rÎ  r†   r©  Ú	same_root)rº   rÞ  r‚  r›   Úrootsr?  r]   s          r?   rà  ÚAlgebraicNumber.to_rootŸ
  s‡   € ð( ×$×$¬Z¸¿	¹	Ä?×-SÑ-SØ—9‘9ÐØ×0�t×.Ñ.Ó0ˆØ—‘ X�Ð.ˆÜˆu‹:˜‹?Ø˜‘8ˆOØ�\‰\‹^ˆÛˆAØ�{‰{˜1×!Ó!Ø’ò re   )rƒ  rC  r:   rD  )TN)!r®   rs  rt  ru  rv  ry  r“  Úis_algebraicr;   r   rz  Úsetr„  rE  r´   rD  rÞ   rN  r­  r³  r©  rž  r¾  rÅ  rÑ  rÔ  r×  rÚ  rá  rß  rà  r|  r}  r~  s   @r?   r~  r~  ·  s¯   ø‡ ñð" D€IàÐØ€LØ€Ið €Dñ
  #›u€L�*Ó$ôfõP"ò+ð ñ&ó ð&ô
:ô?òKò%ò?ò"	ò)HðV ñ/ó ð/ò*ôE'òN!÷,ò re   r~  c                  ó"   • \ rS rSrSrSrS rSrg)ÚRationalConstanti¿
  z˜
Abstract base class for rationals with specific behaviors

Derived classes must define class attributes p and q and should probably all
be singletons.
r€   c                ó.   • [         R                  " U 5      $ r:   ©r   r´   r  s    r?   r´   ÚRationalConstant.__new__È
  ó   € Ü×!Ò! #Ó&Ð&re   N)r®   rs  rt  ru  rv  ry  r´   r|  r€   re   r?   rî  rî  ¿
  s   † ñð €Iõ're   rî  c                  ó   • \ rS rSrSrS rSrg)ÚIntegerConstantiÌ
  r€   c                ó.   • [         R                  " U 5      $ r:   rð  r  s    r?   r´   ÚIntegerConstant.__new__Ï
  rò  re   N)r®   rs  rt  ru  ry  r´   r|  r€   re   r?   rô  rô  Ì
  s   † Ø€Iõ're   rô  c                  óp   • \ 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	 5       r\S
 5       rS rS rS rSrg)r'  iÓ
  zïThe number zero.

Zero is a singleton, and can be accessed by ``S.Zero``

Examples
========

>>> from sympy import S, Integer
>>> Integer(0) is S.Zero
True
>>> 1/S.Zero
zoo

References
==========

.. [1] https://en.wikipedia.org/wiki/Zero
r   r   FTr€   c                ó   • grQ  r€   r¹   s    r?   rm  ÚZero.__getnewargs__ñ
  ó   € Øre   c                 ó"   • [         R                  $ r:   rd  r€   re   r?   r  ÚZero.__abs__ô
  ó   € ä�v‰vˆre   c                 ó"   • [         R                  $ r:   rd  r€   re   r?   r  ÚZero.__neg__ø
  rý  re   c                ó†  • UR                   (       a  U $ UR                  (       a  [        R                  $ UR                  SL a  [        R
                  $ UR                  (       a  [        R                  $ UR                  5       u  p#UR                  (       a  [        R                  U-  $ U[        R                  La  X-  $ g r¨  )
r  r¸   r   r  rI  rª   r"  r  r`  rS  )rº   rn   rÃ  Útermss       r?   r  ÚZero._eval_powerü
  s‘   € Ø×$×$ØˆKØ×$×$Ü×$Ñ$Ð$Ø× Ñ  EÒ)Ü—5‘5ˆLØ�<�<Ü—5‘5ˆLð
 ×(Ñ(Ó*‰ˆØ××Ü×$Ñ$ eÑ+Ð+ØœŸ™ÒØ‘;Ðð re   c                ó   • U $ r:   r€   ©rº   r  s     r?   r  ÚZero._eval_order  ó   € àˆre   c                ó   • gr¨  r€   r¹   s    r?   rã  ÚZero.__bool__  s   € Øre   N)r®   rs  rt  ru  rv  rz   r|   r#  rS  r"  r;   r%  ry  rm  Ústaticmethodr  r  r  r  rã  r|  r€   re   r?   r'  r'  Ó
  sm   † ñð& 	
€AØ	€AØ€KØ€KØ€GØ€IØ€Mà€Iòð ñó ðð ñó ðòò&õre   r'  )Ú	metaclassc                  óv   • \ rS rSrSrSrSrSrSrSr	S r
\S 5       r\S 5       rS	 rS
 r\  SS j5       rSrg)r  i  zåThe number one.

One is a singleton, and can be accessed by ``S.One``.

Examples
========

>>> from sympy import S, Integer
>>> Integer(1) is S.One
True

References
==========

.. [1] https://en.wikipedia.org/wiki/1_%28number%29
Tr   r€   c                ó   • grQ  r€   r¹   s    r?   rm  ÚOne.__getnewargs__0  rú  re   c                 ó"   • [         R                  $ r:   r^  r€   re   r?   r  ÚOne.__abs__3  ó   € ä�u‰uˆre   c                 ó"   • [         R                  $ r:   )r   rT  r€   re   r?   r  ÚOne.__neg__7  s   € ä�}‰}Ðre   c                ó   • U $ r:   r€   ©rº   rn   s     r?   r  ÚOne._eval_power;  rþ   re   c                ó   • g r:   r€   r  s     r?   r  ÚOne._eval_order>  s   € Øre   Nc                ó4   • U(       a  [         R                  $ 0 $ r:   r^  )rÀ  rÁ  rÂ  rÃ  rÄ  rÇ  s         r?   rÈ  ÚOne.factorsA  s   € ö Ü—5‘5ˆLàˆIre   rß  )r®   rs  rt  ru  rv  r;   r#  rz   r|   ry  rm  r	  r  r  r  r  rÈ  r|  r€   re   r?   r  r    ss   † ñð  €IØ€Kà	€AØ	€Aà€Iòð ñó ðð ñó ðòòð ØCHØ&+óó óre   r  c                  óT   • \ rS rSrSrSrSrSrSrS r	\
S 5       r\
S	 5       rS
 rSrg)rT  iJ  a)  The number negative one.

NegativeOne is a singleton, and can be accessed by ``S.NegativeOne``.

Examples
========

>>> from sympy import S, Integer
>>> Integer(-1) is S.NegativeOne
True

See Also
========

One

References
==========

.. [1] https://en.wikipedia.org/wiki/%E2%88%921_%28number%29

Trx   r   r€   c                ó   • grQ  r€   r¹   s    r?   rm  ÚNegativeOne.__getnewargs__h  rú  re   c                 ó"   • [         R                  $ r:   r^  r€   re   r?   r  ÚNegativeOne.__abs__k  r  re   c                 ó"   • [         R                  $ r:   r^  r€   re   r?   r  ÚNegativeOne.__neg__o  r  re   c                ó  • UR                   (       a  [        R                  $ UR                  (       a  [        R                  $ [        U[        5      (       Ga.  [        U[        5      (       a  [        S5      U-  $ U[        R                  L a  [        R                  $ U[        R                  [        R                  4;   a  [        R                  $ U[        R                  L a  [        R                  $ [        U[        5      (       a|  UR                  S:X  a&  [        R                  [        UR                   5      -  $ [#        UR                   UR                  5      u  p#U(       a  X-  U [        X1R                  5      -  -  $ g )Ng      ð¿r5   )Úis_oddr   rT  rŒ  r  rL   r    rQ   rª   r«   r¬   rf  r
  r‹   r|   r‡   rz   rÊ   )rº   rn   r>   rÍ   s       r?   r  ÚNegativeOne._eval_powers  sû   € Ø�;�;Ü—=‘=Ð Ø�<�<Ü—5‘5ˆLÜ�dœF×#Ò#Ü˜$¤×&Ñ&Ü˜T“{ DÑ(Ð(Ø”q—u‘uŠ}Ü—u‘u�ØœŸ
™
¤A×$6Ñ$6Ð7Ó7Ü—u‘u�Ø”q—v‘vŠ~Ü—‘Ð&Ü˜$¤×)Ñ)Ø—6‘6˜Q“;ÜŸ?™?¬G°D·F±F«OÑ;Ð;Ü˜dŸf™f d§f¡fÓ-‘�ÞØ™7 4¬°!·V±VÓ)<Ñ#<Ñ<Ð<Øre   N)r®   rs  rt  ru  rv  r;   rz   r|   ry  rm  r	  r  r  r  r|  r€   re   r?   rT  rT  J  sO   † ñð, €Ià
€AØ	€Aà€Iòð ñó ðð ñó ðõre   rT  c                  ó>   • \ rS rSrSrSrSrSrSrS r	\
S 5       rSrg	)
rf  iŠ  zðThe rational number 1/2.

Half is a singleton, and can be accessed by ``S.Half``.

Examples
========

>>> from sympy import S, Rational
>>> Rational(1, 2) is S.Half
True

References
==========

.. [1] https://en.wikipedia.org/wiki/One_half
Tr   r5   r€   c                ó   • grQ  r€   r¹   s    r?   rm  ÚHalf.__getnewargs__¢  rú  re   c                 ó"   • [         R                  $ r:   )r   rf  r€   re   r?   r  ÚHalf.__abs__¥  rý  re   N)r®   rs  rt  ru  rv  r;   rz   r|   ry  rm  r	  r  r|  r€   re   r?   rf  rf  Š  s6   † ñð  €Ià	€AØ	€Aà€Iòð ñó óre   rf  c                  óÆ  ^ • \ 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S	 jrSS
 jr\" S\5      S 5       r\r\" S\5      S 5       r\" S\5      S 5       r\" S\5      S 5       r\r\" S\5      S 5       rS rS rS rS rU 4S jr S r!S r"\#RH                  r$\#RJ                  r%\#RL                  r&\#RN                  r'\" S\5      S 5       r(\(r)S r*S r+Sr,U =r-$ )r«   iª  a[  Positive infinite quantity.

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

In real analysis the symbol `\infty` denotes an unbounded
limit: `x\to\infty` means that `x` grows without bound.

Infinity is often used not only to define a limit but as a value
in the affinely extended real number system.  Points labeled `+\infty`
and `-\infty` can be added to the topological space of the real numbers,
producing the two-point compactification of the real numbers.  Adding
algebraic properties to this gives us the extended real numbers.

Infinity is a singleton, and can be accessed by ``S.Infinity``,
or can be imported as ``oo``.

Examples
========

>>> from sympy import oo, exp, limit, Symbol
>>> 1 + oo
oo
>>> 42/oo
0
>>> x = Symbol('x')
>>> limit(exp(x), x, oo)
oo

See Also
========

NegativeInfinity, NaN

References
==========

.. [1] https://en.wikipedia.org/wiki/Infinity
TFr€   c                ó.   • [         R                  " U 5      $ r:   rð  r  s    r?   r´   ÚInfinity.__new__Þ  rò  re   c                ó   • g)Nz\inftyr€   ©rº   Úprinters     r?   Ú_latexÚInfinity._latexá  ó   € Øre   c                ó   • X:X  a  U$ g r:   r€   r  s      r?   r
  ÚInfinity._eval_subsä  ó   € Ø‹;ØˆJð re   c                ó   • [        S5      $ ©Nr£   ©rQ   rØ   s     r?   rÞ   ÚInfinity._eval_evalfè  s   € Ü�U‹|Ðre   c                ó$   • U R                  U5      $ r:   ©rÞ   ©rº   rk   Úoptionss      r?   r&  ÚInfinity.evalfë  ó   € Ø×Ñ Ó%Ð%re   rÀ   c                óì   • [        U[        5      (       aK  [        R                  (       a6  U[        R
                  [        R                  4;   a  [        R                  $ U $ [        R                  X5      $ r:   )rL   r    r4   r  r   r¬   rª   r  rÑ   s     r?   r  ÚInfinity.__add__î  óL   € ä�eœV×$Ñ$Ô):×)C×)CØœ×+Ñ+¬Q¯U©UÐ3Ó3Ü—u‘u�ØˆKÜ�~‰~˜dÓ*Ð*re   c                óì   • [        U[        5      (       aK  [        R                  (       a6  U[        R
                  [        R                  4;   a  [        R                  $ U $ [        R                  X5      $ r:   )rL   r    r4   r  r   r«   rª   r  rÑ   s     r?   r  ÚInfinity.__sub__÷  óJ   € ä�eœV×$Ñ$Ô):×)C×)CØœŸ™¤Q§U¡UÐ+Ó+Ü—u‘u�ØˆKÜ�~‰~˜dÓ*Ð*re   c                ó&   • U * R                  U5      $ r:   ©r  rÑ   s     r?   r~  ÚInfinity.__rsub__ÿ  ó   € à��‰˜uÓ%Ð%re   c                ó.  • [        U[        5      (       al  [        R                  (       aW  UR                  (       d  U[
        R                  L a  [
        R                  $ UR                  (       a  U $ [
        R                  $ [        R                  X5      $ r:   )
rL   r    r4   r  r"  r   rª   r  r¬   r$  rÑ   s     r?   r$  ÚInfinity.__mul__  s[   € ä�eœV×$Ñ$Ô):×)C×)CØ�}�} ¬¯©¢Ü—u‘u�Ø×)×)Ø�Ü×%Ñ%Ð%Ü�~‰~˜dÓ*Ð*re   c                óX  • [        U[        5      (       a�  [        R                  (       al  U[        R
                  L d&  U[        R                  L d  U[        R                  L a  [        R                  $ UR                  (       a  U $ [        R                  $ [        R                  X5      $ r:   ©
rL   r    r4   r  r   r«   r¬   rª   Úis_extended_nonnegativer(  rÑ   s     r?   r(  ÚInfinity.__truediv__  sq   € ä�eœV×$Ñ$Ô):×)C×)CØœŸ
™
Ò"Øœ×+Ñ+Ò+ØœQŸU™U’NÜ—u‘u�Ø×,×,Ø�Ü×%Ñ%Ð%Ü×!Ñ! $Ó.Ð.re   c                ó"   • [         R                  $ r:   ©r   r«   r¹   s    r?   r  ÚInfinity.__abs__  ó   € Ü�z‰zÐre   c                ó"   • [         R                  $ r:   )r   r¬   r¹   s    r?   r  ÚInfinity.__neg__  s   € Ü×!Ñ!Ð!re   c                ó\  • UR                   (       a  [        R                  $ UR                  (       a  [        R                  $ U[        R
                  L a  [        R
                  $ U[        R                  L a  [        R
                  $ UR                  SL a•  UR                  (       aƒ  SSK	J
n  U" U5      nUR                  (       a  [        R                  $ UR                  (       a  [        R                  $ UR                  (       a  [        R
                  $ XR                  5       -  $ gg)au  
``expt`` is symbolic object but not equal to 0 or 1.

================ ======= ==============================
Expression       Result  Notes
================ ======= ==============================
``oo ** nan``    ``nan``
``oo ** -p``     ``0``   ``p`` is number, ``oo``
================ ======= ==============================

See Also
========
Pow
NaN
NegativeInfinity

Fr   )r  N)r  r   r«   r¸   r'  rª   r  rI  r;   rÅ   r  r#  rS  r"  r&  )rº   rn   r  Ú	expt_reals       r?   r  ÚInfinity._eval_power   sÄ   € ð$ ×$×$Ü—:‘:ÐØ×$×$Ü—6‘6ˆMØ”1—5‘5Š=Ü—5‘5ˆLØ”1×$Ñ$Ò$Ü—5‘5ˆLØ× Ñ  EÒ)¨d¯n¯nÝ?Ù˜4›ˆIØ×$×$Ü×(Ñ(Ð(Ø×$×$Ü—v‘v�Ø× × Ü—u‘u�àŸ™›Ñ%Ð%ð /=Ð)re   c                ó"   • [         R                  $ r:   )rç   r+   rØ   s     r?   rÙ   ÚInfinity._as_mpf_valF  s   € Ü�y‰yÐre   c                ó    >• [         TU ]  5       $ r:   rB  rE  s    €r?   rD  ÚInfinity.__hash__I  rG  re   c                óP   • U[         R                  L =(       d    U[        S5      :H  $ r6  ©r   r«   r¦   rÑ   s     r?   r+  ÚInfinity.__eq__L  s   € ØœŸ
™
Ð"×; e¬u°U«|Ñ&;Ð;re   c                óP   • U[         R                  L=(       a    U[        S5      :g  $ r6  r]  rÑ   s     r?   r/  ÚInfinity.__ne__O  s   € ØœAŸJ™JÐ&×@¨5´E¸%³LÑ+@Ð@re   c                óX   • [        U[        5      (       d  [        $ [        R                  $ r:   ©rL   r   rÇ   r   rª   rÑ   s     r?   rú  ÚInfinity.__mod__W  ó   € ä˜%¤×&Ñ&Ü!Ð!Ü�u‰uˆre   c                ó   • U $ r:   r€   r¹   s    r?   rì   ÚInfinity.floor_  rþ   re   c                ó   • U $ r:   r€   r¹   s    r?   rï   ÚInfinity.ceilingb  rþ   re   r:   ).r®   rs  rt  ru  rv  rw  r;   Ú
is_complexrI  rÆ   r%  r  rI  ry  r´   r/  r
  rÞ   r&  r   rÇ   r  rá  r  r~  r$  râ  r(  r  r  r  rÙ   rD  r+  r/  r   r;  r?  r4  r8  rú  rþ  rì   rï   r|  r}  r~  s   @r?   r«   r«   ª  s^  ø† ñ&ðP €NØ€IØ€JØÐØ€KØ€MØÐØ€Hà€Iò'òòôô&ñ �˜Ó(ñ+ó )ð+ð €Há�˜Ó(ñ+ó )ð+ñ �˜Ó(ñ&ó )ð&ñ �˜Ó(ñ+ó )ð+ð €Há�˜Ó(ñ	/ó )ð	/òò"ò$&òLõ"ò<òAð �[‰[€FØ�[‰[€FØ�[‰[€FØ�[‰[€Fá�˜Ó(ñó )ðð
 €Hò÷ð re   r«   c                  óÌ  ^ • \ 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S	 jrSS
 jr\" S\5      S 5       r\r\" S\5      S 5       r\" S\5      S 5       r\" S\5      S 5       r\r\" S\5      S 5       rS rS rS rS rU 4S jr S r!S r"\#RH                  r$\#RJ                  r%\#RL                  r&\#RN                  r'\" S\5      S 5       r(\(r)S r*S r+S r,Sr-U =r.$ )r¬   ih  zŠNegative infinite quantity.

NegativeInfinity is a singleton, and can be accessed
by ``S.NegativeInfinity``.

See Also
========

Infinity
TFr€   c                ó.   • [         R                  " U 5      $ r:   rð  r  s    r?   r´   ÚNegativeInfinity.__new__  rò  re   c                ó   • g)Nz-\inftyr€   r-  s     r?   r/  ÚNegativeInfinity._latex‚  s   € Øre   c                ó   • X:X  a  U$ g r:   r€   r  s      r?   r
  ÚNegativeInfinity._eval_subs…  r4  re   c                ó   • [        S5      $ ©Nr¥   r7  rØ   s     r?   rÞ   ÚNegativeInfinity._eval_evalf‰  s   € Ü�V‹}Ðre   c                ó$   • U R                  U5      $ r:   r:  r;  s      r?   r&  ÚNegativeInfinity.evalfŒ  r>  re   rÀ   c                óì   • [        U[        5      (       aK  [        R                  (       a6  U[        R
                  [        R                  4;   a  [        R                  $ U $ [        R                  X5      $ r:   )rL   r    r4   r  r   r«   rª   r  rÑ   s     r?   r  ÚNegativeInfinity.__add__�  rD  re   c                óì   • [        U[        5      (       aK  [        R                  (       a6  U[        R
                  [        R                  4;   a  [        R                  $ U $ [        R                  X5      $ r:   )rL   r    r4   r  r   r¬   rª   r  rÑ   s     r?   r  ÚNegativeInfinity.__sub__˜  rA  re   c                ó&   • U * R                  U5      $ r:   rF  rÑ   s     r?   r~  ÚNegativeInfinity.__rsub__   rH  re   c                ó.  • [        U[        5      (       al  [        R                  (       aW  UR                  (       d  U[
        R                  L a  [
        R                  $ UR                  (       a  U $ [
        R                  $ [        R                  X5      $ r:   )
rL   r    r4   r  r"  r   rª   r  r«   r$  rÑ   s     r?   r$  ÚNegativeInfinity.__mul__¤  sY   € ä�eœV×$Ñ$Ô):×)C×)CØ�}�} ¬¯©¢Ü—u‘u�Ø×)×)Ø�Ü—:‘:ÐÜ�~‰~˜dÓ*Ð*re   c                óX  • [        U[        5      (       a�  [        R                  (       al  U[        R
                  L d&  U[        R                  L d  U[        R                  L a  [        R                  $ UR                  (       a  U $ [        R
                  $ [        R                  X5      $ r:   rL  rÑ   s     r?   r(  ÚNegativeInfinity.__truediv__¯  so   € ä�eœV×$Ñ$Ô):×)C×)CØœŸ
™
Ò"Øœ×+Ñ+Ò+ØœQŸU™U’NÜ—u‘u�Ø×,×,Ø�Ü—:‘:ÐÜ×!Ñ! $Ó.Ð.re   c                ó"   • [         R                  $ r:   rP  r¹   s    r?   r  ÚNegativeInfinity.__abs__»  rR  re   c                ó"   • [         R                  $ r:   rP  r¹   s    r?   r  ÚNegativeInfinity.__neg__¾  rR  re   c                óx  • UR                   (       Ga(  U[        R                  L d&  U[        R                  L d  U[        R                  L a  [        R                  $ [        U[        5      (       aB  UR                  (       a1  UR                  (       a  [        R                  $ [        R                  $ [        R                  U-  n[        R                  U-  nUS:X  a  UR                  (       a  U$ U[        R                  L a2  UR                  (       a!  UR                  (       d  [        R                  $ X2-  $ g)aÞ  
``expt`` is symbolic object but not equal to 0 or 1.

================ ======= ==============================
Expression       Result  Notes
================ ======= ==============================
``(-oo) ** nan`` ``nan``
``(-oo) ** oo``  ``nan``
``(-oo) ** -oo`` ``nan``
``(-oo) ** e``   ``oo``  ``e`` is positive even integer
``(-oo) ** o``   ``-oo`` ``o`` is positive odd integer
================ ======= ==============================

See Also
========

Infinity
Pow
NaN

r   N)r;   r   rª   r«   r¬   rL   r‡   r  r"  rT  rƒ   r  r"  )rº   rn   Úinf_partÚs_parts       r?   r  ÚNegativeInfinity._eval_powerÁ  sÓ   € ð, �>�>ˆ>Ø”q—u‘uŠ}ØœŸ
™
Ò"ØœA×.Ñ.Ò.Ü—u‘u�ä˜$¤×(Ñ(¨T×-F×-FØ—;—;Ü×-Ñ-Ð-äŸ:™:Ð%ä—z‘z 4Ñ'ˆHÜ—]‘] DÑ(ˆFØ˜1‹} ×!1×!1Ø�ØœA×-Ñ-Ò-Ø×$×$¨V¯^¯^Ü×(Ñ(Ð(Ø‘?Ð"ð' re   c                ó"   • [         R                  $ r:   )rç   r,   rØ   s     r?   rÙ   ÚNegativeInfinity._as_mpf_valì  s   € Ü�z‰zÐre   c                ó    >• [         TU ]  5       $ r:   rB  rE  s    €r?   rD  ÚNegativeInfinity.__hash__ï  rG  re   c                óP   • U[         R                  L =(       d    U[        S5      :H  $ rr  ©r   r¬   r¦   rÑ   s     r?   r+  ÚNegativeInfinity.__eq__ò  s!   € Øœ×*Ñ*Ð*×D¨e´u¸V³}Ñ.DÐDre   c                óP   • U[         R                  L=(       a    U[        S5      :g  $ rr  r�  rÑ   s     r?   r/  ÚNegativeInfinity.__ne__õ  s!   € ØœA×.Ñ.Ð.×I°5¼EÀ&»MÑ3IÐIre   c                óX   • [        U[        5      (       d  [        $ [        R                  $ r:   rb  rÑ   s     r?   rú  ÚNegativeInfinity.__mod__ý  rd  re   c                ó   • U $ r:   r€   r¹   s    r?   rì   ÚNegativeInfinity.floor  rþ   re   c                ó   • U $ r:   r€   r¹   s    r?   rï   ÚNegativeInfinity.ceiling  rþ   re   c                óF   • [         R                  S[         R                  S0$ r"  )r   rT  r«   r¹   s    r?   Úas_powers_dictÚNegativeInfinity.as_powers_dict  s   € Ü—‘˜q¤!§*¡*¨aÐ0Ð0re   r:   )/r®   rs  rt  ru  rv  rI  ri  rw  rÆ   r%  r¸   r;   rI  ry  r´   r/  r
  rÞ   r&  r   rÇ   r  rá  r  r~  r$  râ  r(  r  r  r  rÙ   rD  r+  r/  r   r;  r?  r4  r8  rú  rþ  rì   rï   r˜  r|  r}  r~  s   @r?   r¬   r¬   h  sc  ø† ñ	ð ÐØ€JØ€NØ€KØ€MØÐØ€IØ€Hà€Iò'òòôô&ñ �˜Ó(ñ+ó )ð+ð €Há�˜Ó(ñ+ó )ð+ñ �˜Ó(ñ&ó )ð&ñ �˜Ó(ñ+ó )ð+ð €Há�˜Ó(ñ	/ó )ð	/òòò)#òVõ"òEòJð �[‰[€FØ�[‰[€FØ�[‰[€FØ�[‰[€Fá�˜Ó(ñó )ðð
 €Hòò÷1ð 1re   r¬   c                  óp  ^ • \ 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
\5      S 5       r\" S
\5      S 5       r\" S
\5      S 5       r\" S
\5      S 5       rS rS rS rU 4S jr S r!S r"\#RH                  r$\#RJ                  r%\#RL                  r&\#RN                  r'Sr(U =r)$ )rª   i  a¢  
Not a Number.

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

This serves as a place holder for numeric values that are indeterminate.
Most operations on NaN, produce another NaN.  Most indeterminate forms,
such as ``0/0`` or ``oo - oo` produce NaN.  Two exceptions are ``0**0``
and ``oo**0``, which all produce ``1`` (this is consistent with Python's
float).

NaN is loosely related to floating point nan, which is defined in the
IEEE 754 floating point standard, and corresponds to the Python
``float('nan')``.  Differences are noted below.

NaN is mathematically not equal to anything else, even NaN itself.  This
explains the initially counter-intuitive results with ``Eq`` and ``==`` in
the examples below.

NaN is not comparable so inequalities raise a TypeError.  This is in
contrast with floating point nan where all inequalities are false.

NaN is a singleton, and can be accessed by ``S.NaN``, or can be imported
as ``nan``.

Examples
========

>>> from sympy import nan, S, oo, Eq
>>> nan is S.NaN
True
>>> oo - oo
nan
>>> nan + 1
nan
>>> Eq(nan, nan)   # mathematical equality
False
>>> nan == nan     # structural equality
True

References
==========

.. [1] https://en.wikipedia.org/wiki/NaN

TNFr€   c                ó.   • [         R                  " U 5      $ r:   rð  r  s    r?   r´   ÚNaN.__new__P  rò  re   c                ó   • g)Nz
\text{NaN}r€   r-  s     r?   r/  Ú
NaN._latexS  s   € Øre   c                ó   • U $ r:   r€   r¹   s    r?   r  ÚNaN.__neg__V  rþ   re   rÀ   c                ó   • U $ r:   r€   rÑ   s     r?   r  ÚNaN.__add__Y  r  re   c                ó   • U $ r:   r€   rÑ   s     r?   r  ÚNaN.__sub__]  r  re   c                ó   • U $ r:   r€   rÑ   s     r?   r$  ÚNaN.__mul__a  r  re   c                ó   • U $ r:   r€   rÑ   s     r?   r(  ÚNaN.__truediv__e  r  re   c                ó   • U $ r:   r€   r¹   s    r?   rì   Ú	NaN.floori  rþ   re   c                ó   • U $ r:   r€   r¹   s    r?   rï   ÚNaN.ceilingl  rþ   re   c                ó   • [         $ r:   )r¢  rØ   s     r?   rÙ   ÚNaN._as_mpf_valo  s   € Üˆre   c                ó    >• [         TU ]  5       $ r:   rB  rE  s    €r?   rD  ÚNaN.__hash__r  rG  re   c                ó&   • U[         R                  L $ r:   ©r   rª   rÑ   s     r?   r+  Ú
NaN.__eq__u  s   € àœŸ™ˆ~Ðre   c                ó&   • U[         R                  L$ r:   r²  rÑ   s     r?   r/  Ú
NaN.__ne__y  s   € ØœAŸE™EÐ!Ð!re   )*r®   rs  rt  ru  rv  rw  rI  rH  rF  rë  Úis_transcendentalrà  r%  rƒ   r"  rI  r#  rS  r;   ry  r´   r/  r  r   rÇ   r  r  r$  r(  rì   rï   rÙ   rD  r+  r/  r   r;  r?  r4  r8  r|  r}  r~  s   @r?   rª   rª     s  ø† ñ.ð^ €NØÐØ€GØ€KØ€LØÐØ€JØ€MØ€IØ€GØ€HØ€KØ€KØ€Ià€Iò'òòñ �˜Ó(ñó )ðñ �˜Ó(ñó )ðñ �˜Ó(ñó )ðñ �˜Ó(ñó )ðòòòõ"òò"ð �[‰[€FØ�[‰[€FØ�[‰[€FØ�[‰[†Fre   rª   c                ó   • gr¨  r€   )r\   r]   s     r?   Ú_eval_is_eqr¸  „  ó   € àre   c                  óv   • \ rS rSrSrSrSrSrSrSr	Sr
\rSrS rS r\S 5       rS	 rS
 r\S 5       rS rSrg)r  i‰  a¾  Complex infinity.

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

In complex analysis the symbol `\tilde\infty`, called "complex
infinity", represents a quantity with infinite magnitude, but
undetermined complex phase.

ComplexInfinity is a singleton, and can be accessed by
``S.ComplexInfinity``, or can be imported as ``zoo``.

Examples
========

>>> from sympy import zoo
>>> zoo + 42
zoo
>>> 42/zoo
0
>>> zoo + zoo
nan
>>> zoo*zoo
zoo

See Also
========

Infinity
TFr€   c                ó.   • [         R                  " U 5      $ r:   rð  r  s    r?   r´   ÚComplexInfinity.__new__´  rò  re   c                ó   • g)Nz\tilde{\infty}r€   r-  s     r?   r/  ÚComplexInfinity._latex·  s   € Ø re   c                 ó"   • [         R                  $ r:   rP  r€   re   r?   r  ÚComplexInfinity.__abs__º  s   € ä�z‰zÐre   c                ó   • U $ r:   r€   r¹   s    r?   rì   ÚComplexInfinity.floor¾  rþ   re   c                ó   • U $ r:   r€   r¹   s    r?   rï   ÚComplexInfinity.ceilingÁ  rþ   re   c                 ó"   • [         R                  $ r:   )r   r  r€   re   r?   r  ÚComplexInfinity.__neg__Ä  s   € ä× Ñ Ð re   c                ó  • U[         R                  L a  [         R                  $ [        U[        5      (       aR  UR
                  (       a  [         R                  $ UR                  (       a  [         R                  $ [         R                  $ g r:   )r   r  rª   rL   r    r"  r#  r'  r  s     r?   r  ÚComplexInfinity._eval_powerÈ  sY   € Ø”1×$Ñ$Ò$Ü—5‘5ˆLä�dœF×#Ñ#Ø�|�|Ü—u‘u�à×#×#Ü×,Ñ,Ð,äŸ6™6�Mð $re   N)r®   rs  rt  ru  rv  rw  rÆ   r;   rI  ri  rI  r   rz  ry  r´   r/  r	  r  rì   rï   r  r  r|  r€   re   r?   r  r  ‰  ss   † ñð> €NØ€KØ€IØ€HØ€JØÐà€Dà€Iò'ò!ð ñó ðòòð ñ!ó ð!õ"re   r  c                  óp   ^ • \ rS rSrSrSrSrSrSr\	r
S rS rS rS rS rS	 rS
 rS rU 4S jrSrU =r$ )r™  iÙ  Tr€   c                ó.   • [         R                  " U 5      $ r:   rð  r  s    r?   r´   ÚNumberSymbol.__new__å  rò  re   c                ó   • g)z|Return an interval with number_cls endpoints
that contains the value of NumberSymbol.
If not implemented, then return None.
Nr€   ©rº   Ú
number_clss     r?   ÚapproximationÚNumberSymbol.approximationè  s   � re   c                óL   • [         R                  U R                  U5      U5      $ r:   rÜ   rØ   s     r?   rÞ   ÚNumberSymbol._eval_evalfî  rà   re   c                ó˜   •  [        U5      nXL a  gUR                  (       a  U R                  (       a  gg! [         a	    [        s $ f = frÆ  )r   r   rÇ   rx  rG  rÑ   s     r?   r+  ÚNumberSymbol.__eq__ñ  sF   € ð	"Ü˜U“OˆEð Š=ØØ�?�?˜t×1×1Øàøô ó 	"Ü!Ò!ð	"ús   ‚6 ¶A	ÁA	c                ó   • X:X  + $ r:   r€   rÑ   s     r?   r/  ÚNumberSymbol.__ne__ý  r­  re   c                óV   • XL a  [         R                  $ [        R                  " X5      $ r:   )r   Útruer   r8  rÑ   s     r?   r8  ÚNumberSymbol.__le__   ó   € ØŠ=Ü—6‘6ˆMÜ�{Š{˜4Ó'Ð're   c                óV   • XL a  [         R                  $ [        R                  " X5      $ r:   )r   rØ  r   r?  rÑ   s     r?   r?  ÚNumberSymbol.__ge__  rÚ  re   c                ó   • [         er:   r  r¹   s    r?   r  ÚNumberSymbol.__int__
  s   € ä!Ð!re   c                ó    >• [         TU ]  5       $ r:   rB  rE  s    €r?   rD  ÚNumberSymbol.__hash__  rG  re   )r®   rs  rt  ru  rw  rƒ   r;   ry  r©  r   rz  r´   rÏ  rÞ   r+  r/  r8  r?  r  rD  r|  r}  r~  s   @r?   r™  r™  Ù  sS   ø† à€NØ€IØ€Ià€Ià€Oà€Dò'òò8ò
ò!ò(ò
(ò
"÷"ó "re   r™  c                  óx   • \ 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 5       rS rS	 rS
 rS rS rS rS rSrg)ÚExp1i  aò  The `e` constant.

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

The transcendental number `e = 2.718281828\ldots` is the base of the
natural logarithm and of the exponential function, `e = \exp(1)`.
Sometimes called Euler's number or Napier's constant.

Exp1 is a singleton, and can be accessed by ``S.Exp1``,
or can be imported as ``E``.

Examples
========

>>> from sympy import exp, log, E
>>> E is exp(1)
True
>>> log(E)
1

References
==========

.. [1] https://en.wikipedia.org/wiki/E_%28mathematical_constant%29
TFr€   c                ó   • g)Nr�   r€   r-  s     r?   r/  ÚExp1._latex8  rM  re   c                 ó"   • [         R                  $ r:   )r   râ  r€   re   r?   r  ÚExp1.__abs__;  rý  re   c                ó   • gr,  r€   r¹   s    r?   r  ÚExp1.__int__?  ó   € Øre   c                ó   • [        U5      $ r:   )r(   rØ   s     r?   rÙ   ÚExp1._as_mpf_valB  s   € Ü�T‹{Ðre   c                ó†   • [        U[        5      (       a  [        S5      [        S5      4$ [        U[        5      (       a  g g )Nr5   r…  ©Ú
issubclassr‡   r‹   rÍ  s     r?   Úapproximation_intervalÚExp1.approximation_intervalE  s7   € Ü�j¤'×*Ñ*Ü˜A“J¤¨£
Ð+Ð+Ü˜
¤H×-Ñ-Øð .re   c                ój   • [         R                  (       a  U R                  U5      $ SSKJn  U" U5      $ )Nr   )r¨  )r4   Ú
exp_is_powÚ_eval_power_exp_is_powÚ&sympy.functions.elementary.exponentialr¨  )rº   rn   r¨  s      r?   r  ÚExp1._eval_powerK  s)   € Ü×'×'Ø×.Ñ.¨tÓ4Ð4åBÙ�t“9Ðre   c                óÜ  • UR                   (       a*  U[        L a  [        $ U[        * :X  a  [        R                  $ SSKJn  [        X5      (       a  UR                  S   $ UR                  (       Gdå  [        [        -  nXU* 4;   a  [        $ UR                  [        [        -  5      nU(       Ga  SU-  R                  (       a”  UR                  (       a  [        R                  $ UR                   (       a  [        R"                  $ U[        R$                  -   R                  (       a  [        * $ U[        R$                  -   R                   (       a  [        $ O[UR&                  (       aJ  US-  nUS:”  a  US-  nXT:w  a5  [        R(                  U[        R*                  -  [        R,                  -  -  $ UR/                  5       u  pFU[        [        * 4;   a  g U/S p‡[0        R2                  " U5       HM  n	[        X’5      (       a  Uc  U	R                  S   nM'    g U	R4                  (       a  UR7                  U	5        MM    g    U(       a  U[1        U6 -  $ S $ UR                  (       aã  / n
/ nSnUR                   H¤  nU[        R                  L a  UR7                  U5        M)  X-  n[        U[8        5      (       aQ  UR:                  U L aB  UR<                  U:w  a  UR7                  UR<                  5        SnM€  UR7                  U5        M“  U
R7                  U5        M¦     U
(       d  U(       a  [1        U
6 [9        U [?        U6 SS9-  $ g UR@                  (       a  UR=                  5       $ g )Nr   )Úlogr5   r   FTr  )!rx  Úoor   r'  rô  r÷  rL   rÂ   Úis_AddÚIr¢   rÃ  Úpirà  rŒ  r  r"  rT  rf  rR  râ  ÚPir
  r`  ÚMulÚ	make_argsr%  Úappendr  Úbaser¨  r  Ú	is_Matrix)rº   r©  r÷  ÚIoorÃ  Úncoeffr  rž  Úlog_termÚtermÚoutÚaddÚ
argchangedr\   Únewas                  r?   ró  ÚExp1._eval_power_exp_is_powR  s‰  € Ø�=�=Ø”bŠyÜ�	Øœ˜“Ü—v‘v�Ý>Ü�c×ÑØ—8‘8˜A‘;Ðð ——�Ü”B‘$ˆCØ˜S˜D�kÓ!Ü�
à—I‘Iœb¤™d“OˆEßØ�e‘G×'×'Ø—}—}Ü Ÿu™u˜ØŸŸÜ Ÿ}™}Ð,Ø¤!§&¡&™.×1×1Ü !˜r˜	Ø¤!§&¡&™.×0×0Ü ˜ð 1à×&×&Ø" Q™Y�FØ “zØ !™˜Ø“Ü Ÿv™v¨¬q¯t©t©´A·O±OÑ(CÑDÐDð ×+Ñ+Ó-‰LˆEð œœb˜S˜	Ó!Øà %˜w¨�HÜŸš eÖ,�Ü˜d×(Ñ(ØÑ'Ø#'§9¡9¨Q¡<šáØ×'×'Ø—M‘M $Ö'áñ -ö .6�8œS &˜\Ñ)Ð?¸4Ð?Ø�Z�ZØˆCØˆCØˆJØ—X”X�ØœŸ™’:Ø—J‘J˜q”MÙØ‘w�Ü˜d¤C×(Ñ(¨T¯Y©Y¸$Ò->Ø—x‘x 1“}ØŸ
™
 4§8¡8Ô,Ø%)š
àŸ
™
 1žà—J‘J˜tÖ$ñ ö –jÜ˜C�y¤ T¬3°¨9¸uÑ!EÑEÐEð !à�]�]Ø—7‘7“9Ðð re   c                óv   • SSK Jn  U" [        [        R                  S-  -   5      [        U" [        5      -  -
  $ )Nr   )Úsinr5   )Ú(sympy.functions.elementary.trigonometricr  rú  r   rü  )rº   rV  r  s      r?   Ú_eval_rewrite_as_sinÚExp1._eval_rewrite_as_sin¢  s(   € Ý@Ù”1”q—t‘t˜A‘v‘:‹¤¡3¤q£6¡Ñ)Ð)re   c                óv   • SSK Jn  U" [        5      [        U" [        [        R                  S-  -   5      -  -   $ )Nr   )Úcosr5   )r  r  rú  r   rü  )rº   rV  r  s      r?   Ú_eval_rewrite_as_cosÚExp1._eval_rewrite_as_cos¦  s)   € Ý@Ù”1‹vœ™#œa¤!§$¡$ q¡&™j›/Ñ)Ñ)Ð)re   N)r®   rs  rt  ru  rv  rH  r#  rS  rG  r;   rë  r¶  ry  r/  r	  r  r  rÙ   rï  r  ró  r  r  r|  r€   re   r?   râ  râ    sp   † ñð6 €GØ€KØ€KØ€MØ€IØ€LØÐà€Iòð ñó ðòòòòòNò`*õ*re   râ  c                  ó`   • \ 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 5       rS rS	 rS
 rSrg)rü  i­  a‹  The `\pi` constant.

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

The transcendental number `\pi = 3.141592654\ldots` represents the ratio
of a circle's circumference to its diameter, the area of the unit circle,
the half-period of trigonometric functions, and many other things
in mathematics.

Pi is a singleton, and can be accessed by ``S.Pi``, or can
be imported as ``pi``.

Examples
========

>>> from sympy import S, pi, oo, sin, exp, integrate, Symbol
>>> S.Pi
pi
>>> pi > 3
True
>>> pi.is_irrational
True
>>> x = Symbol('x')
>>> sin(x + 2*pi)
sin(x)
>>> integrate(exp(-x**2), (x, -oo, oo))
sqrt(pi)

References
==========

.. [1] https://en.wikipedia.org/wiki/Pi
TFr€   c                ó   • g)Nz\pir€   r-  s     r?   r/  Ú	Pi._latexÛ  s   € Øre   c                 ó"   • [         R                  $ r:   )r   rü  r€   re   r?   r  Ú
Pi.__abs__Þ  s   € ä�t‰tˆre   c                ó   • g)Nr…  r€   r¹   s    r?   r  Ú
Pi.__int__â  ré  re   c                ó   • [        U5      $ r:   )r'   rØ   s     r?   rÙ   ÚPi._as_mpf_valå  s   € Ü�d‹|Ðre   c                ó¸   • [        U[        5      (       a  [        S5      [        S5      4$ [        U[        5      (       a  [        SSS5      [        SSS5      4$ g )Nr…  r†  éß   éG   r   é   é   rí  rÍ  s     r?   rï  ÚPi.approximation_intervalè  sQ   € Ü�j¤'×*Ñ*Ü˜A“J¤¨£
Ð+Ð+Ü˜
¤H×-Ñ-Ü˜S " aÓ(¬(°2°q¸!Ó*<Ð=Ð=ð .re   N)r®   rs  rt  ru  rv  rH  r#  rS  rG  r;   rë  r¶  ry  r/  r	  r  r  rÙ   rï  r|  r€   re   r?   rü  rü  ­  s[   † ñ!ðF €GØ€KØ€KØ€MØ€IØ€LØÐà€Iòð ñó ðòòõ>re   rü  c                  óZ   • \ 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\rSrg)ÚGoldenRatioiñ  a3  The golden ratio, `\phi`.

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

`\phi = \frac{1 + \sqrt{5}}{2}` is an algebraic number.  Two quantities
are in the golden ratio if their ratio is the same as the ratio of
their sum to the larger of the two quantities, i.e. their maximum.

GoldenRatio is a singleton, and can be accessed by ``S.GoldenRatio``.

Examples
========

>>> from sympy import S
>>> S.GoldenRatio > 1
True
>>> S.GoldenRatio.expand(func=True)
1/2 + sqrt(5)/2
>>> S.GoldenRatio.is_irrational
True

References
==========

.. [1] https://en.wikipedia.org/wiki/Golden_ratio
TFr€   c                ó   • g)Nz\phir€   r-  s     r?   r/  ÚGoldenRatio._latex  s   € Øre   c                ó   • gr"  r€   r¹   s    r?   r  ÚGoldenRatio.__int__  ré  re   c                óf   • [         R                  " [        US-   5      U* S-
  5      n[        X!5      $ ©NrJ   )rç   Úfrom_man_expr)   rq   r½  s      r?   rÙ   ÚGoldenRatio._as_mpf_val  s.   € ä×Òœy¨°©Ó3°d°U¸R±ZÓ@ˆÜ˜Ó!Ð!re   c                ób   • SSK Jn  [        R                  [        R                  U" S5      -  -   $ )Nr   )ÚsqrtrK   )Ú(sympy.functions.elementary.miscellaneousr.  r   rf  )rº   Úhintsr.  s      r?   Ú_eval_expand_funcÚGoldenRatio._eval_expand_func#  s    € ÝAÜ�v‰vœŸ™™t A›w™Ñ&Ð&re   c                ó�   • [        U[        5      (       a  [        R                  [	        S5      4$ [        U[        5      (       a  g g r,  ©rî  r‡   r   r  r‹   rÍ  s     r?   rï  Ú"GoldenRatio.approximation_interval'  ó7   € Ü�j¤'×*Ñ*Ü—E‘Eœ8 A›;Ð'Ð'Ü˜
¤H×-Ñ-Øð .re   N)r®   rs  rt  ru  rv  rH  r#  rS  rG  r;   rë  r¶  ry  r/  r  rÙ   r1  rï  Ú_eval_rewrite_as_sqrtr|  r€   re   r?   r$  r$  ñ  sS   † ñð8 €GØ€KØ€KØ€MØ€IØ€LØÐà€Iòòò"ò
'òð .Óre   r$  c                  ó`   • \ 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\rSrg)ÚTribonacciConstanti0  a¶  The tribonacci constant.

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

The tribonacci numbers are like the Fibonacci numbers, but instead
of starting with two predetermined terms, the sequence starts with
three predetermined terms and each term afterwards is the sum of the
preceding three terms.

The tribonacci constant is the ratio toward which adjacent tribonacci
numbers tend. It is a root of the polynomial `x^3 - x^2 - x - 1 = 0`,
and also satisfies the equation `x + x^{-3} = 2`.

TribonacciConstant is a singleton, and can be accessed
by ``S.TribonacciConstant``.

Examples
========

>>> from sympy import S
>>> S.TribonacciConstant > 1
True
>>> S.TribonacciConstant.expand(func=True)
1/3 + (19 - 3*sqrt(33))**(1/3)/3 + (3*sqrt(33) + 19)**(1/3)/3
>>> S.TribonacciConstant.is_irrational
True
>>> S.TribonacciConstant.n(20)
1.8392867552141611326

References
==========

.. [1] https://en.wikipedia.org/wiki/Generalizations_of_Fibonacci_numbers#Tribonacci_numbers
TFr€   c                ó   • g)Nz\text{TribonacciConstant}r€   r-  s     r?   r/  ÚTribonacciConstant._latex_  s   € Ø+re   c                ó   • gr"  r€   r¹   s    r?   r  ÚTribonacciConstant.__int__b  ré  re   c                ó8   • U R                  U5      R                  $ r:   )rÞ   rw   rØ   s     r?   rÙ   ÚTribonacciConstant._as_mpf_vale  s   € Ø×Ñ Ó%×+Ñ+Ð+re   c                óV   • U R                  SS9R                  US-   5      n[        X!S9$ )NT)Úfunctionr†  rù  )r1  rÞ   rQ   r½  s      r?   rÞ   ÚTribonacciConstant._eval_evalfh  s/   € Ø×#Ñ#¨TÐ#Ð2×>Ñ>¸tÀa¹xÓHˆÜ�RÑ(Ð(re   c                óp   • SSK JnJn  SU" SSU" S5      -  -
  5      -   U" SSU" S5      -  -   5      -   S-  $ )Nr   )Úcbrtr.  r   é   r…  é!   )r/  rD  r.  )rº   r0  rD  r.  s       r?   r1  Ú$TribonacciConstant._eval_expand_funcl  s<   € ßGØ‘D˜˜a¡ R£™j™Ó)Ñ)©D°°a¹¸R»±j±Ó,AÑAÀQÑFÐFre   c                ó�   • [        U[        5      (       a  [        R                  [	        S5      4$ [        U[        5      (       a  g g r,  r4  rÍ  s     r?   rï  Ú)TribonacciConstant.approximation_intervalp  r6  re   N)r®   rs  rt  ru  rv  rH  r#  rS  rG  r;   rë  r¶  ry  r/  r  rÙ   rÞ   r1  rï  r7  r|  r€   re   r?   r9  r9  0  sZ   † ñ"ðH €GØ€KØ€KØ€MØ€IØ€LØÐà€Iò,òò,ò)òGòð .Óre   r9  c                  óH   • \ 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g)Ú
EulerGammaiy  a§  The Euler-Mascheroni constant.

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

`\gamma = 0.5772157\ldots` (also called Euler's constant) is a mathematical
constant recurring in analysis and number theory.  It is defined as the
limiting difference between the harmonic series and the
natural logarithm:

.. math:: \gamma = \lim\limits_{n\to\infty}
          \left(\sum\limits_{k=1}^n\frac{1}{k} - \ln n\right)

EulerGamma is a singleton, and can be accessed by ``S.EulerGamma``.

Examples
========

>>> from sympy import S
>>> S.EulerGamma.is_irrational
>>> S.EulerGamma > 0
True
>>> S.EulerGamma > 1
False

References
==========

.. [1] https://en.wikipedia.org/wiki/Euler%E2%80%93Mascheroni_constant
TFNr€   c                ó   • g)Nz\gammar€   r-  s     r?   r/  ÚEulerGamma._latex¡  r1  re   c                ó   • grõ  r€   r¹   s    r?   r  ÚEulerGamma.__int__¤  ré  re   c                ó�   • [         R                  R                  US-   5      n[         R                  " X!* S-
  5      n[	        X15      $ r*  )rç   ÚlibhyperÚeuler_fixedr+  rq   ©rº   rk   rA  rp   s       r?   rÙ   ÚEulerGamma._as_mpf_val§  s;   € ä�M‰M×%Ñ% d¨R¡iÓ0ˆÜ×Ò˜q %¨"¡*Ó-ˆÜ˜Ó!Ð!re   c                óÒ   • [        U[        5      (       a   [        R                  [        R                  4$ [        U[
        5      (       a  [        R                  [        SSS5      4$ g )Nr…  rK   r   )rî  r‡   r   r'  r  r‹   rf  rÍ  s     r?   rï  Ú!EulerGamma.approximation_interval­  sK   € Ü�j¤'×*Ñ*Ü—F‘FœAŸE™E�?Ð"Ü˜
¤H×-Ñ-Ü—F‘FœH Q¨¨1Ó-Ð.Ð.ð .re   )r®   rs  rt  ru  rv  rH  r#  rS  rG  r;   ry  r/  r  rÙ   rï  r|  r€   re   r?   rK  rK  y  s;   † ñð> €GØ€KØ€KØ€MØ€Ià€Iòòò"õ/re   rK  c                  óR   • \ 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S
 jrS rSrg)ÚCatalani´  a¨  Catalan's constant.

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

$G = 0.91596559\ldots$ is given by the infinite series

.. math:: G = \sum_{k=0}^{\infty} \frac{(-1)^k}{(2k+1)^2}

Catalan is a singleton, and can be accessed by ``S.Catalan``.

Examples
========

>>> from sympy import S
>>> S.Catalan.is_irrational
>>> S.Catalan > 0
True
>>> S.Catalan > 1
False

References
==========

.. [1] https://en.wikipedia.org/wiki/Catalan%27s_constant
TFNr€   c                ó   • grõ  r€   r¹   s    r?   r  ÚCatalan.__int__Ø  ré  re   c                ó~   • [         R                  " US-   5      n[         R                  " X!* S-
  5      n[        X15      $ r*  )rç   Úcatalan_fixedr+  rq   rS  s       r?   rÙ   ÚCatalan._as_mpf_valÛ  s7   € ä×Ò˜t b™yÓ)ˆÜ×Ò˜q %¨"¡*Ó-ˆÜ˜Ó!Ð!re   c                óÒ   • [        U[        5      (       a   [        R                  [        R                  4$ [        U[
        5      (       a  [        SSS5      [        R                  4$ g )Né	   rJ   r   )rî  r‡   r   r'  r  r‹   rÍ  s     r?   rï  ÚCatalan.approximation_intervalá  sK   € Ü�j¤'×*Ñ*Ü—F‘FœAŸE™E�?Ð"Ü˜
¤H×-Ñ-Ü˜Q  AÓ&¬¯©Ð.Ð.ð .re   c                ó¨   • Uc  Ub  U $ SSK Jn  SSKJn  U" SSSS9nU" [        R
                  U-  SU-  S-   S-  -  US[        R                  45      $ )	Nr   r±  r   )ÚSumr@  T)ÚintegerÚnonnegativer5   )rœ  r²  Úsympy.concrete.summationsrb  r   rT  r«   )rº   Úk_symr  r0  r²  rb  r@  s          r?   Ú_eval_rewrite_as_SumÚCatalan._eval_rewrite_as_Sumç  sX   € ØÑ 7Ñ#6ØˆKÝ!Ý1Ù�#˜t°Ñ6ˆÙ”1—=‘= !Ñ# q¨¡s¨1¡u¨q¡jÑ0°1°a¼¿¹Ð2DÓEÐEre   c                ó   • g)NÚGr€   r-  s     r?   r/  ÚCatalan._latexï  s   € Øre   rC  )r®   rs  rt  ru  rv  rH  r#  rS  rG  r;   ry  r  rÙ   rï  rg  r/  r|  r€   re   r?   rX  rX  ´  sA   † ñð6 €GØ€KØ€KØ€MØ€Ià€Iòò"ò/ôFõre   rX  c                  óv   • \ rS rSrSrSrSrSrSrSr	Sr
\rSrS r\S 5       rS rS	 rS
 rS r\S 5       rSrg)r
  ió  a  The imaginary unit, `i = \sqrt{-1}`.

I is a singleton, and can be accessed by ``S.I``, or can be
imported as ``I``.

Examples
========

>>> from sympy import I, sqrt
>>> sqrt(-1)
I
>>> I*I
-1
>>> 1/I
-I

References
==========

.. [1] https://en.wikipedia.org/wiki/Imaginary_unit
TFr€   c                ó    • UR                   S   $ )NÚimaginary_unit_latex)Ú	_settingsr-  s     r?   r/  ÚImaginaryUnit._latex  s   € Ø× Ñ Ð!7Ñ8Ð8re   c                 ó"   • [         R                  $ r:   r^  r€   re   r?   r  ÚImaginaryUnit.__abs__  r  re   c                ó   • U $ r:   r€   rØ   s     r?   rÞ   ÚImaginaryUnit._eval_evalf  rþ   re   c                ó$   • [         R                  * $ r:   )r   r
  r¹   s    r?   rü   ÚImaginaryUnit._eval_conjugate  s   € Ü—‘ÐÐre   c                ó¬  • [        U[        5      (       a^  US-  nUS:X  a  [        R                  $ US:X  a  [        R                  $ US:X  a  [        R
                  $ US:X  a  [        R                  * $ [        U[        5      (       aL  [        US5      u  p#[        [        R                  USS9nUS-  (       a  [        [        R
                  USS9$ U$ g)	zÓ
b is I = sqrt(-1)
e is symbolic object but not equal to 0, 1

I**r -> (-1)**(r/2) -> exp(r/2*Pi*I) -> sin(Pi*r/2) + cos(Pi*r/2)*I, r is decimal
I**0 mod 4 -> 1
I**1 mod 4 -> I
I**2 mod 4 -> -1
I**3 mod 4 -> -I
r†  r   r   r5   r…  Fr  N)
rL   r‡   r   r  r
  rT  r‹   rÊ   r  rý  )rº   rn   r>   rÍ   rp   s        r?   r  ÚImaginaryUnit._eval_power"  s°   € ô �dœG×$Ñ$Ø˜!‘8ˆDØ�q‹yÜ—u‘u�Ø˜“Ü—‘Ð&Ø˜“Ü—}‘}Ð$Ø˜“ÜŸ™Ð'Ð'Ü�dœH×%Ñ%Ü˜$ “?‰DˆAÜ”Q—_‘_ a°%Ñ8ˆBØ�1�uÜœ1Ÿ=™=¨"°uÑ=Ð=ØˆIð &re   c                óB   • [         R                  [         R                  4$ r:   )r   rT  rf  r¹   s    r?   Úas_base_expÚImaginaryUnit.as_base_exp?  s   € Ü�}‰}œaŸf™fÐ$Ð$re   c                óV   • [        S5      R                  [        S5      R                  4$ )Nr   r   )rQ   rw   r¹   s    r?   Ú_mpc_ÚImaginaryUnit._mpc_B  s   € ä�a“—‘¤ a£§¡Ð/Ð/re   N)r®   rs  rt  ru  rv  rw  Úis_imaginaryrƒ   r;   rë  r¶  r   rz  ry  r/  r	  r  rÞ   rü   r  rz  rN  r}  r|  r€   re   r?   r
  r
  ó  ss   † ñð, €NØ€LØ€IØ€IØ€LØÐà€Dà€Iò9ð ñó ðòò òò:%ð ñ0ó ó0re   r
  c                óú   • [        U [        [        45      (       a  g[        U 5      [        L a  U R                  5       $ [        U [        5      (       a  g[        U [        5      (       a  U R                  S   S:¬  $ g)z�return True only for a literal Number whose internal
representation as a fraction has a denominator of 1,
else False, i.e. integer, with no fractional part.
Tr5   r   F)	rL   r   rW   r­   r¦   rà  r‡   rQ   rw   ©r2  s    r?   rÊ  rÊ  J  sc   € ô
 �!”j¤#Ð&×'Ñ'ØÜˆAƒw”%ÒØ�|‰|‹~ÐÜ�!”W×ÑØÜ�!”U×Ñà�w‰w�q‰z˜Q‰ÐØre   c                óŒ  • [        U 5      n [        U5      nU R                  (       d  UR                  (       d  X:H  $ U R                  (       a*  UR                  (       a  U R                  UR                  :H  $ U R                  (       a  XpU R                  (       d  gUR                  u  p#pEU R                  U R
                  pvU(       a  U* nUS:X  a  US:H  =(       a    X6:H  $ US:”  a4  US:w  a  gUR                  5       UR                  5       U-   :w  a  gX4-  U:H  $ Xc:w  a  gU* nUR                  5       S-
  U:w  a  gSU-  U:H  $ )a*  Compare expressions treating plain floats as rationals.

Examples
========

>>> from sympy import S, symbols, Rational, Float
>>> from sympy.core.numbers import equal_valued
>>> equal_valued(1, 2)
False
>>> equal_valued(1, 1)
True

In SymPy expressions with Floats compare unequal to corresponding
expressions with rationals:

>>> x = symbols('x')
>>> x**2 == x**2.0
False

However an individual Float compares equal to a Rational:

>>> Rational(1, 2) == Float(0.5)
False

In a future version of SymPy this might change so that Rational and Float
compare unequal. This function provides the behavior currently expected of
``==`` so that it could still be used if the behavior of ``==`` were to
change in future.

>>> equal_valued(1, 1.0) # Float vs Rational
True
>>> equal_valued(S(1).n(3), S(1).n(5)) # Floats of different precision
True

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

In future SymPy versions Float and Rational might compare unequal and floats
with different precisions might compare unequal. In that context a function
is needed that can check if a number is equal to 1 or 0 etc. The idea is
that instead of testing ``if x == 1:`` if we want to accept floats like
``1.0`` as well then the test can be written as ``if equal_valued(x, 1):``
or ``if equal_valued(x, 2):``. Since this function is intended to be used
in situations where one or both operands are expected to be concrete
numbers like 1 or 0 the function does not recurse through the args of any
compound expression to compare any nested floats.

References
==========

.. [1] https://github.com/sympy/sympy/pull/20033
Fr   r   )r   r$  rw   rR  rz   r|   Ú
bit_length)	r2  r  rl   rm   r¨  r`   rz   r|   Úneg_exps	            r?   r  r  [  s  € ôj 	�‹€AÜ�‹€Að �:�:˜aŸjŸjØ‰vˆØ	
��˜Ÿ
Ÿ
à�w‰w˜!Ÿ'™'Ñ!Ð!Ø	
��Øˆ1Ø�=�=Øð Ÿ™Ñ€DˆsØ�3‰3�—‘€qæØˆdˆà
ˆaƒxà�A‰v×"˜#™(Ð"Ø	ˆq‹à�‹6ØØ�<‰<‹>˜SŸ^™^Ó-°Ñ3Ó3ØØ‰z˜Q‰Ðð ‹8ØØ�$ˆØ�<‰<‹>˜AÑ Ó(ØØ�W‘ Ñ"Ð"re   c                óv   ^^^^^^^• [         [        4mUU4S jmUUUU4S jmUU4S jmUUU4S jmT" X5      $ )ay  Return True if expr1 and expr2 are numerically close.

The expressions must have the same structure, but any Rational, Integer, or
Float numbers they contain are compared approximately using rtol and atol.
Any other parts of expressions are compared exactly. However, allowance is
made to allow for the additive and multiplicative identities.

Relative tolerance is measured with respect to expr2 so when used in
testing expr2 should be the expected correct answer.

Examples
========

>>> from sympy import exp
>>> from sympy.abc import x, y
>>> from sympy.core.numbers import all_close
>>> expr1 = 0.1*exp(x - y)
>>> expr2 = exp(x - y)/10
>>> expr1
0.1*exp(x - y)
>>> expr2
exp(x - y)/10
>>> expr1 == expr2
False
>>> all_close(expr1, expr2)
True

Identities are automatically supplied:

>>> all_close(x, x + 1e-10)
True
>>> all_close(x, 1.0*x)
True
>>> all_close(x, 1.0*x + 1e-10)
True

c                ó  >• [        U 5      [        U5      :X  aR  [        U [        [        45      (       a7  [	        U 5      [	        U5      :w  a  g[        U4S j[        X5       5       5      $ T" [        U 5      [        U5      5      $ )NFc              3  ó8   >#   • U  H  u  pT" X5      v •  M     g 7fr:   r€   )r=   Úe1Úe2Ú
_all_closes      €r?   r@   Ú0all_close.<locals>._all_close.<locals>.<genexpr>è  s   øé € ÐHº©f¨b‘z "×)Ð)ºùó   ƒ)r­   rL   r–  r—   r†   rO   rU   r   )Úobj1Úobj2rŠ  Ú_all_close_exprs     €€r?   rŠ  Úall_close.<locals>._all_closeä  s`   ø€ Ü�‹:œ˜d›Ó#¬
°4¼$Ä¸×(GÑ(GÜ�4‹yœC ›IÓ%ØÜÔH¼¸D¼ÓHÓHÐHá"¤8¨D£>´8¸D³>ÓBÐBre   c                óî  >• [        U T5      n[        UT5      nX#:w  a  gU(       a  T" X5      $ U R                  (       d3  U R                  (       d"  UR                  (       d  UR                  (       a  T" X5      $ U R                  UR                  :w  d,  [	        U R
                  5      [	        UR
                  5      :w  a  g[        U R
                  UR
                  5      n[        U4S jU 5       5      $ )NFc              3  ó8   >#   • U  H  u  pT" X5      v •  M     g 7fr:   r€   )r=   Úa1Úa2r�  s      €r?   r@   Ú5all_close.<locals>._all_close_expr.<locals>.<genexpr>ø  s   øé € Ð>º©v¨r‘? 2×*Ð*ºùrŒ  )rL   rù  Úis_MulrÏ  r†   rÂ   rU   rO   )	Úexpr1Úexpr2Únum1Únum2rÂ   Ú	NUM_TYPESÚ_all_close_acr�  Ú
_close_nums	        €€€€r?   r�  Ú"all_close.<locals>._all_close_exprì  s¤   ø€ Ü˜% Ó+ˆÜ˜% Ó+ˆØ‹<ØÞÙ˜eÓ+Ð+Ø�<�<˜5Ÿ<Ÿ<¨5¯<¯<¸5¿<¿<Ù  Ó.Ð.Ø�:‰:˜Ÿ™Ó#¤s¨5¯:©:£¼#¸e¿j¹j»/Ó'IØÜ�5—:‘:˜uŸz™zÓ*ˆÜÔ>¹Ó>Ó>Ð>re   c                óT   >• [        [        X-
  5      TT[        U5      -  -   :*  5      $ r:   )r·   rX   )r™  rš  ÚatolÚrtols     €€r?   r�  Úall_close.<locals>._close_numú  s'   ø€ Ü”C˜™Ó$¨¨t´C¸³I©~Ñ(=Ñ=Ó>Ð>re   c                ó’  >• U R                   (       d  UR                   (       Ga  U R                  SS9u  p#UR                  SS9u  pET" X$5      (       d  g[        U5      n[        U5      nXg-  nXh-  nXx-  nU(       d  g[        S Xg4 5       5      (       d  g[	        U5       V	s/ s H  o™R                  5       PM     nn	[	        U5       V	s/ s H  o™R                  5       PM     nn	[        [        [        U5      5      5      n
U H1  nU
 H(  n	Xy   nT" X¼5      (       d  M  U
R                  U	5          M/       g   U
(       + $ U R                  (       d  UR                  (       d   eU R                  5       nUR                  5       nT" US   US   5      (       d  g[        U5      [        U5      :w  a  g[        U5       H8  nXþ;   d  M
  T" UR                  U5      UR                  U5      5      (       a  M8    g   U(       d  gU H4  nU H+  nT" UU5      (       d  M  T" UU   UU   5      (       d      g  M2       g   gs  sn	f s  sn	f )NFrN  Tc              3  ó\   #   • U  H"  o  H  o"R                  [        5      v •  M     M$     g 7fr:   )ÚhasrQ   )r=   rI   r>   s      r?   r@   Ú3all_close.<locals>._all_close_ac.<locals>.<genexpr>  s    é € ÐAªX¨»q¸!—u‘uœU—|�|¹q‘|ªXùs   ‚*,r   )r–  rW  rì  Úanyr   rz  r–  rR   r†   Úremoverù  Úas_coefficients_dictÚpop)r—  r˜  Úc1rˆ  Úc2r‰  Ús1Ús2Úcommonr>   Ú	unmatchedÚbe1Úbe2Úcd1Úcd2r@  Úk1Úk2rŠ  r�  r�  s                     €€€r?   rœ  Ú all_close.<locals>._all_close_acý  s	  ø€ ð �<�<˜5Ÿ<Ÿ<˜<à×'Ñ'°Ð'Ð7‰FˆBØ×'Ñ'°Ð'Ð7‰FˆBÙ˜b×%Ñ%ØÜ�R“ˆBÜ�R“ˆBØ‘WˆFØ‰LˆBØ‰LˆBÞØÜÑA¨b©XÓA×AÑAØô ,3°2¬;Ó7ª; a—-‘-–/©;ˆBÐ7Ü+2°2¬;Ó7ª; a—-‘-–/©;ˆBÐ7ÜœU¤3 r£7›^Ó,ˆIÛ�Û"�AØ™%�CÙ! #×+Ó+Ø!×(Ñ(¨Ô+Úñ	 #ñ !ñ ð !”>Ð!Ø�|�|˜uŸ|Ÿ|Ð+Ð+Ø×(Ñ(Ó*ˆØ×(Ñ(Ó*ˆñ ˜#˜a™& # a¡&×)Ñ)ØÜˆs‹8”s˜3“xÓØÜ�c–ˆAØ�xÙ! #§'¡'¨!£*¨c¯g©g°a«j×9Ó9Ù ñ ö ØÛˆBÛ�Ù" 2 r×*Ó*ñ & c¨"¡g¨s°2©w×7Ñ7Ú$Úñ ñ ñ ð ùò[ 8ùÚ7s   Â%H?ÃI)r‹   rQ   )	r—  r˜  r¡  r   r›  rŠ  rœ  r�  r�  s	     ``@@@@@r?   Ú	all_closer¸  ¼  s9   þ€ ôL œ5Ð!€IöC÷?ð ?ö?÷BñH �eÓ#Ð#re   c                ó   • gr¨  r€   rÑ   s     r?   r¸  r¸  D  r¹  re   c                óX   • [         R                  U R                  U R                  S5      $ r"  )r‹   rÝ   r[  r\  )rœ   s    r?   Úsympify_fractionsr»  I  s   € Ü�=‰=˜Ÿ™ a§m¡m°QÓ7Ð7re   c                ó*   • [        [        U 5      5      $ r:   ©r‡   rW   r�  s    r?   Úsympify_mpzr¾  Q  ó   € Ü”s˜1“v‹Ðre   c                óf   • [        [        U R                  5      [        U R                  5      5      $ r:   ©r‹   rW   r[  r\  r�  s    r?   Úsympify_mpqrÂ  T  ó!   € Üœ˜AŸK™KÓ(¬#¨a¯m©mÓ*<Ó=Ð=re   c                ó*   • [        [        U 5      5      $ r:   r½  r�  s    r?   Úsympify_fmpzrÅ  ]  r¿  re   c                óf   • [        [        U R                  5      [        U R                  5      5      $ r:   rÁ  r�  s    r?   Úsympify_fmpqrÇ  `  rÃ  re   c                óV   • [         R                  " X R                  R                  5      $ r:   )r   Ú_from_mpmathr‘  rk   r�  s    r?   Úsympify_mpmathrÊ  g  s   € Ü×Ò˜Q§	¡	§¡Ó/Ð/re   c                ó�   • [        [        [        U R                  U R                  45      5      u  pU[
        R                  U-  -   $ r:   )r–  Úmapr	   ÚrealÚimagr   r
  )r\   rÍ  rÎ  s      r?   Úsympify_complexrÏ  m  s6   € Ü”cœ' A§F¡F¨A¯F©FÐ#3Ó4Ó5�J€DØ”!—/‘/ $Ñ&Ñ&Ð&re   )r  )rý  )r  c                 ó  • [         R                  R                  [        5        [         R                  R                  [        5        [         R
                  R                  [
        5        [         R                  R                  [        5        g r:   )rV  r    ÚregisterÚRealrQ   r‹   rW  r‡   r€   re   r?   Ú_register_classesrÓ  z  sN   € Ü‡N�N×ÑœFÔ#Ü‡L�L×Ñœ%Ô Ü×Ñ×ÑœhÔ'Ü×Ñ×ÑœgÕ&re   r:   rr  )gñhãˆµøä>g:Œ0âŽyE>)œÚ
__future__r   Útypingr   rV  r§   rY  r�  Ú
containersr   r	   r   r   r
   r   r   Ú	singletonr   r   Úbasicr   r�  r   r   r&  r   Úcacher   r   Ú
decoratorsr   Úintfuncr   r   r   r   r   Úlogicr   rz  r   Úsortingr   Úsympy.external.gmpyr   r   r    Úsympy.multipledispatchr!   ry   Úmpmath.libmpÚlibmprç   r"   r#   ri   rg   r%   r&   r'   r(   r)   Úmpmath.ctx_mp_pythonr*   Úmpmath.libmp.libmpfr+   r£  r,   r¤  r-   r¢  r.   r/   rh   r0   r1   Úsympy.utilities.miscr2   Úsympy.utilities.exceptionsr3   Ú
parametersr4   r÷  Ú_LOG2rH   rq   rt   ru   r}   r�   rM   rJ  rK  rL  r™   rž   r    rQ   r¦   r¨   Ú
RealNumberr‹   r‡   rW   r~  rî  rô  r'  r  rT  rf  r«   rø  r¬   rª   r¢   r¸  r  Úzoor™  râ  ÚErü  rû  r$  r9  rK  rX  r
  rú  rÊ  r  r¸  r»  rZ  r¾  rÂ  r­   ÚmpzÚmpqrÅ  rÇ  ÚfmpzÚfmpqrÊ  rÏ  ÚcomplexÚpowerr  Úmulrý  Úidentityr  r  rÓ  Ú_illegalr€   re   r?   Ú<module>rô     s  ðÝ "å ã Û Û Û å ÷,÷ ,ç #Ý ß "Ý ß 'Ý "ß IÕ IÝ Ý Ý ß 7Ñ 7Ý +Û Ý ß 7Ý $ß :Ó :Ý *÷÷ ñ õ 'Ý @Ý )à�Š�‹€ôjòZð< �eÐ€ô	$òòð ‡}�}�T—]‘] <Ó0Ó1€ò3ôtv&ˆZô v&ôr	_	?ˆFô _	?ðF ?DÐ CÐ �Ñ Ð*¨7¯?©?Ñ;ð €
ôlˆvô lô^G ˆhô G ðT  Ð �Ñ ôE�dô EôP
'�xô 
'ô'�gô 'ôAˆ? iò AôH0ˆ/ Yò 0ôf=�/¨Yò =ô@Ð yò ô@yˆv ò yðv ‡Z�Z€ôd1�v¨ò d1ôNqˆ&˜Iò qðf ‡e�e€á	ˆ#ˆtÓñó ðôJ"�j¨Iò J"ðZ ×Ñ€ô6"�:ô 6"ôrV*ˆ< 9ò V*ðp ‡F�F€ô?>ˆ ò ?>ðB ‡T�T€ô<.�,¨)ò <.ô~F.˜°ò F.ôR8/�¨ò 8/ôv<ˆl iò <ô~Q0�J¨)ò Q0ðh ‡O‚O€òò"^#ôBE$ñP 
ˆ%�Óñó ðò8ð (9Ð �×#Ò#Ñ $ð Ñòò>ð +6Ð‘T˜$Ÿ(›( 1›+Ó&Ñ'Ø-8Ð‘T˜$Ÿ(›( 1 a›.Ó)Ñ*ð 	Ñòò>ð -9Ð‘T˜%Ÿ*›* Q›-Ó(Ñ)Ø/;Ð‘T˜%Ÿ*›* Q¨Ó*Ó+Ñ,ò0ð -Ð �Ñ ò'ð ,Ð �Ñ å Ý Ù‹u€„Ý Ù‹v€„ò'ñ Ô à�E‰E�1—:‘:˜q×1Ñ1°1×3DÑ3DÐE�re   