当前位置: 首页>>代码示例>>Python>>正文


Python solveset._has_rational_power函数代码示例

本文整理汇总了Python中sympy.solvers.solveset._has_rational_power函数的典型用法代码示例。如果您正苦于以下问题:Python _has_rational_power函数的具体用法?Python _has_rational_power怎么用?Python _has_rational_power使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_has_rational_power函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: continuous_domain

def continuous_domain(f, symbol, domain):
    """
    Returns the intervals in the given domain for which the function is continuous.
    This method is limited by the ability to determine the various
    singularities and discontinuities of the given function.

    Examples
    ========
    >>> from sympy import Symbol, S, tan, log, pi, sqrt
    >>> from sympy.sets import Interval
    >>> from sympy.calculus.util import continuous_domain
    >>> x = Symbol('x')
    >>> continuous_domain(1/x, x, S.Reals)
    (-oo, 0) U (0, oo)
    >>> continuous_domain(tan(x), x, Interval(0, pi))
    [0, pi/2) U (pi/2, pi]
    >>> continuous_domain(sqrt(x - 2), x, Interval(-5, 5))
    [2, 5]
    >>> continuous_domain(log(2*x - 1), x, S.Reals)
    (1/2, oo)

    """
    from sympy.solvers.inequalities import solve_univariate_inequality
    from sympy.solvers.solveset import solveset, _has_rational_power

    if domain.is_subset(S.Reals):
        constrained_interval = domain
        for atom in f.atoms(Pow):
            predicate, denom = _has_rational_power(atom, symbol)
            constraint = S.EmptySet
            if predicate and denom == 2:
                constraint = solve_univariate_inequality(atom.base >= 0,
                                                         symbol).as_set()
                constrained_interval = Intersection(constraint,
                                                    constrained_interval)

        for atom in f.atoms(log):
            constraint = solve_univariate_inequality(atom.args[0] > 0,
                                                     symbol).as_set()
            constrained_interval = Intersection(constraint,
                                                constrained_interval)

        domain = constrained_interval

    try:
        sings = S.EmptySet
        for atom in f.atoms(Pow):
            predicate, denom = _has_rational_power(atom, symbol)
            if predicate and denom == 2:
                sings = solveset(1/f, symbol, domain)
                break
        else:
            sings = Intersection(solveset(1/f, symbol), domain)

    except:
        raise NotImplementedError("Methods for determining the continuous domains"
                                  " of this function has not been developed.")

    return domain - sings
开发者ID:ataber,项目名称:sympy,代码行数:59,代码来源:util.py

示例2: test__has_rational_power

def test__has_rational_power():
    from sympy.solvers.solveset import _has_rational_power
    assert _has_rational_power(sqrt(2), x)[0] is False
    assert _has_rational_power(x*sqrt(2), x)[0] is False

    assert _has_rational_power(x**2*sqrt(x), x) == (True, 2)
    assert _has_rational_power(sqrt(2)*x**(S(1)/3), x) == (True, 3)
    assert _has_rational_power(sqrt(x)*x**(S(1)/3), x) == (True, 6)
开发者ID:nickle8424,项目名称:sympy,代码行数:8,代码来源:test_solveset.py

示例3: test_improve_coverage

def test_improve_coverage():
    from sympy.solvers.solveset import _has_rational_power
    x = Symbol('x', real=True)
    y = exp(x+1/x**2)
    raises(NotImplementedError, lambda: solveset(y**2+y, x))

    assert _has_rational_power(sin(x)*exp(x) + 1, x) == (False, S.One)
    assert _has_rational_power((sin(x)**2)*(exp(x) + 1)**3, x) == (False, S.One)
开发者ID:ChaliZhg,项目名称:sympy,代码行数:8,代码来源:test_solveset.py

示例4: test_improve_coverage

def test_improve_coverage():
    from sympy.solvers.solveset import _has_rational_power
    x = Symbol('x')
    y = exp(x+1/x**2)
    solution = solveset(y**2+y, x, S.Reals)
    unsolved_object = ConditionSet(x, Eq((exp((x**3 + 1)/x**2) + 1)*exp((x**3 + 1)/x**2), 0), S.Reals)
    assert solution == unsolved_object

    assert _has_rational_power(sin(x)*exp(x) + 1, x) == (False, S.One)
    assert _has_rational_power((sin(x)**2)*(exp(x) + 1)**3, x) == (False, S.One)
开发者ID:nickle8424,项目名称:sympy,代码行数:10,代码来源:test_solveset.py

示例5: continuous_domain

def continuous_domain(f, symbol, domain):
    """
    Returns the intervals in the given domain for which the function
    is continuous.
    This method is limited by the ability to determine the various
    singularities and discontinuities of the given function.

    Parameters
    ==========

    f : Expr
        The concerned function.
    symbol : Symbol
        The variable for which the intervals are to be determined.
    domain : Interval
        The domain over which the continuity of the symbol has to be checked.

    Examples
    ========

    >>> from sympy import Symbol, S, tan, log, pi, sqrt
    >>> from sympy.sets import Interval
    >>> from sympy.calculus.util import continuous_domain
    >>> x = Symbol('x')
    >>> continuous_domain(1/x, x, S.Reals)
    Union(Interval.open(-oo, 0), Interval.open(0, oo))
    >>> continuous_domain(tan(x), x, Interval(0, pi))
    Union(Interval.Ropen(0, pi/2), Interval.Lopen(pi/2, pi))
    >>> continuous_domain(sqrt(x - 2), x, Interval(-5, 5))
    Interval(2, 5)
    >>> continuous_domain(log(2*x - 1), x, S.Reals)
    Interval.open(1/2, oo)

    Returns
    =======

    Interval
        Union of all intervals where the function is continuous.

    Raises
    ======
    NotImplementedError
        If the method to determine continuity of such a function
        has not yet been developed.

    """
    from sympy.solvers.inequalities import solve_univariate_inequality
    from sympy.solvers.solveset import solveset, _has_rational_power

    if domain.is_subset(S.Reals):
        constrained_interval = domain
        for atom in f.atoms(Pow):
            predicate, denomin = _has_rational_power(atom, symbol)
            constraint = S.EmptySet
            if predicate and denomin == 2:
                constraint = solve_univariate_inequality(atom.base >= 0,
                                                         symbol).as_set()
                constrained_interval = Intersection(constraint,
                                                    constrained_interval)

        for atom in f.atoms(log):
            constraint = solve_univariate_inequality(atom.args[0] > 0,
                                                     symbol).as_set()
            constrained_interval = Intersection(constraint,
                                                constrained_interval)

        domain = constrained_interval

    try:
        sings = S.EmptySet
        if f.has(Abs):
            sings = solveset(1/f, symbol, domain) + \
                solveset(denom(together(f)), symbol, domain)
        else:
            for atom in f.atoms(Pow):
                predicate, denomin = _has_rational_power(atom, symbol)
                if predicate and denomin == 2:
                    sings = solveset(1/f, symbol, domain) +\
                        solveset(denom(together(f)), symbol, domain)
                    break
            else:
                sings = Intersection(solveset(1/f, symbol), domain) + \
                    solveset(denom(together(f)), symbol, domain)

    except NotImplementedError:
        import sys
        raise (NotImplementedError("Methods for determining the continuous domains"
                                   " of this function have not been developed."),
               None,
               sys.exc_info()[2])

    return domain - sings
开发者ID:gamechanger98,项目名称:sympy,代码行数:92,代码来源:util.py


注:本文中的sympy.solvers.solveset._has_rational_power函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。