K i/`dZddlmZddlmZddlmZddlmZddl m Z ddl m Z m Z mZmZmZddlmZmZmZmZmZmZmZmZmZdd lmZdd Zej<d fd Zej<d fd Z ej<d fdZ!ej<d fdZ"ej<d fdZ#ej<d fdZ$y )af Singularities ============= This module implements algorithms for finding singularities for a function and identifying types of functions. The differential calculus methods in this module include methods to identify the following function types in the given ``Interval``: - Increasing - Strictly Increasing - Decreasing - Strictly Decreasing - Monotonic )Pow)S)Symbol)sympify)log)seccsccottancos) sechcschcothtanhcoshasechacschatanhacoth) filldedentNcpddlm}|,|jrtjntj } tj }|jttttgt}|jtttt gt"}|j%t&D]L}|j(j*rt,|j(j.s6|||j0||z }N|j%t2t4t6D]}|||j8d||z }|j%t:t<D]<}|||j8ddz ||z }|||j8ddz||z }>|S#t,$rt-t?dwxYw)a Find singularities of a given function. Parameters ========== expression : Expr The target function in which singularities need to be found. symbol : Symbol The symbol over the values of which the singularity in expression in being searched for. Returns ======= Set A set of values for ``symbol`` for which ``expression`` has a singularity. An ``EmptySet`` is returned if ``expression`` has no singularities for any given value of ``Symbol``. Raises ====== NotImplementedError Methods for determining the singularities of this function have not been developed. Notes ===== This function does not find non-isolated singularities nor does it find branch points of the expression. Currently supported functions are: - univariate continuous (real or complex) functions References ========== .. [1] https://en.wikipedia.org/wiki/Mathematical_singularity Examples ======== >>> from sympy import singularities, Symbol, log >>> x = Symbol('x', real=True) >>> y = Symbol('y', real=False) >>> singularities(x**2 + x + 1, x) EmptySet >>> singularities(1/(x + 1), x) {-1} >>> singularities(1/(y**2 + 1), y) {-I, I} >>> singularities(1/(y**3 + 1), y) {-1, 1/2 - sqrt(3)*I/2, 1/2 + sqrt(3)*I/2} >>> singularities(log(x), x) {0} rsolvesetzl Methods for determining the singularities of this function have not been developed.) sympy.solvers.solvesetris_realrReals ComplexesEmptySetrewriterr r r r r rrrratomsrexp is_infiniteNotImplementedError is_negativebaserrrargsrrr) expressionsymboldomainrsingseis b/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/calculus/singularities.py singularitiesr/svx0 ~"NN ;    S#s3S 9 IItT4. 5 :Auu  ))uu  !&&&&99  : !!#ue4 9A XaffQi8 8E 9!!%/ =A XaffQi!mVV< 0$J  " "D ~ t9q=%5  >$((*&+H*J!)J"7177K   0 11c t|d||S)a Return whether the function is increasing in the given interval. Parameters ========== expression : Expr The target function which is being checked. interval : Set, optional The range of values in which we are testing (defaults to set of all real numbers). symbol : Symbol, optional The symbol present in expression which gets varied over the given range. Returns ======= Boolean True if ``expression`` is increasing (either strictly increasing or constant) in the given ``interval``, False otherwise. Examples ======== >>> from sympy import is_increasing >>> from sympy.abc import x, y >>> from sympy import S, Interval, oo >>> is_increasing(x**3 - 3*x**2 + 4*x, S.Reals) True >>> is_increasing(-x**2, Interval(-oo, 0)) True >>> is_increasing(-x**2, Interval(0, oo)) False >>> is_increasing(4*x**3 - 6*x**2 - 72*x + 30, Interval(-2, 3)) False >>> is_increasing(x**2 + y, Interval(1, 2), x) True c |dk\SNrr1s r.zis_increasing.. Q!Vr>r=r(r8r)s r. is_increasingrHsP z+;Xv NNr>c t|d||S)at Return whether the function is strictly increasing in the given interval. Parameters ========== expression : Expr The target function which is being checked. interval : Set, optional The range of values in which we are testing (defaults to set of all real numbers). symbol : Symbol, optional The symbol present in expression which gets varied over the given range. Returns ======= Boolean True if ``expression`` is strictly increasing in the given ``interval``, False otherwise. Examples ======== >>> from sympy import is_strictly_increasing >>> from sympy.abc import x, y >>> from sympy import Interval, oo >>> is_strictly_increasing(4*x**3 - 6*x**2 - 72*x + 30, Interval.Ropen(-oo, -2)) True >>> is_strictly_increasing(4*x**3 - 6*x**2 - 72*x + 30, Interval.Lopen(3, oo)) True >>> is_strictly_increasing(4*x**3 - 6*x**2 - 72*x + 30, Interval.open(-2, 3)) False >>> is_strictly_increasing(-x**2, Interval(0, oo)) False >>> is_strictly_increasing(-x**2 + y, Interval(-oo, 0), x) False c |dkDSrArBrCs r.rDz(is_strictly_increasing.. QUr>rFrGs r.is_strictly_increasingrLP z?Hf MMr>c t|d||S)a Return whether the function is decreasing in the given interval. Parameters ========== expression : Expr The target function which is being checked. interval : Set, optional The range of values in which we are testing (defaults to set of all real numbers). symbol : Symbol, optional The symbol present in expression which gets varied over the given range. Returns ======= Boolean True if ``expression`` is decreasing (either strictly decreasing or constant) in the given ``interval``, False otherwise. Examples ======== >>> from sympy import is_decreasing >>> from sympy.abc import x, y >>> from sympy import S, Interval, oo >>> is_decreasing(1/(x**2 - 3*x), Interval.open(S(3)/2, 3)) True >>> is_decreasing(1/(x**2 - 3*x), Interval.open(1.5, 3)) True >>> is_decreasing(1/(x**2 - 3*x), Interval.Lopen(3, oo)) True >>> is_decreasing(1/(x**2 - 3*x), Interval.Ropen(-oo, S(3)/2)) False >>> is_decreasing(1/(x**2 - 3*x), Interval.Ropen(-oo, 1.5)) False >>> is_decreasing(-x**2, Interval(-oo, 0)) False >>> is_decreasing(-x**2 + y, Interval(-oo, 0), x) False c |dkSrArBrCs r.rDzis_decreasing..+rEr>rFrGs r. is_decreasingrPsX z+;Xv NNr>c t|d||S)aZ Return whether the function is strictly decreasing in the given interval. Parameters ========== expression : Expr The target function which is being checked. interval : Set, optional The range of values in which we are testing (defaults to set of all real numbers). symbol : Symbol, optional The symbol present in expression which gets varied over the given range. Returns ======= Boolean True if ``expression`` is strictly decreasing in the given ``interval``, False otherwise. Examples ======== >>> from sympy import is_strictly_decreasing >>> from sympy.abc import x, y >>> from sympy import S, Interval, oo >>> is_strictly_decreasing(1/(x**2 - 3*x), Interval.Lopen(3, oo)) True >>> is_strictly_decreasing(1/(x**2 - 3*x), Interval.Ropen(-oo, S(3)/2)) False >>> is_strictly_decreasing(1/(x**2 - 3*x), Interval.Ropen(-oo, 1.5)) False >>> is_strictly_decreasing(-x**2, Interval(-oo, 0)) False >>> is_strictly_decreasing(-x**2 + y, Interval(-oo, 0), x) False c |dkSrArBrCs r.rDz(is_strictly_decreasing..VrKr>rFrGs r.is_strictly_decreasingrS.rMr>c(ddlm}t|}|j}|t |dkDr t d|xs|r|j n td}||j|||}|j|tjuS)a Return whether the function is monotonic in the given interval. Parameters ========== expression : Expr The target function which is being checked. interval : Set, optional The range of values in which we are testing (defaults to set of all real numbers). symbol : Symbol, optional The symbol present in expression which gets varied over the given range. Returns ======= Boolean True if ``expression`` is monotonic in the given ``interval``, False otherwise. Raises ====== NotImplementedError Monotonicity check has not been implemented for the queried function. Examples ======== >>> from sympy import is_monotonic >>> from sympy.abc import x, y >>> from sympy import S, Interval, oo >>> is_monotonic(1/(x**2 - 3*x), Interval.open(S(3)/2, 3)) True >>> is_monotonic(1/(x**2 - 3*x), Interval.open(1.5, 3)) True >>> is_monotonic(1/(x**2 - 3*x), Interval.Lopen(3, oo)) True >>> is_monotonic(x**3 - 3*x**2 + 4*x, S.Reals) True >>> is_monotonic(-x**2, S.Reals) False >>> is_monotonic(x**2 + y + 1, Interval(1, 2), x) True rrrzKis_monotonic has not yet been implemented for all multivariate expressions.r1) rrrr2r3r$r4rr5 intersectionrr)r(r8r)rr9r:turning_pointss r. is_monotonicrWYs`0$J  " "D ~#d)a-! 1  >$((*&+Hjooh78LN   0AJJ >>r>)N)%__doc__sympy.core.powerrsympy.core.singletonrsympy.core.symbolrsympy.core.sympifyr&sympy.functions.elementary.exponentialr(sympy.functions.elementary.trigonometricrr r r r %sympy.functions.elementary.hyperbolicr rrrrrrrrsympy.utilities.miscrr/rr=rHrLrPrSrWrBr>r.ras"!"$&6LL>>>+S;v9:.2b()wwt(OV12(NV()wwt,O^12(NV'(ggd=?r>