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


Python inequalities.reduce_inequalities函数代码示例

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


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

示例1: test_issue_5526

def test_issue_5526():
    assert reduce_inequalities(S(0) <= x + Integral(y**2, (y, 1, 3)) - 1, True, [x]) == \
        (-Integral(y**2, (y, 1, 3)) + 1 <= x)
    f = Function('f')
    e = Sum(f(x), (x, 1, 3))
    assert reduce_inequalities(S(0) <= x + e + y**2, True, [x]) == \
        (-y**2 - Sum(f(x), (x, 1, 3)) <= x)
开发者ID:aiwku1277,项目名称:sympy,代码行数:7,代码来源:test_inequalities.py

示例2: test_reduce_inequalities_errors

def test_reduce_inequalities_errors():
    x = Symbol('x')
    y = Symbol('y')

    raises(NotImplementedError, lambda: reduce_inequalities(Ge(sin(x) + x, 1)))
    raises(NotImplementedError, lambda: reduce_inequalities(Ge(x**2*y + y, 1)))
    raises(NotImplementedError, lambda: reduce_inequalities(Ge(sqrt(2)*x, 1)))
开发者ID:Devendra0910,项目名称:sympy,代码行数:7,代码来源:test_inequalities.py

示例3: test_reduce_abs_inequalities

def test_reduce_abs_inequalities():
    real = Q.real(x)

    assert reduce_inequalities(abs(x - 5) < 3, assume=real) == And(Gt(x, 2), Lt(x, 8))
    assert reduce_inequalities(abs(2*x + 3) >= 8, assume=real) == Or(Le(x, -S(11)/2), Ge(x, S(5)/2))
    assert reduce_inequalities(abs(x - 4) + abs(3*x - 5) < 7, assume=real) == And(Gt(x, S(1)/2), Lt(x, 4))
    assert reduce_inequalities(abs(x - 4) + abs(3*abs(x) - 5) < 7, assume=real) == Or(And(-2 < x, x < -1), And(S(1)/2 < x, x < 4))

    raises(NotImplementedError, "reduce_inequalities(abs(x - 5) < 3)")
开发者ID:ALGHeArT,项目名称:sympy,代码行数:9,代码来源:test_inequalities.py

示例4: test_issue_10198

def test_issue_10198():
    assert reduce_inequalities(
        -1 + 1/abs(1/x - 1) < 0) == Or(
        And(-oo < x, x < 0), And(S(0) < x, x < S(1)/2)
        )
    assert reduce_inequalities(abs(1/sqrt(x)) - 1, x) == Eq(x, 1)
    assert reduce_abs_inequality(-3 + 1/abs(1 - 1/x), '<', x) == \
        Or(And(-oo < x, x < 0),
        And(S(0) < x, x < S(3)/4), And(S(3)/2 < x, x < oo))
    raises(ValueError,lambda: reduce_abs_inequality(-3 + 1/abs(
        1 - 1/sqrt(x)), '<', x))
开发者ID:richardotis,项目名称:sympy,代码行数:11,代码来源:test_inequalities.py

示例5: test_reduce_abs_inequalities

def test_reduce_abs_inequalities():
    real = Q.real(x)

    assert reduce_inequalities(
        abs(x - 5) < 3, assume=real) == And(Lt(2, x), Lt(x, 8))
    assert reduce_inequalities(
        abs(2*x + 3) >= 8, assume=real) == Or(And(Le(S(5)/2, x), Lt(x, oo)), And(Le(x, -S(11)/2), Lt(-oo, x)))
    assert reduce_inequalities(abs(x - 4) + abs(
        3*x - 5) < 7, assume=real) == And(Lt(S(1)/2, x), Lt(x, 4))
    assert reduce_inequalities(abs(x - 4) + abs(3*abs(x) - 5) < 7, assume=real) == Or(And(S(-2) < x, x < -1), And(S(1)/2 < x, x < 4))

    raises(NotImplementedError, lambda: reduce_inequalities(abs(x - 5) < 3))
开发者ID:aiwku1277,项目名称:sympy,代码行数:12,代码来源:test_inequalities.py

示例6: test_reduce_abs_inequalities

def test_reduce_abs_inequalities():
    x = Symbol('x', real=True)

    assert reduce_inequalities(abs(x - 5) < 3) == And(Lt(2, x), Lt(x, 8))
    assert reduce_inequalities(
        abs(2*x + 3) >= 8) == Or(And(Le(S(5)/2, x), Lt(x, oo)), And(Le(x, -S(11)/2), Lt(-oo, x)))
    assert reduce_inequalities(abs(x - 4) + abs(
        3*x - 5) < 7) == And(Lt(S(1)/2, x), Lt(x, 4))
    assert reduce_inequalities(abs(x - 4) + abs(3*abs(x) - 5) < 7) == \
        Or(And(S(-2) < x, x < -1), And(S(1)/2 < x, x < 4))

    x = Symbol('x')
    raises(NotImplementedError, lambda: reduce_inequalities(abs(x - 5) < 3))
开发者ID:Devendra0910,项目名称:sympy,代码行数:13,代码来源:test_inequalities.py

示例7: test_issue_8235

def test_issue_8235():
    x = Symbol('x', real=True)
    assert reduce_inequalities(x**2 - 1 < 0) == \
        And(S(-1) < x, x < S(1))
    assert reduce_inequalities(x**2 - 1 <= 0) == \
        And(S(-1) <= x, x <= 1)
    assert reduce_inequalities(x**2 - 1 > 0) == \
        Or(And(-oo < x, x < -1), And(x < oo, S(1) < x))
    assert reduce_inequalities(x**2 - 1 >= 0) == \
        Or(And(-oo < x, x <= S(-1)), And(S(1) <= x, x < oo))

    eq = x**8 + x**2 - 9
    sol = solve(eq >= 0)
    known_sol = Or(And(-oo < x, RootOf(x**8 + x**2 - 9, 1) <= x, x < oo), \
            And(-oo < x, x < oo, x <= RootOf(x**8 + x**2 - 9, 0)))
    assert sol == known_sol
开发者ID:Devendra0910,项目名称:sympy,代码行数:16,代码来源:test_inequalities.py

示例8: test_issue_8545

def test_issue_8545():
    from sympy import refine
    eq = 1 - x - abs(1 - x)
    ans = And(Lt(1, x), Lt(x, oo))
    assert reduce_abs_inequality(eq, '<', x) == ans
    eq = 1 - x - sqrt((1 - x)**2)
    assert reduce_inequalities(refine(eq) < 0) == ans
开发者ID:GolimarOurHero,项目名称:sympy,代码行数:7,代码来源:test_inequalities.py

示例9: test_issue_8235

def test_issue_8235():
    assert reduce_inequalities(x**2 - 1 < 0) == \
        And(S(-1) < x, x < S(1))
    assert reduce_inequalities(x**2 - 1 <= 0) == \
        And(S(-1) <= x, x <= 1)
    assert reduce_inequalities(x**2 - 1 > 0) == \
        Or(And(-oo < x, x < -1), And(x < oo, S(1) < x))
    assert reduce_inequalities(x**2 - 1 >= 0) == \
        Or(And(-oo < x, x <= S(-1)), And(S(1) <= x, x < oo))

    eq = x**8 + x - 9  # we want CRootOf solns here
    sol = solve(eq >= 0)
    tru = Or(And(rootof(eq, 1) <= x, x < oo), And(-oo < x, x <= rootof(eq, 0)))
    assert sol == tru

    # recast vanilla as real
    assert solve(sqrt((-x + 1)**2) < 1) == And(S(0) < x, x < 2)
开发者ID:richardotis,项目名称:sympy,代码行数:17,代码来源:test_inequalities.py

示例10: test_reduce_inequalities_multivariate

def test_reduce_inequalities_multivariate():
    x = Symbol('x')
    y = Symbol('y')

    assert reduce_inequalities([Ge(x**2, 1), Ge(y**2, 1)]) == \
        And(Eq(im(x), 0), Eq(im(y), 0), Or(And(Le(1, re(x)), Lt(re(x), oo)),
                                           And(Le(re(x), -1), Lt(-oo, re(x)))),
            Or(And(Le(1, re(y)), Lt(re(y), oo)), And(Le(re(y), -1), Lt(-oo, re(y)))))
开发者ID:Devendra0910,项目名称:sympy,代码行数:8,代码来源:test_inequalities.py

示例11: test_reduce_abs_inequalities

def test_reduce_abs_inequalities():
    e = abs(x - 5) < 3
    ans = And(Lt(2, x), Lt(x, 8))
    assert reduce_inequalities(e) == ans
    assert reduce_inequalities(e, x) == ans
    assert reduce_inequalities(abs(x - 5)) == Eq(x, 5)
    assert reduce_inequalities(
        abs(2*x + 3) >= 8) == Or(And(Le(S(5)/2, x), Lt(x, oo)),
        And(Le(x, -S(11)/2), Lt(-oo, x)))
    assert reduce_inequalities(abs(x - 4) + abs(
        3*x - 5) < 7) == And(Lt(S(1)/2, x), Lt(x, 4))
    assert reduce_inequalities(abs(x - 4) + abs(3*abs(x) - 5) < 7) == \
        Or(And(S(-2) < x, x < -1), And(S(1)/2 < x, x < 4))

    nr = Symbol('nr', real=False)
    raises(TypeError, lambda: reduce_inequalities(abs(nr - 5) < 3))
    assert reduce_inequalities(x < 3, symbols=[x, nr]) == And(-oo < x, x < 3)
开发者ID:richardotis,项目名称:sympy,代码行数:17,代码来源:test_inequalities.py

示例12: test_hacky_inequalities

def test_hacky_inequalities():
    assert reduce_inequalities(x + y < 1, symbols=[x]) == (x < 1 - y)
    assert reduce_inequalities(x + y >= 1, symbols=[x]) == (x >= 1 - y)
    assert reduce_inequalities(Eq(0, x - y), symbols=[x]) == Eq(x, y)
    assert reduce_inequalities(Ne(0, x - y), symbols=[x]) == Ne(x, y)
开发者ID:richardotis,项目名称:sympy,代码行数:5,代码来源:test_inequalities.py

示例13: test_reduce_inequalities_errors

def test_reduce_inequalities_errors():
    raises(NotImplementedError, lambda: reduce_inequalities(Ge(sin(x) + x, 1)))
    raises(NotImplementedError, lambda: reduce_inequalities(Ge(x**2*y + y, 1)))
开发者ID:richardotis,项目名称:sympy,代码行数:3,代码来源:test_inequalities.py

示例14: test_reduce_inequalities_multivariate

def test_reduce_inequalities_multivariate():
    assert reduce_inequalities([Ge(x**2, 1), Ge(y**2, 1)]) == And(
        Or(And(Le(1, x), Lt(x, oo)), And(Le(x, -1), Lt(-oo, x))),
        Or(And(Le(1, y), Lt(y, oo)), And(Le(y, -1), Lt(-oo, y))))
开发者ID:richardotis,项目名称:sympy,代码行数:4,代码来源:test_inequalities.py

示例15: test_reduce_inequalities_boolean

def test_reduce_inequalities_boolean():
    assert reduce_inequalities(
        [Eq(x**2, 0), True]) == Eq(x, 0)
    assert reduce_inequalities([Eq(x**2, 0), False]) == False
    assert reduce_inequalities(x**2 >= 0) is S.true  # issue 10196
开发者ID:richardotis,项目名称:sympy,代码行数:5,代码来源:test_inequalities.py


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