コード例 #1
0
ファイル: test_simplify.py プロジェクト: cbm755/diofant
def test_sympyissue_9398():
    assert cancel(1e-14) != 0
    assert cancel(1e-14 * I) != 0

    assert simplify(1e-14) != 0
    assert simplify(1e-14 * I) != 0

    assert (I * Number(1.) * Number(10)**Number(-14)).simplify() != 0

    assert cancel(1e-20) != 0
    assert cancel(1e-20 * I) != 0

    assert simplify(1e-20) != 0
    assert simplify(1e-20 * I) != 0

    assert cancel(1e-100) != 0
    assert cancel(1e-100 * I) != 0

    assert simplify(1e-100) != 0
    assert simplify(1e-100 * I) != 0

    f = Float("1e-1000", 15)
    assert cancel(f) != 0
    assert cancel(f * I) != 0

    assert simplify(f) != 0
    assert simplify(f * I) != 0
コード例 #2
0
def test_sympyissue_3449():
    # test if powers are simplified correctly
    # see also issue sympy/sympy#3995
    assert cbrt(x)**2 == x**Rational(2, 3)
    assert (x**3)**Rational(2, 5) == Pow(x**3, Rational(2, 5), evaluate=False)

    a = Symbol('a', extended_real=True)
    b = Symbol('b', extended_real=True)
    assert (a**2)**b == (abs(a)**b)**2
    assert sqrt(1 / a) != 1 / sqrt(a)  # e.g. for a = -1
    assert cbrt(a**3) != a
    assert (x**a)**b != x**(a * b)  # e.g. x = -1, a=2, b=1/2
    assert (x**.5)**b == x**(.5 * b)
    assert (x**.5)**.5 == x**.25
    assert (x**2.5)**.5 != x**1.25  # e.g. for x = 5*I

    k = Symbol('k', integer=True)
    m = Symbol('m', integer=True)
    assert (x**k)**m == x**(k * m)
    assert Number(5)**Rational(2, 3) == cbrt(Number(25))

    assert (x**.5)**2 == x**1.0
    assert (x**2)**k == (x**k)**2 == x**(2 * k)

    a = Symbol('a', positive=True)
    assert (a**3)**Rational(2, 5) == a**Rational(6, 5)
    assert (a**2)**b == (a**b)**2
    assert (a**Rational(2, 3))**x == (a**(2 * x / 3)) != (a**x)**Rational(2, 3)