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


Python solveset.solveset_real函数代码示例

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


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

示例1: test_garbage_input

def test_garbage_input():
    raises(ValueError, lambda: solveset_real([x], x))
    raises(ValueError, lambda: solveset_real(x, pi))
    raises(ValueError, lambda: solveset_real(x, x ** 2))

    raises(ValueError, lambda: solveset_complex([x], x))
    raises(ValueError, lambda: solveset_complex(x, pi))
开发者ID:LuckyStrikes1090,项目名称:sympy,代码行数:7,代码来源:test_solveset.py

示例2: test_solve_rational

def test_solve_rational():
    assert solveset_real(1/x + 1, x) == FiniteSet(-S.One)
    assert solveset_real(1/exp(x) - 1, x) == FiniteSet(0)
    assert solveset_real(x*(1 - 5/x), x) == FiniteSet(5)
    assert solveset_real(2*x/(x + 2) - 1, x) == FiniteSet(2)
    assert solveset_real((x**2/(7 - x)).diff(x), x) == \
        FiniteSet(S(0), S(14))
开发者ID:nickle8424,项目名称:sympy,代码行数:7,代码来源:test_solveset.py

示例3: test_solve_trig

def test_solve_trig():
    from sympy.abc import n

    assert solveset_real(sin(x), x) == Union(
        imageset(Lambda(n, 2 * pi * n), S.Integers), imageset(Lambda(n, 2 * pi * n + pi), S.Integers)
    )

    assert solveset_real(sin(x) - 1, x) == imageset(Lambda(n, 2 * pi * n + pi / 2), S.Integers)

    assert solveset_real(cos(x), x) == Union(
        imageset(Lambda(n, 2 * pi * n - pi / 2), S.Integers), imageset(Lambda(n, 2 * pi * n + pi / 2), S.Integers)
    )

    assert solveset_real(sin(x) + cos(x), x) == Union(
        imageset(Lambda(n, 2 * n * pi - pi / 4), S.Integers), imageset(Lambda(n, 2 * n * pi + 3 * pi / 4), S.Integers)
    )

    assert solveset_real(sin(x) ** 2 + cos(x) ** 2, x) == S.EmptySet

    assert solveset_complex(cos(x) - S.Half, x) == Union(
        imageset(Lambda(n, 2 * n * pi + pi / 3), S.Integers), imageset(Lambda(n, 2 * n * pi - pi / 3), S.Integers)
    )

    y, a = symbols("y,a")
    assert solveset(sin(y + a) - sin(y), a, domain=S.Reals) == Union(
        imageset(Lambda(n, 2 * n * pi), S.Integers),
        imageset(Lambda(n, -I * (I * (2 * n * pi + arg(-exp(-2 * I * y))) + 2 * im(y))), S.Integers),
    )
开发者ID:pabloferz,项目名称:sympy,代码行数:28,代码来源:test_solveset.py

示例4: test_uselogcombine_1

def test_uselogcombine_1():
    assert solveset_real(log(x - 3) + log(x + 3), x) == \
        FiniteSet(sqrt(10))
    assert solveset_real(log(x + 1) - log(2*x - 1), x) == FiniteSet(2)
    assert solveset_real(log(x + 3) + log(1 + 3/x) - 3) == FiniteSet(
        -3 + sqrt(-12 + exp(3))*exp(S(3)/2)/2 + exp(3)/2,
        -sqrt(-12 + exp(3))*exp(S(3)/2)/2 - 3 + exp(3)/2)
开发者ID:nickle8424,项目名称:sympy,代码行数:7,代码来源:test_solveset.py

示例5: test_solve_abs

def test_solve_abs():
    assert solveset_real(Abs(x) - 2, x) == FiniteSet(-2, 2)
    assert solveset_real(Abs(x + 3) - 2*Abs(x - 3), x) == \
        FiniteSet(1, 9)
    assert solveset_real(2*Abs(x) - Abs(x - 1), x) == \
        FiniteSet(-1, Rational(1, 3))

    assert solveset_real(Abs(x - 7) - 8, x) == FiniteSet(-S(1), S(15))
开发者ID:ChaliZhg,项目名称:sympy,代码行数:8,代码来源:test_solveset.py

示例6: test_solve_trig_simplified

def test_solve_trig_simplified():
    from sympy.abc import n

    assert solveset_real(sin(x), x) == imageset(Lambda(n, n * pi), S.Integers)

    assert solveset_real(cos(x), x) == imageset(Lambda(n, n * pi + pi / 2), S.Integers)

    assert solveset_real(cos(x) + sin(x), x) == imageset(Lambda(n, n * pi - pi / 4), S.Integers)
开发者ID:LuckyStrikes1090,项目名称:sympy,代码行数:8,代码来源:test_solveset.py

示例7: test_errorinverses

def test_errorinverses():
    assert solveset_real(erf(x) - S.One/2, x) == \
        FiniteSet(erfinv(S.One/2))
    assert solveset_real(erfinv(x) - 2, x) == \
        FiniteSet(erf(2))
    assert solveset_real(erfc(x) - S.One, x) == \
        FiniteSet(erfcinv(S.One))
    assert solveset_real(erfcinv(x) - 2, x) == FiniteSet(erfc(2))
开发者ID:nickle8424,项目名称:sympy,代码行数:8,代码来源:test_solveset.py

示例8: test_piecewise

def test_piecewise():
    eq = Piecewise((x - 2, Gt(x, 2)), (2 - x, True)) - 3
    f = Piecewise(((x - 2) ** 2, x >= 0), (0, True))
    assert set(solveset_real(eq, x)) == set(FiniteSet(-1, 5))
    absxm3 = Piecewise((x - 3, S(0) <= x - 3), (3 - x, S(0) > x - 3))
    y = Symbol("y", positive=True)
    assert solveset_real(absxm3 - y, x) == FiniteSet(-y + 3, y + 3)
    assert solveset(f, x, domain=S.Reals) == Union(FiniteSet(2), Interval(-oo, 0, True, True))
开发者ID:JackWangCUMT,项目名称:sympy,代码行数:8,代码来源:test_solveset.py

示例9: test_piecewise

def test_piecewise():
    eq = Piecewise((x - 2, Gt(x, 2)), (2 - x, True)) - 3
    assert set(solveset_real(eq, x)) == set(FiniteSet(-1, 5))
    absxm3 = Piecewise(
        (x - 3, S(0) <= x - 3),
        (3 - x, S(0) > x - 3)
    )
    y = Symbol('y', positive=True)
    assert solveset_real(absxm3 - y, x) == FiniteSet(-y + 3, y + 3)
开发者ID:ChaliZhg,项目名称:sympy,代码行数:9,代码来源:test_solveset.py

示例10: test_solve_polynomial_cv_1a

def test_solve_polynomial_cv_1a():
    """
    Test for solving on equations that can be converted to
    a polynomial equation using the change of variable y -> x**Rational(p, q)
    """
    assert solveset_real(sqrt(x) - 1, x) == FiniteSet(1)
    assert solveset_real(sqrt(x) - 2, x) == FiniteSet(4)
    assert solveset_real(x ** Rational(1, 4) - 2, x) == FiniteSet(16)
    assert solveset_real(x ** Rational(1, 3) - 3, x) == FiniteSet(27)
    assert solveset_real(x * (x ** (S(1) / 3) - 3), x) == FiniteSet(S(0), S(27))
开发者ID:LuckyStrikes1090,项目名称:sympy,代码行数:10,代码来源:test_solveset.py

示例11: test_solve_sqrt_3

def test_solve_sqrt_3():
    R = Symbol("R")
    eq = sqrt(2) * R * sqrt(1 / (R + 1)) + (R + 1) * (sqrt(2) * sqrt(1 / (R + 1)) - 1)
    sol = solveset_complex(eq, R)

    assert sol == FiniteSet(
        *[
            S(5) / 3 + 4 * sqrt(10) * cos(atan(3 * sqrt(111) / 251) / 3) / 3,
            -sqrt(10) * cos(atan(3 * sqrt(111) / 251) / 3) / 3
            + 40 * re(1 / ((-S(1) / 2 - sqrt(3) * I / 2) * (S(251) / 27 + sqrt(111) * I / 9) ** (S(1) / 3))) / 9
            + sqrt(30) * sin(atan(3 * sqrt(111) / 251) / 3) / 3
            + S(5) / 3
            + I
            * (
                -sqrt(30) * cos(atan(3 * sqrt(111) / 251) / 3) / 3
                - sqrt(10) * sin(atan(3 * sqrt(111) / 251) / 3) / 3
                + 40 * im(1 / ((-S(1) / 2 - sqrt(3) * I / 2) * (S(251) / 27 + sqrt(111) * I / 9) ** (S(1) / 3))) / 9
            ),
        ]
    )

    # the number of real roots will depend on the value of m: for m=1 there are 4
    # and for m=-1 there are none.
    eq = -sqrt((m - q) ** 2 + (-m / (2 * q) + S(1) / 2) ** 2) + sqrt(
        (-m ** 2 / 2 - sqrt(4 * m ** 4 - 4 * m ** 2 + 8 * m + 1) / 4 - S(1) / 4) ** 2
        + (m ** 2 / 2 - m - sqrt(4 * m ** 4 - 4 * m ** 2 + 8 * m + 1) / 4 - S(1) / 4) ** 2
    )
    raises(NotImplementedError, lambda: solveset_real(eq, q))
开发者ID:LuckyStrikes1090,项目名称:sympy,代码行数:28,代码来源:test_solveset.py

示例12: test_solve_polynomial

def test_solve_polynomial():
    assert solveset_real(3 * x - 2, x) == FiniteSet(Rational(2, 3))

    assert solveset_real(x ** 2 - 1, x) == FiniteSet(-S(1), S(1))
    assert solveset_real(x - y ** 3, x) == FiniteSet(y ** 3)

    a11, a12, a21, a22, b1, b2 = symbols("a11, a12, a21, a22, b1, b2")

    assert solveset_real(x ** 3 - 15 * x - 4, x) == FiniteSet(-2 + 3 ** Rational(1, 2), S(4), -2 - 3 ** Rational(1, 2))

    assert solveset_real(sqrt(x) - 1, x) == FiniteSet(1)
    assert solveset_real(sqrt(x) - 2, x) == FiniteSet(4)
    assert solveset_real(x ** Rational(1, 4) - 2, x) == FiniteSet(16)
    assert solveset_real(x ** Rational(1, 3) - 3, x) == FiniteSet(27)
    assert len(solveset_real(x ** 5 + x ** 3 + 1, x)) == 1
    assert len(solveset_real(-2 * x ** 3 + 4 * x ** 2 - 2 * x + 6, x)) > 0
开发者ID:LuckyStrikes1090,项目名称:sympy,代码行数:16,代码来源:test_solveset.py

示例13: test_rewrite_trigh

def test_rewrite_trigh():
    # if this import passes then the test below should also pass
    from sympy import sech
    assert solveset_real(sinh(x) + sech(x), x) == FiniteSet(
        2*atanh(-S.Half + sqrt(5)/2 - sqrt(-2*sqrt(5) + 2)/2),
        2*atanh(-S.Half + sqrt(5)/2 + sqrt(-2*sqrt(5) + 2)/2),
        2*atanh(-sqrt(5)/2 - S.Half + sqrt(2 + 2*sqrt(5))/2),
        2*atanh(-sqrt(2 + 2*sqrt(5))/2 - sqrt(5)/2 - S.Half))
开发者ID:nickle8424,项目名称:sympy,代码行数:8,代码来源:test_solveset.py

示例14: test_solve_abs

def test_solve_abs():
    assert solveset_real(Abs(x) - 2, x) == FiniteSet(-2, 2)
    assert solveset_real(Abs(x + 3) - 2 * Abs(x - 3), x) == FiniteSet(1, 9)
    assert solveset_real(2 * Abs(x) - Abs(x - 1), x) == FiniteSet(-1, Rational(1, 3))

    assert solveset_real(Abs(x - 7) - 8, x) == FiniteSet(-S(1), S(15))

    # issue 9565. Note: solveset_real does not solve this as it is
    # solveset's job to handle Relationals
    assert solveset(Abs((x - 1) / (x - 5)) <= S(1) / 3, domain=S.Reals) == Interval(-1, 2)

    # issue #10069
    eq = abs(1 / (x - 1)) - 1 > 0
    u = Union(Interval.open(0, 1), Interval.open(1, 2))
    assert solveset_real(eq, x) == u
    assert solveset(eq, x, domain=S.Reals) == u

    raises(ValueError, lambda: solveset(abs(x) - 1, x))
开发者ID:pabloferz,项目名称:sympy,代码行数:18,代码来源:test_solveset.py

示例15: test_solve_trig

def test_solve_trig():
    from sympy.abc import n
    assert solveset_real(sin(x), x) == \
        Union(imageset(Lambda(n, 2*pi*n), S.Integers),
              imageset(Lambda(n, 2*pi*n + pi), S.Integers))

    assert solveset_real(sin(x) - 1, x) == \
        imageset(Lambda(n, 2*pi*n + pi/2), S.Integers)

    assert solveset_real(cos(x), x) == \
        Union(imageset(Lambda(n, 2*pi*n - pi/2), S.Integers),
              imageset(Lambda(n, 2*pi*n + pi/2), S.Integers))

    assert solveset_real(sin(x) + cos(x), x) == \
        Union(imageset(Lambda(n, 2*n*pi - pi/4), S.Integers),
              imageset(Lambda(n, 2*n*pi + 3*pi/4), S.Integers))

    assert solveset_real(sin(x)**2 + cos(x)**2, x) == S.EmptySet
开发者ID:nickle8424,项目名称:sympy,代码行数:18,代码来源:test_solveset.py


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