K i(mddlmZmZmZddlmZddlmZddlm Z ddl m Z m Z ddl mZmZmZmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*m+Z+m,Z,ddl-m.Z.ddlm/Z/ddl0m1Z1m2Z2dZ3Gddee"Z4ejhZ5d'dZ6d'dZ7d(dZ8d)dZ9Gdd ee Z:Gd!d"e:eZ;Gd#d$e:eZ<Gd%d&eZ=y)*)Ssympify NumberKind)sift)Add)Tuple) LatticeOp ShortCircuit) ApplicationLambdaArgumentIndexErrorDefinedFunction)Expr) factor_terms)Mod)Mul)Rational)Pow)Eq Relational) Singleton)ordered)Dummy) Transform) fuzzy_andfuzzy_or_torf)walk)Integer)AndOrc ddlm}g}t|D]Q\}}t|dzt |Dcgc]}t ||||}}|j |t|fS||Scc}w)Nr Piecewise)$sympy.functions.elementary.piecewiser$ enumeraterangelenrappendr )opargsr$eciajcs n/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/functions/elementary/miscellaneous.py_minmax_as_Piecewiser3sv> B$ 116q1uc$i1H IAZ47B ' I I 1c1g,  b> JsA-c@eZdZdZedZedZedZy)IdentityFunctionz The identity function Examples ======== >>> from sympy import Id, Symbol >>> x = Symbol('x') >>> Id(x) x xc,t|jSN)r_symbolselfs r2 signaturezIdentityFunction.signature3sT\\""c|jSr8)r9r:s r2exprzIdentityFunction.expr7s ||r=N) __name__ __module__ __qualname____doc__rr9propertyr<r?r=r2r5r5#s8 CjG ##r=r5) metaclassNc:t|tj|S)aReturns the principal square root. Parameters ========== evaluate : bool, optional The parameter determines if the expression should be evaluated. If ``None``, its value is taken from ``global_parameters.evaluate``. Examples ======== >>> from sympy import sqrt, Symbol, S >>> x = Symbol('x') >>> sqrt(x) sqrt(x) >>> sqrt(x)**2 x Note that sqrt(x**2) does not simplify to x. >>> sqrt(x**2) sqrt(x**2) This is because the two are not equal to each other in general. For example, consider x == -1: >>> from sympy import Eq >>> Eq(sqrt(x**2), x).subs(x, -1) False This is because sqrt computes the principal square root, so the square may put the argument in a different branch. This identity does hold if x is positive: >>> y = Symbol('y', positive=True) >>> sqrt(y**2) y You can force this simplification by using the powdenest() function with the force option set to True: >>> from sympy import powdenest >>> sqrt(x**2) sqrt(x**2) >>> powdenest(sqrt(x**2), force=True) x To get both branches of the square root you can use the rootof function: >>> from sympy import rootof >>> [rootof(x**2-3,i) for i in (0,1)] [-sqrt(3), sqrt(3)] Although ``sqrt`` is printed, there is no ``sqrt`` function so looking for ``sqrt`` in an expression will fail: >>> from sympy.utilities.misc import func_name >>> func_name(sqrt(x)) 'Pow' >>> sqrt(x).has(sqrt) False To find ``sqrt`` look for ``Pow`` with an exponent of ``1/2``: >>> (x + 1/sqrt(x)).find(lambda i: i.is_Pow and abs(i.exp) is S.Half) {1/sqrt(x)} See Also ======== sympy.polys.rootoftools.rootof, root, real_root References ========== .. [1] https://en.wikipedia.org/wiki/Square_root .. [2] https://en.wikipedia.org/wiki/Principal_value evaluate)rrHalfargrIs r2sqrtrMCsj sAFFX ..r=c2t|tdd|S)a-Returns the principal cube root. Parameters ========== evaluate : bool, optional The parameter determines if the expression should be evaluated. If ``None``, its value is taken from ``global_parameters.evaluate``. Examples ======== >>> from sympy import cbrt, Symbol >>> x = Symbol('x') >>> cbrt(x) x**(1/3) >>> cbrt(x)**3 x Note that cbrt(x**3) does not simplify to x. >>> cbrt(x**3) (x**3)**(1/3) This is because the two are not equal to each other in general. For example, consider `x == -1`: >>> from sympy import Eq >>> Eq(cbrt(x**3), x).subs(x, -1) False This is because cbrt computes the principal cube root, this identity does hold if `x` is positive: >>> y = Symbol('y', positive=True) >>> cbrt(y**3) y See Also ======== sympy.polys.rootoftools.rootof, root, real_root References ========== .. [1] https://en.wikipedia.org/wiki/Cube_root .. [2] https://en.wikipedia.org/wiki/Principal_value r%rH)rrrKs r2cbrtrPsl sHQNX 66r=ct|}|rBtt|tj|z |tj d|z|z z|St|d|z |S)aReturns the *k*-th *n*-th root of ``arg``. Parameters ========== k : int, optional Should be an integer in $\{0, 1, ..., n-1\}$. Defaults to the principal root if $0$. evaluate : bool, optional The parameter determines if the expression should be evaluated. If ``None``, its value is taken from ``global_parameters.evaluate``. Examples ======== >>> from sympy import root, Rational >>> from sympy.abc import x, n >>> root(x, 2) sqrt(x) >>> root(x, 3) x**(1/3) >>> root(x, n) x**(1/n) >>> root(x, -Rational(2, 3)) x**(-3/2) To get the k-th n-th root, specify k: >>> root(-2, 3, 2) -(-1)**(2/3)*2**(1/3) To get all n n-th roots you can use the rootof function. The following examples show the roots of unity for n equal 2, 3 and 4: >>> from sympy import rootof >>> [rootof(x**2 - 1, i) for i in range(2)] [-1, 1] >>> [rootof(x**3 - 1,i) for i in range(3)] [1, -1/2 - sqrt(3)*I/2, -1/2 + sqrt(3)*I/2] >>> [rootof(x**4 - 1,i) for i in range(4)] [-1, 1, -I, I] SymPy, like other symbolic algebra systems, returns the complex root of negative numbers. This is the principal root and differs from the text-book result that one might be expecting. For example, the cube root of -8 does not come back as -2: >>> root(-8, 3) 2*(-1)**(1/3) The real_root function can be used to either make the principal result real (or simply to return the real root directly): >>> from sympy import real_root >>> real_root(_) -2 >>> real_root(-32, 5) -2 Alternatively, the n//2-th n-th root of a negative number can be computed with root: >>> root(-32, 5, 5//2) -2 See Also ======== sympy.polys.rootoftools.rootof sympy.core.intfunc.integer_nthroot sqrt, real_root References ========== .. [1] https://en.wikipedia.org/wiki/Square_root .. [2] https://en.wikipedia.org/wiki/Real_root .. [3] https://en.wikipedia.org/wiki/Root_of_unity .. [4] https://en.wikipedia.org/wiki/Principal_value .. [5] https://mathworld.wolfram.com/CubeRoot.html rHr%)rrrrOne NegativeOne)rLnkrIs r2rootrWsV|  A3sAEE!Gh71Q9OZbcc sAaC( ++r=c ddlm}m}m}ddlm}||t |||tt|tjt|tjft||t |||||tt||tjtt|dtjft |||dfSt!|}t#dd}|j%|S) a"Return the real *n*'th-root of *arg* if possible. Parameters ========== n : int or None, optional If *n* is ``None``, then all instances of $(-n)^{1/\text{odd}}$ will be changed to $-n^{1/\text{odd}}$. This will only create a real root of a principal root. The presence of other factors may cause the result to not be real. evaluate : bool, optional The parameter determines if the expression should be evaluated. If ``None``, its value is taken from ``global_parameters.evaluate``. Examples ======== >>> from sympy import root, real_root >>> real_root(-8, 3) -2 >>> root(-8, 3) 2*(-1)**(1/3) >>> real_root(_) -2 If one creates a non-principal root and applies real_root, the result will not be real (so use with caution): >>> root(-8, 3, 2) -2*(-1)**(2/3) >>> real_root(_) -2*(-1)**(2/3) See Also ======== sympy.polys.rootoftools.rootof sympy.core.intfunc.integer_nthroot root, sqrt r)Absimsignr#rHrRTc8|j |jz Sr8)baseexpr6s r2zreal_root..ns166'AEE!1 1r=c|jxrd|jjxrL|jjxr4|jj dk(xr|jj dzS)Nr%rR)is_Powr] is_negativer^ is_Rationalpqr_s r2r`zreal_root..os^hh3ff((3ee''3eeggl3()uuww{ r=)$sympy.functions.elementary.complexesrYrZr[r&r$rWr!rrrSrTrr Zerorrrxreplace) rLrUrIrYrZr[r$rvn1pows r2 real_rootrl8sZCB>} #q8 ,bAquur!Q]]?S.T U cDS1x@8 T 2c7AFF#RAq 155%9 : < #q8 ,d 3 5 5 B 13 4E ;;u r=ceZdZdZedZedZedZedZfdZ dZ d$dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&xZ'S)% MinMaxBasecddlm}|jd|j}d|D}|rA t |j |}|j|fi|}|j|fi|}t |}|s |jSt|dk(rt|jStj|gt|i|}||_|S#t $r|jcYSwxYw)Nr)global_parametersrIc32K|]}t|ywr8)r).0rLs r2 z%MinMaxBase.__new__..s- -sr%)sympy.core.parametersrppoprI frozenset_new_args_filterr zero_collapse_arguments_find_localzerosidentityr)listr__new__r_argset)clsr, assumptionsrprIobjs r2r}zMinMaxBase.__new__|s;??:/@/I/IJ--   !5!5d!;<+3**4?;?D'3''< :>># #ll3>>+>  #  xx sCC21C2c |s|Stt|}tk(rtnt|djrggfx}\}}|D]X}t |ttD]>}|j djs|t|tj|@Ztj}|D])}|j d}|js||kdk(s(|}+tj} |D])}|j d}|js|| kDdk(s(|} +tk(r!|D]} | jsn7| |kdk(s| }n)tk(r |D]} | jsn | | kDdk(s| } d} tk(r|tjk7r$t|} n| tjk7rt| } | `tt|D]I}||} t| s| j d} tk(r| | kDn| | kdk(s;j||<Kfdt|D](\}} ||dzdDcgc] }||  c}||dzd*fd}t|dkDr||}|Scc}w)a}Remove redundant args. Examples ======== >>> from sympy import Min, Max >>> from sympy.abc import a, b, c, d, e Any arg in parent that appears in any parent-like function in any of the flat args of parent can be removed from that sub-arg: >>> Min(a, Max(b, Min(a, c, d))) Min(a, Max(b, Min(c, d))) If the arg of parent appears in an opposite-than parent function in any of the flat args of parent that function can be replaced with the arg: >>> Min(a, Max(b, Min(c, d, Max(a, e)))) Min(a, Max(b, Min(a, c, d))) rTNc Tt|ttfs|S||jv}|s1|j|jDcgc] }|| c}ddiSt|r7|j|jDcgc]}||k7s ||c}ddiS|Scc}wcc}w)NrIF) isinstanceMinMaxr,func)air/condr.rdos r2rz*MinMaxBase._collapse_arguments..dosb3*- .factor_minmax..s:c5#9r=T)binaryrIF)rsetr, intersectionr|allr*)r,is_other other_argsremaining_argsrLarg_setscommonnew_other_argsarg_set arg_sets_diffsother_args_diffother_args_factoredrrs r2 factor_minmaxz5MinMaxBase._collapse_arguments..factor_minmaxs9H)-dHT)J &J 2<<#CHH DAq04QUV ="Br1I=DQL > :0 t9q= &D I>s<I5c#JK|D]}t|tr&|jdus|jr|jst d|z||j k(r t|||jk(rq|j|k(r|jEd{|y7 w)z Generator filtering args. first standard filter, for cls.zero and cls.identity. Also reshape ``Max(a, Max(b, c))`` to ``Max(a, b, c)``, and check arguments for comparability Fz$The argument '%s' is not comparable.N) rris_extended_realrr ValueErrorrxr r{rr,)r arg_sequencerLs r2rwzMinMaxBase._new_args_filter!s  Cc4(C,@,@E,IMM)) !G#!MNNchh"3'' $S88##  $sBB#B! B#c 6t}|D]}d}t|}|D]`}t|t|k(rd}|j||}|s2d}|dus||k(s>|j ||j |gb|sx|j |g|S)a Sequentially allocate values to localzeros. When a value is identified as being more extreme than another member it replaces that member; if this is never true, then the value is simply appended to the localzeros. TF)rr|id _is_connectedremoveupdate) rvaluesoptions localzerosr is_newzero localzeros_zcons r2rzzMinMaxBase._find_localzeros:sU  'AJz*K 3a5BqE>!&J++Aq1C%* $;#*&--a0&--qc2 3!!1#& 'r=cBtdD]}||k(rytt}}dD]G}tdD]3} |dk(r||k\}n||k}|js |r|n|cccS||}}||}}5||}}It ||z }t j}y#t$rYywxYw)z9 Check if x and y are connected somehow. rRTz><>F)r(rr TypeError is_Relationalrrrh) rr6yr.tfr+r0rs r2rzMinMaxBase._is_connectedUs q AAvqA q  A%9 !QA !QA??$%q1,aqAaqA  !1  QU#AA+ .%%$%sB B B c d}g}|jD]K}|dz }|j|}|jr& |j|}|j ||zMt|S#t$rt | |}Y8wxYw)Nrr%)r,diffis_zerofdiffr superr*r)r;rr.lr/dadf __class__s r2_eval_derivativezMinMaxBase._eval_derivativess   A FABzz &ZZ] HHR"W  Aw& &W]1% &sA((BBcddlm}|d|j|ddzdz }t|d|j|ddz dz }t |t r||zj |S||z j |S)Nr)rYr%rR)rgrYrabsrrrewrite)r;r,kwargsrYrds r2_eval_rewrite_as_AbszMinMaxBase._eval_rewrite_as_Abss< !Wytyy$qr(+ +Q . Q)$))T!"X.. / 1#D#.ABB3GGAEBB3GGr=c ||j|jDcgc]}|j|fi|c}Scc}wr8)rr,evalf)r;rUrr/s r2rzMinMaxBase.evalfs5tyy$))DQ7177100DEEDs9c&|j|i|Sr8)rr;r,rs r2rUz MinMaxBase.nstzz4*6**r=c:td|jDS)Nc34K|]}|jywr8) is_algebraicrrr.s r2rsz&MinMaxBase...(HA(Hrr,rs r2r`zMinMaxBase.5(H(H#Hr=c:td|jDS)Nc34K|]}|jywr8)is_antihermitianrs r2rsz&MinMaxBase...,PAQ-?-?,Prrrs r2r`zMinMaxBase.u,P,P'Pr=c:td|jDS)Nc34K|]}|jywr8)is_commutativers r2rsz&MinMaxBase...*L1+;+;*Lrrrs r2r`zMinMaxBase.U*LQVV*L%Lr=c:td|jDS)Nc34K|]}|jywr8) is_complexrs r2rsz&MinMaxBase...&Dq||&Drrrs r2r`zMinMaxBase.&DQVV&D!Dr=c:td|jDS)Nc34K|]}|jywr8) is_compositers r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=c:td|jDS)Nc34K|]}|jywr8)is_evenrs r2rsz&MinMaxBase...#>!AII#>rrrs r2r`zMinMaxBase.e#>qvv#>>r=c:td|jDS)Nc34K|]}|jywr8) is_finiters r2rsz&MinMaxBase...s%Baakk%Brrrs r2r`zMinMaxBase.s%B166%B Br=c:td|jDS)Nc34K|]}|jywr8) is_hermitianrs r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=c:td|jDS)Nc34K|]}|jywr8) is_imaginaryrs r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=c:td|jDS)Nc34K|]}|jywr8) is_infiniters r2rsz&MinMaxBase...'F! 'Frrrs r2r`zMinMaxBase.%'Fqvv'F"Fr=c:td|jDS)Nc34K|]}|jywr8) is_integerrs r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=c:td|jDS)Nc34K|]}|jywr8) is_irrationalrs r2rsz&MinMaxBase...)Ja!//)Jrrrs r2r`zMinMaxBase.E)J166)J$Jr=c:td|jDS)Nc34K|]}|jywr8rcrs r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=c:td|jDS)Nc34K|]}|jywr8) is_nonintegerrs r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=c:td|jDS)Nc34K|]}|jywr8is_nonnegativers r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=c:td|jDS)Nc34K|]}|jywr8)is_nonpositivers r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=c:td|jDS)Nc34K|]}|jywr8) is_nonzerors r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=c:td|jDS)Nc34K|]}|jywr8)is_oddrs r2rsz&MinMaxBase...s"<188"sU"..$@AQZZ$@rrrs r2r`zMinMaxBase.u$@$@@r=c:td|jDS)Nc34K|]}|jywr8 is_positivers r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=c:td|jDS)Nc34K|]}|jywr8)is_primers r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.r r=c:td|jDS)Nc34K|]}|jywr8) is_rationalrs r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=c:td|jDS)Nc34K|]}|jywr8)is_realrs r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=c:td|jDS)Nc34K|]}|jywr8)rrs r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=c:td|jDS)Nc34K|]}|jywr8)is_transcendentalrs r2rsz&MinMaxBase...s-Raa.A.A-Rrrrs r2r`zMinMaxBase.s-R166-R(Rr=c:td|jDS)Nc34K|]}|jywr8)rrs r2rsz&MinMaxBase...rrrrs r2r`zMinMaxBase.rr=))(r@rArBr} classmethodryrwrzrrrrrU_eval_is_algebraic_eval_is_antihermitian_eval_is_commutative_eval_is_complex_eval_is_composite _eval_is_even_eval_is_finite_eval_is_hermitian_eval_is_imaginary_eval_is_infinite_eval_is_integer_eval_is_irrational_eval_is_negative_eval_is_noninteger_eval_is_nonnegative_eval_is_nonpositive_eval_is_nonzero _eval_is_odd_eval_is_polar_eval_is_positive_eval_is_prime_eval_is_rational _eval_is_real_eval_is_extended_real_eval_is_transcendental _eval_is_zero __classcell__)rs@r2rnrn{s <DDL04: H F+IPLDH>MBOHHFDJFJLLDMPR>Mr=rncdeZdZdZej ZejZdZ dZ dZ dZ dZ dZy) ra Return, if possible, the maximum value of the list. When number of arguments is equal one, then return this argument. When number of arguments is equal two, then return, if possible, the value from (a, b) that is $\ge$ the other. In common case, when the length of list greater than 2, the task is more complicated. Return only the arguments, which are greater than others, if it is possible to determine directional relation. If is not possible to determine such a relation, return a partially evaluated result. Assumptions are used to make the decision too. Also, only comparable arguments are permitted. It is named ``Max`` and not ``max`` to avoid conflicts with the built-in function ``max``. Examples ======== >>> from sympy import Max, Symbol, oo >>> from sympy.abc import x, y, z >>> p = Symbol('p', positive=True) >>> n = Symbol('n', negative=True) >>> Max(x, -2) Max(-2, x) >>> Max(x, -2).subs(x, 3) 3 >>> Max(p, -2) p >>> Max(x, y) Max(x, y) >>> Max(x, y) == Max(y, x) True >>> Max(x, Max(y, z)) Max(x, y, z) >>> Max(n, 8, p, 7, -oo) Max(8, p) >>> Max (1, x, oo) oo * Algorithm The task can be considered as searching of supremums in the directed complete partial orders [1]_. The source values are sequentially allocated by the isolated subsets in which supremums are searched and result as Max arguments. If the resulted supremum is single, then it is returned. The isolated subsets are the sets of values which are only the comparable with each other in the current set. E.g. natural numbers are comparable with each other, but not comparable with the `x` symbol. Another example: the symbol `x` with negative assumption is comparable with a natural number. Also there are "least" elements, which are comparable with all others, and have a zero property (maximum or minimum for all elements). For example, in case of $\infty$, the allocation operation is terminated and only this value is returned. Assumption: - if $A > B > C$ then $A > C$ - if $A = B$ then $B$ can be removed References ========== .. [1] https://en.wikipedia.org/wiki/Directed_complete_partial_order .. [2] https://en.wikipedia.org/wiki/Lattice_%28order%29 See Also ======== Min : find minimum values cxddlm}t|j}d|kr||kr|dz}|dk(r(||j||jd|z z St t |Dcgc]}||k7s |j|c}}||j|t |z St||cc}wNr Heavisider%rR)'sympy.functions.special.delta_functionsrVr)r,tupler(rr r;argindexrVrUr.newargss r2rz Max.fdiffsE  N x=r3rs r2_eval_rewrite_as_PiecewisezMax._eval_rewrite_as_Piecewise#D0400r=c:td|jDS)Nc34K|]}|jywr8r#rrr/s r2rsz(Max._eval_is_positive..9! 9rrr,r:s r2rJzMax._eval_is_positive9tyy999r=c:td|jDS)Nc34K|]}|jywr8rris r2rsz+Max._eval_is_nonnegative..s.:1:rrr,r:s r2rCzMax._eval_is_negative: :::r=N)r@rArBrCrInfinityrxNegativeInfinityr{rrarerJrErCrEr=r2rrs=Sh ::D!!H 5 1:=;r=rcdeZdZdZej ZejZdZ dZ dZ dZ dZ dZy) raB Return, if possible, the minimum value of the list. It is named ``Min`` and not ``min`` to avoid conflicts with the built-in function ``min``. Examples ======== >>> from sympy import Min, Symbol, oo >>> from sympy.abc import x, y >>> p = Symbol('p', positive=True) >>> n = Symbol('n', negative=True) >>> Min(x, -2) Min(-2, x) >>> Min(x, -2).subs(x, 3) -2 >>> Min(p, -3) -3 >>> Min(x, y) Min(x, y) >>> Min(n, 8, p, -7, p, oo) Min(-7, n) See Also ======== Max : find maximum values cxddlm}t|j}d|kr||kr|dz}|dk(r(||jd|z |j|z St t |Dcgc]}||k7s |j|c}}|t ||j|z St||cc}wrT)rWrVr)r,rXr(rr rYs r2rz Min.fdiffBsE  N x.Wrqrrrr:s r2rJzMin._eval_is_positiveVrsr=c:td|jDS)Nc34K|]}|jywr8rris r2rsz+Min._eval_is_nonnegative..Zs=a))=rrrr:s r2rEzMin._eval_is_nonnegativeYs=499===r=c:td|jDS)Nc34K|]}|jywr8r ris r2rsz(Min._eval_is_negative..]rjrrkr:s r2rCzMin._eval_is_negative\rlr=N)r@rArBrCrrurxrtr{rrarerJrErCrEr=r2rr!s;:  DzzH 5 1;>:r=rc$eZdZdZeZedZy)Rema8Returns the remainder when ``p`` is divided by ``q`` where ``p`` is finite and ``q`` is not equal to zero. The result, ``p - int(p/q)*q``, has the same sign as the divisor. Parameters ========== p : Expr Dividend. q : Expr Divisor. Notes ===== ``Rem`` corresponds to the ``%`` operator in C. Examples ======== >>> from sympy.abc import x, y >>> from sympy import Rem >>> Rem(x**3, y) Rem(x**3, y) >>> Rem(x**3, y).subs({x: -5, y: 3}) -2 See Also ======== Mod c|jr td|tjus.|tjus|jdus|jdurtjS|tj us||| fvs|j r|dk(rtj S|jr!|jr|t||z |zz Syy)zZReturn the function remainder if both p, q are numbers and q is not zero. zDivision by zeroFr%N) rZeroDivisionErrorrNaNrrhr is_Numberr)rrerfs r2evalzRem.evals 99#$67 7 :aeeq{{e';q{{e?S55L ;!A2w,1<)) r=N)r@rArBrCrkindr6rrEr=r2rr`s! B D**r=rr8)rN)NN)> sympy.corerrrsympy.utilities.iterablesrsympy.core.addrsympy.core.containersrsympy.core.operationsr r sympy.core.functionr r r rsympy.core.exprrsympy.core.exprtoolsrsympy.core.modrsympy.core.mulrsympy.core.numbersrsympy.core.powerrsympy.core.relationalrrsympy.core.singletonrsympy.core.sortingrsympy.core.symbolrsympy.core.rulesrsympy.core.logicrrrsympy.core.traversalrrsympy.logic.boolalgr r!r3r5IdrMrPrWrlrnrrrrEr=r2rs--*'9)) -' 0*&#&77%&'v2U/p67ra,H<Fm?ym?` s;*ks;l<:*k<:~3*/3*r=