ó
    Š*£h¥�  ã                   óf  • S r SSKrSSKJrJrJr  SSKJr  SSKJ	r	  SSK
JrJrJrJr  SSKJrJr  SSK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  SSKJ r J!r!J"r"  SSK#J$r$  SSK%J&r&J'r'  SSK(J)r)J*r*  SSK+J,r,  S r-S r.S r/SS jr0S r1S r2S\Rf                  S4S jr4S r5S S jr6S r7/ 4S jr8g)!z<Tools for solving inequalities and systems of inequalities. é    N)Úcontinuous_domainÚperiodicityÚfunction_range)Úsympify)Úfactor_terms)Ú
RelationalÚLtÚGeÚEq)ÚSymbolÚDummy)ÚIntervalÚ	FiniteSetÚUnionÚIntersection)ÚS)Ú
expand_mul)ÚAbs)ÚAnd)ÚPolyÚPolynomialErrorÚparallel_poly_from_expr)Ú_nsort)ÚsolvifyÚsolveset)ÚsiftÚiterable)Ú
filldedentc           
      ó  • [        U [        5      (       d  [        S5      eU R                  5       R                  (       aq  [        U R                  5       SU5      nU[        R                  L a  [        R                  /$ U[        R                  L a  [        R                  /$ [        SU-  5      eU R                  SS9/ pCUS:X  a)  U H!  u  pV[        XU5      nUR                  U5        M#     U$ US:X  aQ  [        R                  nU[        R                   S4/-    H%  u  p–[        X‰S	S	5      nUR                  U5        U	nM'     U$ U R#                  5       S:”  a  Sn
OS
n
Su  p¼US:X  a  SnO-US:X  a  S
nO$US:X  a  Su  p¼OUS:X  a  Su  p¼O[        SU-  5      e[        R                   S	pÙ[%        U5       H›  u  pŽUS-  (       a3  X«:X  a"  UR'                  S[        X‰U(       + U5      5        U
* XŒ(       + pÙn
MB  X«:X  a)  U(       d"  UR'                  S[        X‰S	U5      5        US	pÙMp  X«:w  d  Mw  U(       d  M€  UR'                  S[        Xˆ5      5        M�     X«:X  a,  UR'                  S[        [        R                  U	S	U5      5        U$ )aÚ  Solve a polynomial inequality with rational coefficients.

Examples
========

>>> from sympy import solve_poly_inequality, Poly
>>> from sympy.abc import x

>>> solve_poly_inequality(Poly(x, x, domain='ZZ'), '==')
[{0}]

>>> solve_poly_inequality(Poly(x**2 - 1, x, domain='ZZ'), '!=')
[Interval.open(-oo, -1), Interval.open(-1, 1), Interval.open(1, oo)]

>>> solve_poly_inequality(Poly(x**2 - 1, x, domain='ZZ'), '==')
[{-1}, {1}]

See Also
========
solve_poly_inequalities
z8For efficiency reasons, `poly` should be a Poly instancer   ú%could not determine truth value of %sF)Úmultipleú==ú!=é   Téÿÿÿÿ)NFÚ>Ú<ú>=)r$   Tú<=)r%   Tz'%s' is not a valid relationé   )Ú
isinstancer   Ú
ValueErrorÚas_exprÚ	is_numberr   r   ÚtrueÚRealsÚfalseÚEmptySetÚNotImplementedErrorÚ
real_rootsr   ÚappendÚNegativeInfinityÚInfinityÚLCÚreversedÚinsert)ÚpolyÚrelÚtÚrealsÚ	intervalsÚrootÚ_ÚintervalÚleftÚrightÚsignÚeq_signÚequalÚ
right_openÚmultiplicitys                  ÚW/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/solvers/inequalities.pyÚsolve_poly_inequalityrK      sl  € ô, �dœD×!Ñ!ÜØFóHð 	Hà‡|�|ƒ~××Ü�t—|‘|“~ q¨#Ó.ˆØ”—‘Š;Ü—G‘G�9ÐØ”!—'‘'Š\Ü—J‘J�<Ðä%Ø7¸!Ñ;ó=ð =ð —‘°�Ð6¸ˆ9à
ˆdƒ{Û‰GˆDÜ Ó+ˆHØ×Ñ˜XÖ&ñ ðd Ðð_ 
�‹Ü×!Ñ!ˆà¤!§*¡*¨a Ð 1Ô1‰HˆEÜ ¨T°4Ó8ˆHØ×Ñ˜XÔ&ØŠDñ 2ðX ÐðO �7‰7‹9�q‹=Ø‰DàˆDà$‰ˆà�#‹:Ø‰GØ�C‹ZØ‰GØ�D‹[Ø%‰NˆG�UØ�D‹[Ø%‰NˆG�UäÐ;¸cÑAÓBÐBäŸJ™J¨ˆzä"*¨5¦/ÑˆDØ˜a×Ø“?Ø×$Ñ$Øœ8 D°U´¸JÓGôIð ,0¨%°´y˜Z�™Zà“?®5Ø×$Ñ$Øœ8 D°°zÓBôDà(,¨dš:Ø•_¯¨Ø×$Ñ$ Q¬°Ó(<Ö=ñ #2ð ‹?Ø×ÑØ”8œA×.Ñ.°°t¸ZÓHôJð Ðó    c           	      ób   • [        U  VVs/ s H  n[        U6   H  o"PM     M     snn6 $ s  snnf )au  Solve polynomial inequalities with rational coefficients.

Examples
========

>>> from sympy import Poly
>>> from sympy.solvers.inequalities import solve_poly_inequalities
>>> from sympy.abc import x
>>> solve_poly_inequalities(((
... Poly(x**2 - 3), ">"), (
... Poly(-x**2 + 1), ">")))
Union(Interval.open(-oo, -sqrt(3)), Interval.open(-1, 1), Interval.open(sqrt(3), oo))
)r   rK   )ÚpolysÚpÚss      rJ   Úsolve_poly_inequalitiesrQ   q   s0   € ô ™eÔGše˜Ô-BÀAÔ-F¨’1Ñ-F‘1™eÒGÐHÐHùÓGs   ‹+
c                 ój  • [         R                  nU  GH  nU(       d  M  [        [         R                  [         R                  5      /nU HÅ  u  u  pEn[        XE-  U5      n[        US5      n/ n	[        R                  " Xs5       H<  u  p«U
R                  U5      nU[         R                  Ld  M+  U	R                  U5        M>     U	n/ n	U H6  nU H  nX½-  nM	     U[         R                  Ld  M%  U	R                  U5        M8     U	nU(       a  MÅ    O   U H  nUR                  U5      nM     GM     U$ )aó  Solve a system of rational inequalities with rational coefficients.

Examples
========

>>> from sympy.abc import x
>>> from sympy import solve_rational_inequalities, Poly

>>> solve_rational_inequalities([[
... ((Poly(-x + 1), Poly(1, x)), '>='),
... ((Poly(-x + 1), Poly(1, x)), '<=')]])
{1}

>>> solve_rational_inequalities([[
... ((Poly(x), Poly(1, x)), '!='),
... ((Poly(-x + 1), Poly(1, x)), '>=')]])
Union(Interval.open(-oo, 0), Interval.Lopen(0, 1))

See Also
========
solve_poly_inequality
r"   )r   r2   r   r6   r7   rK   Ú	itertoolsÚproductÚ	intersectr5   Úunion)ÚeqsÚresultÚ_eqsÚglobal_intervalsÚnumerÚdenomr<   Únumer_intervalsÚdenom_intervalsr?   Únumer_intervalÚglobal_intervalrB   Údenom_intervals                 rJ   Úsolve_rational_inequalitiesrb   ‚   s%  € ô. �Z‰Z€FäˆÞÙä$¤Q×%7Ñ%7¼¿¹ÓDÐEÐã#'Ñ‰NˆU˜CÜ3°E±KÀÓEˆOÜ3°E¸4Ó@ˆOàˆIä3<×3DÒ3DØ#ö47Ñ/�à)×3Ñ3°OÓD�à¤1§:¡:Ô-Ø×$Ñ$ XÖ.ñ47ð  )ÐàˆIã#3�Û&5�NØ#Ñ5’Oñ '6ð #¬!¯*©*Ô4Ø×$Ñ$ _Ö5ñ $4ð  )Ðç#Ð#Ùñ7 $(ó: )ˆHØ—\‘\ (Ó+ŠFô )ñG ðL €MrL   Tc                 óv  • Sn/ n[         R                  nU  GH=  nU(       d  M  / n[         R                  nU GH   n	[        U	[        5      (       a  U	u  pšO8U	R
                  (       a%  U	R                  U	R                  -
  U	R                  p©OSn
U	[         R                  L a"  [         R                  [         R                  Sp¬nOUU	[         R                  L a"  [         R                  [         R                  Sp¬nO U	R                  5       R                  5       u  p¼ [        X¼4U5      u  u  p¼nUR$                  R&                  (       d!  UR)                  5       UR)                  5       Sp<nUR$                  R+                  5       nUR,                  (       d2  UR.                  (       d!  X¼-  n	[1        U	SU
5      n	U[3        X‘SS9-  nGMŒ  UR5                  X¼4U
45        GM£     U(       al  U[7        U/5      -  n[7        U VVVVs/ s H:  oÿ  H1  u  u  nnnUR9                  U5      (       d  M!  UUR:                  4S4PM3     M<     snnnn/5      nUU-  nXX-  nGM@     U(       d  U(       a  UR=                  5       nU(       a  UR?                  U5      nU$ ! [          a    [!        [#        S5      5      ef = fs  snnnnf )aè  Reduce a system of rational inequalities with rational coefficients.

Examples
========

>>> from sympy import Symbol
>>> from sympy.solvers.inequalities import reduce_rational_inequalities

>>> x = Symbol('x', real=True)

>>> reduce_rational_inequalities([[x**2 <= 0]], x)
Eq(x, 0)

>>> reduce_rational_inequalities([[x + 2 > 0]], x)
-2 < x
>>> reduce_rational_inequalities([[(x + 2, ">")]], x)
-2 < x
>>> reduce_rational_inequalities([[x + 2]], x)
Eq(x, -2)

This function find the non-infinite solution set so if the unknown symbol
is declared as extended real rather than real then the result may include
finiteness conditions:

>>> y = Symbol('y', extended_real=True)
>>> reduce_rational_inequalities([[y + 2 > 0]], y)
(-2 < y) & (y < oo)
Tr"   z„
                    only polynomials and rational functions are
                    supported in this context.
                    Fr   )Ú
relational) r   r2   r0   r+   ÚtupleÚis_RelationalÚlhsÚrhsÚrel_opr/   ÚZeroÚOner1   ÚtogetherÚas_numer_denomr   r   r   ÚdomainÚis_ExactÚto_exactÚ	get_exactÚis_ZZÚis_QQr   Úsolve_univariate_inequalityr5   rb   ÚhasÚoneÚevalfÚas_relational)ÚexprsÚgenrd   ÚexactrW   ÚsolutionÚ_exprsrY   Ú_solÚexprr<   r[   r\   Úoptrn   ÚiÚnÚdrA   Úexcludes                       rJ   Úreduce_rational_inequalitiesr…   Ä   sS  € ð: €EØ
€CÜ�z‰z€HÜˆÞÙØˆÜ�w‰wˆÜˆDÜ˜$¤×&Ñ&Ø ‘	��cà×%×%Ø $§¡¨4¯8©8Ñ 3°T·[±[™#à�Cà”q—v‘vŠ~Ü$%§F¡F¬A¯E©E°4˜c�˜cØœŸ™’Ü$%§E¡E¬1¯5©5°$˜c�˜cà#Ÿ}™}›×=Ñ=Ó?‘�ðÜ&=Ø�N Có')Ñ#‘� ð —:‘:×&×&Ø&+§n¡nÓ&6¸¿¹Ó8HÈ%˜e�à—Z‘Z×)Ñ)Ó+ˆFà—L—L F§L§LØ‘{�Ü! $¨¨3Ó/�ØÔ3°DÈ%ÑPÑP“à—‘˜e˜^¨SÐ1×2ñG öJ ØÔ/°°Ó7Ñ7ˆDÜ1Ùö4AÚ�A³¡¡& 1 a¨!°Q·U±U¸3·Zó 5G°a¸¿¹°ZÀÓ4FÙ01ñ 5GÙô4Að 3Bó CˆGà�G‰OˆDàÑ‹ña öd –XØ—>‘>Ó#ˆæØ×)Ñ)¨#Ó.ˆà€OøôA #ó Ü%¤jð 2ó 'ó ð ðüõ(4As   ÄJÇ?%J3È(J3ÊJ0c                 ó(  ^• UR                   SL a  [        [        S5      5      eU4S jmSSS.n/ nT" U 5       HK  u  pXR                  5       ;  a  [	        U SU5      n O[	        U * SX1   5      n UR                  U /U-   5        MM     [        XB5      $ )a]  Reduce an inequality with nested absolute values.

Examples
========

>>> from sympy import reduce_abs_inequality, Abs, Symbol
>>> x = Symbol('x', real=True)

>>> reduce_abs_inequality(Abs(x - 5) - 3, '<', x)
(2 < x) & (x < 8)

>>> reduce_abs_inequality(Abs(x + 2)*3 - 13, '<', x)
(-19/3 < x) & (x < 7/3)

See Also
========

reduce_abs_inequalities
Fzs
            Cannot solve inequalities with absolute values containing
            non-real variables.
            c                 ó  >^• / nU R                   (       d  U R                  (       aq  U R                  nU R                   HS  nT	" U5      nU(       d  UnM  [        R
                  " X5       V VVVs/ s H  u  u  pu  pgU" X5      XW-   4PM     nnnn nMU     U$ U R                  (       aU  U R                  mTR                  (       d  [        S5      eUR                  U4S jT	" U R                  5       5       5        U$ [        U [        5      (       ad  T	" U R                  S   5      nU HG  u  pUR                  X[        U S5      /-   45        UR                  U * U[!        U S5      /-   45        MI     U$ U / 4/nU$ s  snnnn f )Nz'Only Integer Powers are allowed on Abs.c              3   ó6   >#   • U  H  u  pUT-  U4v •  M     g 7f©N© )Ú.0r   Úcondsr‚   s      €rJ   Ú	<genexpr>ÚAreduce_abs_inequality.<locals>._bottom_up_scan.<locals>.<genexpr>L  s   øé € ÐXÒ=W©k¨d˜$ ™' 5Õ)Ò=Wùs   ƒr   )Úis_AddÚis_MulÚfuncÚargsrS   rT   Úis_PowÚexpÚ
is_Integerr,   ÚextendÚbaser+   r   r5   r
   r	   )
r   ry   ÚopÚargr}   rŒ   Ú_exprÚ_condsr‚   Ú_bottom_up_scans
           @€rJ   rœ   Ú.reduce_abs_inequality.<locals>._bottom_up_scan9  sY  ù€ Øˆà�;�;˜$Ÿ+Ÿ+Ø—‘ˆBà—y”y�Ù(¨Ó-�æØ"’Eô &×-Ò-¨eÔ<ö>Ú<ñ DbÁ=ÀDÑRaÐSX™b ›o¨u©~Ó>Ù<ð ó >‘Eñ !ð. ˆð �[�[Ø—‘ˆAØ—<—<Ü Ð!JÓKÐKà�L‰LÔX¹_ÈTÏYÉYÔ=WÓXÔXð ˆô ˜œc×"Ñ"Ù$ T§Y¡Y¨q¡\Ó2ˆFã%‘�Ø—‘˜t¬b°°q«k¨]Ñ%:Ð;Ô<Ø—‘˜t˜e U¬b°°q«k¨]Ñ%:Ð;Ö<ñ  &ð ˆð ˜B�Z�LˆEàˆùõ#>s   Á0E>r&   r(   ©r'   r)   r   )Úis_extended_realÚ	TypeErrorr   Úkeysr   r5   r…   )r   r<   rz   ÚmappingÚinequalitiesrŒ   rœ   s         @rJ   Úreduce_abs_inequalityr¤     s    ø€ ð( ×Ñ˜uÒ$Üœ
ð $ó ó ð 	õ
ð> ˜tÑ$€GØ€Lá& tÖ,‰ˆØ—l‘l“nÓ$Ü˜t Q¨Ó,‰Dä˜t˜e Q¨©Ó5ˆDà×Ñ˜T˜F U™NÖ+ñ -ô (¨Ó:Ð:rL   c                 ó\   • [        U  VVs/ s H  u  p#[        X#U5      PM     snn6 $ s  snnf )aÜ  Reduce a system of inequalities with nested absolute values.

Examples
========

>>> from sympy import reduce_abs_inequalities, Abs, Symbol
>>> x = Symbol('x', extended_real=True)

>>> reduce_abs_inequalities([(Abs(3*x - 5) - 7, '<'),
... (Abs(x + 25) - 13, '>')], x)
(-2/3 < x) & (x < 4) & (((-oo < x) & (x < -38)) | ((-12 < x) & (x < oo)))

>>> reduce_abs_inequalities([(Abs(x - 4) + Abs(3*x - 5) - 7, '<')], x)
(1/2 < x) & (x < 4)

See Also
========

reduce_abs_inequality
)r   r¤   )ry   rz   r   r<   s       rJ   Úreduce_abs_inequalitiesr¦   f  s:   € ô* Ùô!Ú‰IˆDô (¨°3Ö7Ùò!ð "ð "ùó !s   ‹(
Fc                 óÐ  ^ ^^)• SSK Jn  UR                  [        R                  5      SL a  [        [        S5      5      eU[        R                  La5  [        T TSUS9R                  U5      nU(       a  UR                  T5      nU$  TnUnTR                  SL a*  [        R                  nU(       d  U$ UR                  U5      $ TR                  c  [        SSS	9m T R                  UT05      m SnT [        R                  L a  UnGOŽT [        R                   L a  [        R                  nGOiT R"                  T R$                  -
  n	['        U	T5      n
U
[        R(                  :X  aY  [+        U	5      n	T R-                  U	S5      nU[        R                  L a  UnGODU[        R                   L a  [        R                  nGOU
Gb  [/        U	TU5      nT R0                  nUS;   aV  T R-                  UR2                  S5      (       a  UnO�T R-                  UR4                  S5      (       d  [        R                  nO[US;   aU  T R-                  UR4                  S5      (       a  UnO1T R-                  UR2                  S5      (       d  [        R                  nUR4                  UR2                  pþXþ-
  [        R6                  L a  [9        SU
SS5      R;                  U5      nUnUGc´  U	R=                  5       u  nn TUR>                  ;  a  [A        U	R>                  5      S:”  a  [B        e[E        U	TU5      nUc  [B        e [+        U	5      m)U)U U4S jn/ nU" T T5       H  nURK                  [E        UTU5      5        M!     U(       d  [M        T)TU5      nST R0                  ;   =(       a    T R0                  S:g  n [O        URP                  [S        UR4                  UR2                  5      -
  5      n[S        UU-   [U        U5      -   6 R                  [9        UR4                  UR2                  UR4                  U;  UR2                  U;  5      5      n[W        S U 5       5      (       a  [Y        USS9S   nO=[[        US 5      nUS   (       a  [
        e US   n[A        U5      S:”  a  []        U5      n[        R                  nT)R_                  [        R`                  5      =n[        R(                  :w  GaÕ  Sn[S        5       n [c        UTU5      n[e        U[8        5      (       dC  U H;  nUU;  d  M  U" U5      (       d  M  UR                  (       d  M-  U[S        U5      -  nM=     GOUR4                  UR2                  n!n [Y        U[S        U!5      -   5       HÇ  nU" U 5      n"U U!:w  a´  U" U5      n#[g        U U5      n$U$U;  aš  U$R                  (       a‰  U" U$5      (       a|  U"(       a  U#(       a  U[9        U U5      -  nO^U"(       a  U[8        Rh                  " U U5      -  nO<U#(       a  U[8        Rj                  " U U5      -  nOU[8        Rl                  " U U5      -  nUn MÉ     U H  n%U[S        U%5      -  nM      U[        R                  L a-  [C        [        ST RG                  TU5      < SU< S35      5      eUR;                  U5      n[        R                  /n&UR4                  n U U;   a8  U" U 5      (       a+  U Rn                  (       a  U&Rq                  [S        U 5      5        U H–  n'U'n!U" [g        U U!5      5      (       a  U&Rq                  [9        U U!SS5      5        U'U;   a  URs                  U'5        OCU'U;   a  URs                  U'5        U" U'5      n(OUn(U((       a  U&Rq                  [S        U'5      5        U!n M˜     UR2                  n!U!U;   a8  U" U!5      (       a+  U!Rn                  (       a  U&Rq                  [S        U!5      5        U" [g        U U!5      5      (       a&  U&Rq                  [8        Rl                  " U U!5      5        U[        R(                  :w  a  W(       a  UR;                  U5      nO#[u        [w        U&6 UU5      RG                  TU5      nU(       d  U$ UR                  U5      $ ! [         a    [        [        S
5      5      ef = f! [B        [
        4 a1    [        [        ST RG                  T[I        S5      5      -  5      5      ef = f! [         a    [
        ef = f! [
         a    [        S5      ef = f! [         a    [        R                  nSn GNëf = f)a´  Solves a real univariate inequality.

Parameters
==========

expr : Relational
    The target inequality
gen : Symbol
    The variable for which the inequality is solved
relational : bool
    A Relational type output is expected or not
domain : Set
    The domain over which the equation is solved
continuous: bool
    True if expr is known to be continuous over the given domain
    (and so continuous_domain() does not need to be called on it)

Raises
======

NotImplementedError
    The solution of the inequality cannot be determined due to limitation
    in :func:`sympy.solvers.solveset.solvify`.

Notes
=====

Currently, we cannot solve all the inequalities due to limitations in
:func:`sympy.solvers.solveset.solvify`. Also, the solution returned for trigonometric inequalities
are restricted in its periodic interval.

See Also
========

sympy.solvers.solveset.solvify: solver returning solveset solutions with solve's output API

Examples
========

>>> from sympy import solve_univariate_inequality, Symbol, sin, Interval, S
>>> x = Symbol('x')

>>> solve_univariate_inequality(x**2 >= 4, x)
((2 <= x) & (x < oo)) | ((-oo < x) & (x <= -2))

>>> solve_univariate_inequality(x**2 >= 4, x, relational=False)
Union(Interval(-oo, -2), Interval(2, oo))

>>> domain = Interval(0, S.Infinity)
>>> solve_univariate_inequality(x**2 >= 4, x, False, domain)
Interval(2, oo)

>>> solve_univariate_inequality(sin(x) > 0, x, relational=False)
Interval.open(0, pi)

r   ©ÚdenomsFz|
        Inequalities in the complex domain are
        not supported. Try the real domain by
        setting domain=S.Reals)rd   Ú
continuousNrz   T©Úextended_realz–
                When gen is real, the relational has a complex part
                which leads to an invalid comparison like I < 0.
                rž   )r&   r(   r$   z…
                    The inequality, %s, cannot be solved using
                    solve_univariate_inequality.
                    Úxc                 ó®  >• TR                  T[        U 5      5      n TR                  US5      nU[        R                  [        R
                  4;   a  U$ UR                  SL a  [        R
                  $ UR                  S5      nUR                  (       a  TR                  US5      $ [        SU-  5      e! [         a    [        R
                  n N£f = f)Nr   Fr*   z!relationship did not evaluate: %s)Úsubsr   r‘   r    r   r1   r/   rŸ   r‚   Úis_comparabler3   )r­   ÚvÚrÚ
expanded_er   rz   s      €€€rJ   ÚvalidÚ*solve_univariate_inequality.<locals>.valid  sµ   ø€ ð —O‘O C¬°A«Ó7�ð ØŸ	™	 ! Q›�Að œŸ™¤§¡Ð)Ó)Ø�HØ×%Ñ%¨Ò.ÜŸ7™7�NàŸ™˜A›�AØ——Ø#Ÿy™y¨¨A›Ð.ä-Ø;¸aÑ?óAð Aøô !ó  ÜŸ™’Að ús   žB7 Â7CÃCÚ=r#   c              3   ó8   #   • U  H  oR                   v •  M     g 7fr‰   )r.   )r‹   r²   s     rJ   r�   Ú.solve_univariate_inequality.<locals>.<genexpr>@  s   é € Ð<ªO q—{–{ªOùs   ‚)Ú	separatedc                 ó   • U R                   $ r‰   ©rŸ   )r­   s    rJ   Ú<lambda>Ú-solve_univariate_inequality.<locals>.<lambda>C  s
   € ¸Q×=OÒ=OrL   z'sorting of these roots is not supportedz
                        zZ contains imaginary parts which cannot be
                        made 0 for any value of zm satisfying the
                        inequality, leading to relations like I < 0.
                        )<Úsympy.solvers.solversr©   Ú	is_subsetr   r0   r3   r   rt   Úintersectionrx   rŸ   r2   r   Úxreplacer    r/   r1   rg   rh   r   rj   r   r‘   r   ri   ÚsupÚinfr7   r   rU   rm   Úfree_symbolsÚlenr,   r   r¯   r   r–   r   ÚsetÚboundaryr   ÚlistÚallr   r   ÚsortedÚcoeffÚImaginaryUnitr   r+   Ú_ptÚRopenÚLopenÚopenÚ	is_finiter5   Úremover   r   )*r   rz   rd   rn   rª   r©   ÚrvÚ_genÚ_domainÚeÚperiodÚconstÚfranger<   rÃ   rÂ   r‚   rƒ   Úsolnsr´   ÚsingularitiesÚ	include_xÚdiscontinuitiesÚcritical_pointsr>   ÚsiftedÚ	make_realÚcoeffIÚcheckÚim_solÚaÚzÚstartÚendÚvalid_startÚvalid_zÚptrP   Úsol_setsr­   Ú_validr³   s*   ``                                       @rJ   rt   rt     s  ú€ õr -à×ÑœŸ™Ó  EÒ)Ü!¤*ð ."ó ##ó $ð 	$ð 
”q—w‘wÒ	Ü(Øˆc˜e°
ñ<ß<H¹LÈÓ<Pð 	æØ×!Ñ! #Ó&ˆBØˆ	àð
 €DØ€GØ
×Ñ˜uÒ$Ü�Z‰ZˆÞ#ˆrÐ?¨×)9Ñ)9¸$Ó)?Ð?Ø	×	Ñ	Ñ	%Ü�E¨Ñ.ˆð	Ø—=‘= $¨ Ó-ˆDð 
€BàŒq�v‰v‚~ØŠà	”—‘ŠÜ�Z‰ZŠð �H‰H�t—x‘xÑˆÜ˜Q Ó$ˆØ”Q—V‘VÓÜ˜1“ˆAØ—I‘I˜a “OˆEØœŸ™ŠØ’Øœ!Ÿ'™'Ò!Ü—Z‘Z�ùØÒÜ# A s¨FÓ3ˆFà—+‘+ˆCØ�kÓ!Ø—9‘9˜VŸZ™Z¨×+Ñ+Ø‘BØŸ™ 6§:¡:¨q×1Ñ1ÜŸ™�Bøà˜Ó#Ø—9‘9˜VŸZ™Z¨×+Ñ+Ø‘BØŸ™ 6§:¡:¨q×1Ñ1ÜŸ™�Bà—z‘z 6§:¡:�Ø‰yœAŸJ™JÒ&Ü! ! V¨U°DÓ9×CÑCÀGÓL�Ø �àŠ:Ø×#Ñ#Ó%‰DˆAˆqð8Ø˜aŸn™nÓ,´°Q·^±^Ó1DÀqÓ1HÜ$Ð$ô    3¨Ó/�Ø‘=ä$Ð$ð !ô $ A›ˆJ÷Að6 ˆMÙ˜D #Ö&�Ø×$Ñ$¤W¨Q°°VÓ%<Ö=ñ 'æÜ*¨:°s¸FÓC�à˜tŸ{™{Ñ*×B¨t¯{©{¸dÑ/BˆIðUÜ"% f§o¡oÜ˜fŸj™j¨&¯*©*Ó5ñ'6ó #7�ô #,¨e°mÑ.CÄdØ#óG%ñ /%ð #'ß'3¡|Ü˜VŸZ™Z¨¯©Ø—J‘J fÑ,¨f¯j©jÀÑ.FóHó(Ið  ô Ñ<©OÓ<×<Ñ<Ü" ?¸dÑCÀAÑF‘Eä! /Ñ3OÓP�FØ˜d—|ô 2Ð1ð2Ø & t¡˜Ü˜u›:¨›>Ü$*¨5£M˜Eô Ÿ™ˆIØ$×*Ñ*¬1¯?©?Ó;Ð;�ÄÇÁÔFØ�Ü"›�ð"Ü  ¨¨fÓ5�AÜ% a¬×2Ñ2Û!"˜AØ ¨Õ5¹%À¿(»(Àq×GY×GYÑGYØ &¬)°A«,Ñ 6¢ó "#ð &'§U¡U¨A¯E©E˜s˜Ü!'¨¼)ÀC».Ñ(HÖ!I˜AÙ*/°«,˜KØ$¨›|Ù*/°«( Ü%(¨°£] Ø#%¨]Ó#:¸r×?R×?RÑW\Ð]_×W`ÑW`Þ'2¶wØ(.´(¸5À!Ó2DÑ(D©Þ)4Ø(.´(·.².ÀÈÓ2JÑ(J©Þ)0Ø(.´(·.².ÀÈÓ2JÑ(J©à(.´(·-²-ÀÀqÓ2IÑ(I¨Ø$%šEñ "Jó "/˜AØ"¤i°£lÑ2šFò "/ð œQŸZ™ZÒ'Ü$¥Zð !%§	¡	¨#¨tÖ 4³dð	1<ó &=ó >ð >ð &×/Ñ/°Ó7�	äŸ
™
�|ˆHà—J‘JˆEØ˜‹¡5¨§<¡<°E·O·OØ—‘¤	¨%Ó 0Ô1ã�Ø�áœ˜U C›×)Ñ)Ø—O‘O¤H¨U°C¸¸tÓ$DÔEà˜Ó%Ø!×(Ñ(¨Õ+à˜OÓ+Ø'×.Ñ.¨qÔ1Ù!& q£™à!*˜ÞØ Ÿ™¬	°!«Ô5à’ñ# ð& —*‘*ˆCØ�f‹}¡ s§¡°··Ø—‘¤	¨#£Ô/á”S˜ “_×%Ñ%Ø—‘¤§¢¨e°SÓ 9Ô:àœŸ™Ó¦EØ×*Ñ*¨7Ó3‘ä!Ü˜HÐ%¨	°7ó<ß<@¹DÀÀd»Oð ö  ˆ2Ð; R×%5Ñ%5°dÓ%;Ð;øô_ ó 	ÜœJð (ó ó ð ð	ûôp Ô 3Ð4ó 8ô *¬*ð 6ð Ÿ)™) C¬°«Ó5ñ66ó +7ó 8ð 8ð8ûô@ %ó 2Ü1Ð1ð2ûä&ó UÜ)Ð*SÓTÐTðUûôD "ó "ÜŸW™W�FØ!“Eð"úsj   Ãb2 Ë8Ac Î9B:d, Ñ4d, Òd Ô+e Ô1e Õ e Õe Õ'De â2cãAdäd)ä)d, ä,eåe%å$e%c                 ó4  • U R                   (       d  UR                   (       d	  X-   S-  nU$ U R                   (       a#  UR                   (       a  [        R                  nU$ U R                   (       a  U R                  b  UR                   (       a  UR                  c  [	        S5      eUR                   (       a  UR
                  (       d"  U R                   (       a  U R                  (       a  XpUR                   (       aF  U R                  (       a  U S-  nU$ U R
                  (       a  U [        R                  -  nU$ U S-   n U$ U R                   (       aC  UR                  (       a  U[        R                  -  nU$ UR
                  (       a  US-  nU$ US-
  nW$ )z$Return a point between start and endr*   z,cannot proceed with unsigned infinite valuesr$   )Úis_infiniter   rj   Úis_extended_positiver,   Úis_extended_negativeÚHalf)ræ   rç   rê   s      rJ   rÍ   rÍ   ¦  sC  € à×× S§_§_Ø‰k˜1‰_ˆð6 €Ið5 
×	×	˜sŸŸÜ�V‰Vˆð2 €Ið/ ×× %×"<Ñ"<Ñ"DØ—— C×$<Ñ$<Ñ$DÜÐKÓLÐLØ�O�O × 8× 8Ø×!×! e×&@×&@Ø�3ð �?�?Ø×)×)Ø˜1‘W�ð €Ið ×+×+Øœ1Ÿ6™6‘\�ð €Ið ˜Q‘Y‘ð €Ið ××Ø×'×'ØœŸ™‘Z�ð
 €Ið	 ×)×)Ø˜‘U�ð €Ið ˜1‘W�Ø€IrL   c                 ó¬  • SSK Jn  XR                  ;  a  U $ U R                  U:X  a  U R                  n U R
                  U:X  a  XR                  R                  ;  a  U $ S nSn[        R                  nU R
                  U R                  -
  n [        Xq5      nUR                  5       S:X  a!  U R                  UR                  5       S5      nO!U(       d  UR                  5       S:”  a  [        e/ nUGcñ  WR                  5       nSnUR)                  USS9u  pïXÎ-  nXÞ-  n[+        U5      nUR)                  USS9u  nnUR,                  S:w  d2  UR.                  UR0                  s=:X  a   c%  O  O"U R2                  S	;  a  Un[        R4                  nUU-  nUR0                  (       a  U R                  XÍ5      nOU R                  R                  XÍ5      nU" U R
                  5      U" U R                  5      -  nU" U5      nUU-
   Hx  n[7        [9        US5      XS
9n[;        U[8        5      (       d  M.  UR
                  U:X  d  M@  U" XQUR                  5      [        R                   L d  Mf  UR=                  U) 5        Mz     U* U4 HY  nU" XQU5      [        R                   L d  M  U" XU5      [        R                   Ld  M;  UR=                  UUL a  UU:  OUU:  5        M[     UR=                  U5        ['        U6 $ ! [        [        4 GaC    U(       Gd,   [        U //U5      nO! [         a    [        X5      n Of = fU" XU5      n	U	[        R                   L a.  U" XQU5      [        R"                  L a  UR%                  X:  S5      nU" XU* 5      n
U
[        R                   L aF  U" XQU* 5      [        R"                  L a+  UR%                  U* U:  S5      nUR%                  X* :„  S5      nU[        R                   L a>  U	[        R                   L a  X:*  OX:  nU
[        R                   La  ['        U* U:  U5      n GNU[        U5      n GNcf = f)a¼  Return the inequality with s isolated on the left, if possible.
If the relationship is non-linear, a solution involving And or Or
may be returned. False or True are returned if the relationship
is never True or always True, respectively.

If `linear` is True (default is False) an `s`-dependent expression
will be isolated on the left, if possible
but it will not be solved for `s` unless the expression is linear
in `s`. Furthermore, only "safe" operations which do not change the
sense of the relationship are applied: no division by an unsigned
value is attempted unless the relationship involves Eq or Ne and
no division by a value not known to be nonzero is ever attempted.

Examples
========

>>> from sympy import Eq, Symbol
>>> from sympy.solvers.inequalities import _solve_inequality as f
>>> from sympy.abc import x, y

For linear expressions, the symbol can be isolated:

>>> f(x - 2 < 0, x)
x < 2
>>> f(-x - 6 < x, x)
x > -3

Sometimes nonlinear relationships will be False

>>> f(x**2 + 4 < 0, x)
False

Or they may involve more than one region of values:

>>> f(x**2 - 4 < 0, x)
(-2 < x) & (x < 2)

To restrict the solution to a relational, set linear=True
and only the x-dependent portion will be isolated on the left:

>>> f(x**2 - 4 < 0, x, linear=True)
x**2 < 4

Division of only nonzero quantities is allowed, so x cannot
be isolated by dividing by y:

>>> y.is_nonzero is None  # it is unknown whether it is 0 or not
True
>>> f(x*y < 1, x)
x*y < 1

And while an equality (or inequality) still holds after dividing by a
non-zero quantity

>>> nz = Symbol('nz', nonzero=True)
>>> f(Eq(x*nz, 1), x)
Eq(x, 1/nz)

the sign must be known for other inequalities involving > or <:

>>> f(x*nz <= 1, x)
nz*x <= 1
>>> p = Symbol('p', positive=True)
>>> f(x*p <= 1, x)
x <= 1/p

When there are denominators in the original expression that
are removed by expansion, conditions for them will be returned
as part of the result:

>>> f(x < x*(2/x - 1), x)
(x < 1) & Ne(x, 0)
r   r¨   c                 ó¢   •  U R                  X5      nU[        R                  L a  U$ US;  a  g U$ ! [         a    [        R                  s $ f = f)N©TF)r¯   r   ÚNaNr    )ÚierP   r�   r±   s       rJ   ÚclassifyÚ#_solve_inequality.<locals>.classify  sL   € ð	Ø—‘˜“ˆAØ”A—E‘EŠzØ�Ø˜-Ó'ØØˆHøÜó 	Ü—5‘5ŠLð	ús   ‚%1 ¨1 ¯1 ±AÁANr$   T)Úas_AddF)r#   r"   )Úlinear)r¾   r©   rÄ   rh   r9   rg   r   r7   r   Údegreer‘   r-   r3   r   r…   rt   r/   r1   r¯   r   Úas_independentr   Úis_zeroÚis_negativeÚis_positiveri   rk   Ú_solve_inequalityr   r+   r5   )rö   rP   rú   r©   r÷   rÓ   Úoor   rO   ÚokooÚoknoorŒ   rÖ   rh   ÚbÚaxÚefrä   Úbeginning_denomsÚcurrent_denomsrƒ   Úcr�   s                          rJ   r   r   Ç  s¢  € õT -Ø—‘ÓØˆ	Ø	‡v�v�ƒ{Ø�[‰[ˆØ	‡v�v�ƒ{�q§¡× 3Ñ 3Ó3Øˆ	òð 
€BÜ	
�‰€BØ�6‰6�B—F‘F‰?€DðÜ�‹MˆØ�8‰8‹:˜‹?Ø—‘˜Ÿ™› aÓ(‰BÞ˜AŸH™H›J¨›Nä%Ð%ð0 €EØ	‚zØ�I‰I‹Kˆð
 ˆØ× Ñ  ¨4Ð Ð0‰ˆØ	‰ˆØ‰ˆÜ˜!‹_ˆØ× Ñ  ¨5Ð Ð1‰ˆˆ1Ø�I‰I˜ÓØ—‘Ø—‘õ&Ø!%ô&à—	‘	 Ó-ØˆAÜ—‘ˆAØˆq‰ˆØ�=�=Ø—‘˜“‰Bà—‘×!Ñ! !Ó)ˆBñ " "§&¡&›>©F°2·6±6«NÑ:ÐÙ ›ˆØ! NÔ2ˆAÜ!¤" Q¨£(¨AÑ=ˆAÜ˜!œR× Ó  Q§U¡U¨a¥ZÙ˜B 1§5¡5Ó)¬Q¯V©VÔ3à—L‘L ! Ö$ñ 3ð �#�r“ˆAÙ˜ Ó"¤a§f¡fÔ,Ù˜R AÓ&¬a¯f©fÔ4Ø—‘ a¨2¢g˜Q šU°1°q±5Ö9ñ ð
 
‡L�L�ÔÜ�ˆ;ÐøôA Ô0Ð1ô ßð8Ü1°B°4°&¸!Ó<‘øÜ"ó 8Ü0°Ó7’ð8úñ ˜B 2Ó&ˆDØ”q—v‘vŠ~¡(¨2°"Ó"5¼¿¹Ò"@Ø—W‘W˜Q™V TÓ*�Ù˜R R CÓ(ˆEØœŸ™’Ù˜R R CÓ(¬A¯G©GÒ3Ø—W‘W˜b˜S 1™W dÓ+�Ø—W‘W˜Q ™W dÓ+�Ø”Q—V‘VŠ|Ø"&¬!¯&©&¢.�a’g°q±v�Ø¤§¡Ò&Ü˜b˜S 1™W bÓ)�Búä�T“
‹Að+úsC   Â?K? Ã!K? Ë?QÌL(Ì'QÌ(M Ì=QÌ?M Í DQÑQÑQc           
      óê  ^• 0 0 p2/ nU  GHr  nUR                   UR                  pvUR                  [        5      n[	        U5      S:X  a  UR                  5       mOjUR                  U-  n	[	        U	5      S:X  a8  U	R                  5       mUR                  [        [        USU5      T5      5        M¦  [        [        S5      5      eUR                  T5      (       a$  UR                  T/ 5      R                  Xg45        Mô  UR                  U4S j5      n
U
(       a<  [        S U
 5       5      (       a%  UR                  T/ 5      R                  Xg45        GML  UR                  [        [        USU5      T5      5        GMu     UR!                  5        VVs/ s H  u  p¼[#        U/U5      PM     nnnUR!                  5        VVs/ s H  u  p¼[%        XË5      PM     nnn['        XÞ-   U-   6 $ s  snnf s  snnf )Nr$   r   zZ
                    inequality has more than one symbol of interest.
                    c                 ó¶   >• U R                  T5      =(       aA    U R                  =(       d.    U R                  =(       a    U R                  R                  (       + $ r‰   )ru   Úis_Functionr“   r”   r•   )Úurz   s    €rJ   r¼   Ú&_reduce_inequalities.<locals>.<lambda>“  s<   ø€ Ø—‘�c“
÷ DØ—‘×B §¡×!B°!·%±%×2BÑ2BÔ.BðDrL   c              3   óB   #   • U  H  n[        U[        5      v •  M     g 7fr‰   )r+   r   ©r‹   r�   s     rJ   r�   Ú'_reduce_inequalities.<locals>.<genexpr>–  s   é € Ð!Iºj¸¤*¨Q´×"4Ð"4ºjùs   ‚)rg   ri   Úatomsr   rÅ   ÚpoprÄ   r5   r   r   r3   r   Úis_polynomialÚ
setdefaultÚfindrÉ   Úitemsr…   r¦   r   )r£   ÚsymbolsÚ	poly_partÚabs_partÚotherÚ
inequalityr   r<   ÚgensÚcommonÚ
componentsrz   ry   Úpoly_reducedÚabs_reduceds              `   rJ   Ú_reduce_inequalitiesr"  t  s·  ø€ ð ˜bˆxØ€Eä"ˆ
à—N‘N J×$5Ñ$5ˆcð
 �z‰zœ&Ó!ˆäˆt‹9˜‹>Ø—(‘(“*‰Cà×&Ñ&¨Ñ0ˆFÜ�6‹{˜aÓØ—j‘j“l�Ø—‘Ô.¬z¸$ÀÀ3Ó/GÈÓMÔNÙä)¬*ð 6ó +ó ð ð ×Ñ˜c×"Ñ"Ø× Ñ   bÓ)×0Ñ0°$°Ö=àŸ™ô $Dó EˆJö œcÑ!I¹jÓ!I×IÑIØ×#Ñ# C¨Ó,×3Ñ3°T°K×@à—‘Ô.¬z¸$ÀÀ3Ó/GÈÓM×Nñ? #ðB R[×Q`ÑQ`ÔQbÔcÒQbÁ:À3Ô0°%°¸#Ö>ÑQb€LÑcØIQÏÉÔIYÔZÒIY¹:¸3Ô*¨5Ö6ÑIY€KÑZä�Ñ+¨eÑ3Ð5Ð5ùó dùÛZs   ÆG)ÇG/c           	      ó¶  • [        U 5      (       d  U /n U  Vs/ s H  n[        U5      PM     n n[        5       R                  " U  Vs/ s H  o"R                  PM     sn6 n[        U5      (       d  U/n[        U5      =(       d    UU-  n[        S U 5       5      (       a  [        [        S5      5      eU Vs0 s H&  o"R                  b  M  U[        UR                  SS9_M(     nnU  Vs/ s H  o"R                  U5      PM     n nU Vs1 s H  o"R                  U5      iM     nn/ nU  HÊ  n[        U[        5      (       aF  UR                  UR                  R!                  5       UR"                  R!                  5       -
  S5      nOUS;  a  [%        US5      nUS:X  a  Mx  US:X  a  [&        R(                  s  $ UR                  R*                  (       a  [-        SU-  5      eUR/                  U5        MÌ     Un A[1        X5      nUR                  UR3                  5        VVs0 s H  u  pxX‡_M	     snn5      $ s  snf s  snf s  snf s  snf s  snf s  snnf )	a!  Reduce a system of inequalities with rational coefficients.

Examples
========

>>> from sympy.abc import x, y
>>> from sympy import reduce_inequalities

>>> reduce_inequalities(0 <= x + 3, [])
(-3 <= x) & (x < oo)

>>> reduce_inequalities(0 <= x + y*2 - 1, [x])
(x < oo) & (x >= 1 - 2*y)
c              3   ó<   #   • U  H  oR                   S L v •  M     g7f)FNr»   r  s     rJ   r�   Ú&reduce_inequalities.<locals>.<genexpr>¹  s   é € Ð
8²¨1×Ñ Õ&²ùs   ‚zP
            inequalities cannot contain symbols that are not real.
            Tr«   r   rô   Fr    )r   r   rÆ   rV   rÄ   Úanyr    r   rŸ   r   ÚnamerÁ   r+   r   r‘   rg   r-   rh   r   r   r1   r.   r3   r5   r"  r  )	r£   r  r�   r  ÚrecastÚkeeprÓ   Úkr±   s	            rJ   Úreduce_inequalitiesr+  ¡  s  € ô �L×!Ñ!Ø$�~ˆÙ(4Ó5ª 1”G˜A–J©€LÐ5ä‹5�;Š;±Ó>²¨AŸœ±Ñ>Ð?€Dä�G×ÑØ�)ˆÜ�7‹|×#˜t tÑ+€GÜ
Ñ
8±Ó
8×8Ñ8Üœ
ð $ó ó ð 	ñ ó5ÚˆA×+Ñ+ó 3ˆa”�q—v‘v¨TÑ2Ò2Ùð ð 5á0<Ó=²¨1—J‘J˜vÖ&±€LÐ=Ù+2Ó3ª7 a�z‰z˜&Ö!©7€GÐ3ð €DÛˆÜ�aœ×$Ñ$Ø—‘�q—u‘u—}‘}“¨¯©¯©«Ñ8¸!Ó<‰AØ�mÓ#Ü�1�a“ˆAØ�‹9ÙØ�%‹ZÜ—7‘7ŠNØ�5‰5�?�?Ü%Ø7¸!Ñ;ó=ð =à�‰�AŽñ ð €LØô 
˜lÓ	4€Bð �;‰;¨¯©¬Ô8ª¡ ˜š©Ò8Ó9Ð9ùòQ 6ùâ>ùò5ùâ=ùÚ3ùó0 9s)   ˜H<ÁIÂ9IÃIÃ,IÄIÈ&I
)T)F)9Ú__doc__rS   Úsympy.calculus.utilr   r   r   Ú
sympy.corer   Úsympy.core.exprtoolsr   Úsympy.core.relationalr   r	   r
   r   Úsympy.core.symbolr   r   Úsympy.sets.setsr   r   r   r   Úsympy.core.singletonr   Úsympy.core.functionr   Ú$sympy.functions.elementary.complexesr   Úsympy.logicr   Úsympy.polysr   r   r   Úsympy.polys.polyutilsr   Úsympy.solvers.solvesetr   r   Úsympy.utilities.iterablesr   r   Úsympy.utilities.miscr   rK   rQ   rb   r…   r¤   r¦   r0   rt   rÍ   r   r"  r+  rŠ   rL   rJ   Ú<module>r<     s    ðÙ BÛ ÷ñ å Ý -ß 8Ó 8ß +ß DÓ DÝ "Ý *Ý 4Ý ß FÑ FÝ (ß 4ß 4Ý +òXòvIò"?ôDXòvD;òN"ð2 7;À1Ç7Á7ÐW\ô d<òN	ôBjòZ*6ðZ /1õ 9:rL   