+
    i                          ^RI Ht ^RIHt ^RIHt ^RIHt ^RIH	t	H
t
 ^RIHt ^RIHt ^RIHtHtHtHt ^R	IHt  ! R
 R]4      tR# )   )Add)	gcd_terms)DefinedFunction)
NumberKind)	fuzzy_and	fuzzy_not)Mul)equal_valued)is_leis_ltis_geis_gt)Sc                   `   a  ] tR t^t o Rt]t]R 4       tR t	R t
R tR tR tRR ltR	tV tR
# )Moda  Represents a modulo operation on symbolic expressions.

Parameters
==========

p : Expr
    Dividend.

q : Expr
    Divisor.

Notes
=====

The convention used is the same as Python's: the remainder always has the
same sign as the divisor.

Many objects can be evaluated modulo ``n`` much faster than they can be
evaluated directly (or at all).  For this, ``evaluate=False`` is
necessary to prevent eager evaluation:

>>> from sympy import binomial, factorial, Mod, Pow
>>> Mod(Pow(2, 10**16, evaluate=False), 97)
61
>>> Mod(factorial(10**9, evaluate=False), 10**9 + 9)
712524808
>>> Mod(binomial(10**18, 10**12, evaluate=False), (10**5 + 3)**2)
3744312326

Examples
========

>>> from sympy.abc import x, y
>>> x**2 % y
Mod(x**2, y)
>>> _.subs({x: 5, y: 6})
1

c           	     V  a R  pV! VS4      pVe   V# \        W4      '       d`   VP                  ^,          pVS,          ^ 8X  d   V ! VP                  ^ ,          S4      # VSV,
          ,          P                  '       d   V# EM\        V) V 4      '       dc   V) P                  ^,          pVS,          ^ 8X  d   V ! V) P                  ^ ,          ) S4      # VSV,           ,          P                  '       d   V# EM\        V\        4      '       d   . . 3;pw  rxVP                   F$  p	V\        W4      ,          P                  V	4       K&  	  V'       d   \        ;QJ d    V3R lV 4       F  '       d   K   RM	  RM! V3R lV 4       4      '       dA   \	        V!  \	        V U
u. uF  qP                  ^ ,          NK  	  up
!  ,           pV ! VS4      # EM\        V\        4      '       Ed   . . 3;pw  rxVP                   F$  p	V\        W4      ,          P                  V	4       K&  	  V'       Ed`   \        ;QJ d    V3R lV 4       F  '       d   K   RM	  RM! V3R lV 4       4      '       Ed   \        ;QJ d&    R VP                   4       F  '       d   K   RM	  RM! R VP                   4       4      '       d   SP                  '       d   V Uu. uF  q! VS4      NK  	  pp. p. pV FI  p\        W4      '       d%   VP                  VP                  ^ ,          4       K8  VP                  V4       KK  	  \        V!  p\        V!  p\        V U
u. uF  qP                  ^ ,          NK  	  up
!  pVV,          pVV ! VS4      ,          # SP                  '       d   S\        P                  Jd   \        ;QJ d&    R VP                   4       F  '       d   K   RM	  RM! R VP                   4       4      '       d   VP                   U
u. uF  qP                  '       d
   V
S,          MT
NK!  	  pp
\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   \        P                  # \        Wx,           !  p^ RIHp ^ R	IHp  V! VS4      p\%        V^4      '       g+   VS3 U
u. uF  p
\'        V
V,          RRR
7      NK  	  up
w  poTSppTP(                  '       d   . pTP                   FU  p
T ! T
S4      pTP+                  T 4      T
P+                  T 4      8  d   TP                  T
4       KD  TP                  T4       KW  	  T\-        TP                  4      8w  d
   \	        T!  pMTP/                  4       w  ppSP/                  4       w  poRpTP0                  '       d   TP0                  '       g@   TT,          p\%        T^ 4      '       d%   TT,          pT\3        TT,          4      ,          pRpT'       g   TT,          pTS,          oTP5                  4       '       d0   SP5                  4       '       d   TTS3 U
u. uF  q) NK  	  up
w  ppoT! TS4      pTe
   TT,          # TP6                  '       d'   \%        T^4      '       d   TT,          pT ! TSRR7      # TP8                  '       d   TP                  ^ ,          P6                  '       de   \%        TP                  ^ ,          ^4      '       dB   TP                  ^ ,          T,          p\        P:                  ! TP                  R,          4      pTT ! TSTS3TT38g  R7      ,          # u up
i u upi u up
i u up
i u up
i   T d    \        P                  p ELi ; iu up
i )c                   VP                   '       d   \        R4      hV \        P                  J g5   V\        P                  J g!   V P                  RJ g   VP                  RJ d   \        P                  # V \        P
                  J g#   WV) 39   g   V P                  '       d   V^8X  d   \        P
                  # VP                  '       df   V P                  '       d	   W,          # V^8X  dE   V P                  '       d   \        P
                  # V P                  '       d   \        P                  # \        V R4      '       d   \        V R4      ! V4      pVe   V# W,          pVP                  '       d   \        P
                  #  \        V4      p\        V\        4      '       d*   WV,          ,
          pW!,          ^ 8  R8X  d	   W!,          pV#  VP                   '       d   \"        \$        reM VP&                  '       d   \(        \*        reMR# RV,          pW,
          p\-        ^4       F4  pV! Wp4      '       g    R# V! W74      '       d   W,
          u # Wq,          pK6  	  R#   \         d     Li ; i)zUTry to return p % q if both are numbers or +/-p is known
to be less than or equal q.
zModulo by zeroF	_eval_ModNT)is_zeroZeroDivisionErrorr   NaN	is_finiteZero
is_integer	is_Numberis_evenis_oddOnehasattrgetattrint
isinstance	TypeErroris_positiver   r   is_negativer   r   range)	pqrvrdcomp1comp2ls_s	   &&       L/var/www/html/photoedit/myenv/lib/python3.14/site-packages/sympy/core/mod.pynumber_evalMod.eval.<locals>.number_eval9   s   
 yyy'(899AEEzQ!%%Z1;;%+?1;;RWCWuuAFF{ar7lq|||Qvv{{{;;;3J6yyy vv uuq+&&Q,Q/>I A|||vv	F a%%qSBqT)I	 & }}}$eu$euABA1XR||<<6M '  s   I' 'I54I5c              3   N   <"   T F  qP                   ^,          S8H  x  K  	  R# 5ir   Nargs.0innerr)   s   & r1   	<genexpr>Mod.eval.<locals>.<genexpr>        CUEZZ]a/U   "%FTc              3   N   <"   T F  qP                   ^,          S8H  x  K  	  R# 5ir5   r6   r8   s   & r1   r;   r<      r=   r>   c              3   8   "   T F  qP                   x  K  	  R # 5iNr   r9   ts   & r1   r;   r<      s     Kibh]^LLbh   c              3   8   "   T F  qP                   x  K  	  R # 5irA   rB   rC   s   & r1   r;   r<      s     4V||VrE   c              3   D   "   T F  q\         P                  J x  K  	  R # 5irA   )r   r   )r9   iqs   & r1   r;   r<      s     <)B<)s    )PolynomialError)gcd)clearfraction)evaluate:r   NN)r#   r7   is_nonnegativeis_nonpositiver   appendallr	   r   
is_Integerr   r   anyr   sympy.polys.polyerrorsrI   sympy.polys.polytoolsrJ   r
   r   is_Addcountlistas_coeff_Mulis_Rationalr"   could_extract_minus_signis_Floatis_Mul
_from_args)clsr(   r)   r2   r*   qinnerboth_l	non_mod_lmod_larginetxmodnon_modjprod_modprod_non_mod	prod_mod1rI   rJ   Gpwasqwasr7   acpcqokr+   s   &&f                           r1   evalMod.eval7   s   8	t A>I aVVAYFzQ166!9a((!f*%555 6 C  bYYq\FzQaRIIaL=!,,!f*%555 6 3(*B.F%Yvvz#+,33C8  CUCCUCCC9o-GAffQii-G(HH3{"3(*B.F%Yvvz#+,33C8  uCUCCUCCCKibcbhbhKiKibcbhbhKiHiHinonznznz09:	1SAY		:"A!!))

166!9-q)	 #
 9"G}U!;U&&))U!;<	(#CQK//|||34QVV43334QVV444GHvv Nv!,,,QA!=vI Ns<)<sss<)<<< vvi')A 	;-	Aq	A1%%"#Q)!'A "!A#UUC!')1 d 888DVV1I773<!''#,.KKNKKN  tAFF|#J NN$EBNN$EBB>>>G1%%GARUOABqDqD %%''A,F,F,H,H$%q!9-9ar9-GAq! A>a4K :::,q!,,FAq!e,,XXX!&&),,,affQi1K1Kq	!Aqvvbz*AQQFtTl$:;;;} .H ; "< !O) 	A	H .sB   $]/
]4]9%]>!^  ^^ ^&^ ^#"^#c                    V P                   w  r\        VP                  VP                  \        VP                  4      .4      '       d   R # R# )TN)r7   r   r   r   r   )selfr(   r)   s   &  r1   _eval_is_integerMod._eval_is_integer   s9    yyallALL)AII2FGHH I    c                P    V P                   ^,          P                  '       d   R# R# r   TN)r7   r%   rx   s   &r1   _eval_is_nonnegativeMod._eval_is_nonnegative       99Q<### $r{   c                P    V P                   ^,          P                  '       d   R# R# r}   )r7   r&   r~   s   &r1   _eval_is_nonpositiveMod._eval_is_nonpositive   r   r{   c                D    ^ RI Hp WV! W,          4      ,          ,
          # )    floor)#sympy.functions.elementary.integersr   )rx   rq   bkwargsr   s   &&&, r1   _eval_rewrite_as_floorMod._eval_rewrite_as_floor   s    =U13Z<r{   c                R    ^ RI Hp V P                  V4      P                  WVR7      # r   r   )logxcdir)r   r   rewrite_eval_as_leading_term)rx   rg   r   r   r   s   &&&& r1   r   Mod._eval_as_leading_term   s$    =||E"88D8QQr{   c                R    ^ RI Hp V P                  V4      P                  WW4R7      # r   )r   r   r   _eval_nseries)rx   rg   nr   r   r   s   &&&&& r1   r   Mod._eval_nseries  s$    =||E"00D0LLr{    N)r   )__name__
__module____qualname____firstlineno____doc__r   kindclassmethodru   ry   r   r   r   r   r   __static_attributes____classdictcell__)__classdict__s   @r1   r   r      sM     &P Ds< s<j
 RM Mr{   r   N)addr   	exprtoolsr   functionr   r   r   logicr   r   mulr	   numbersr
   
relationalr   r   r   r   	singletonr   r   r   r{   r1   <module>r      s3       %  '  ! 2 2 xM/ xMr{   