Example #1
0
def test_reduce_rational_inequalities_real_relational():
    assert reduce_rational_inequalities([], x) is false
    assert reduce_rational_inequalities(
        [[(x**2 + 3*x + 2)/(x**2 - 16) >= 0]], x, relational=False) == \
        Union(Interval.Ropen(-oo, -4), Interval(-2, -1), Interval.Lopen(4, oo))

    assert reduce_rational_inequalities(
        [[((-2*x - 10)*(3 - x))/((x**2 + 5)*(x - 2)**2) < 0]], x,
        relational=False) == \
        Union(Interval.open(-5, 2), Interval.open(2, 3))

    assert reduce_rational_inequalities([[(x + 1)/(x - 5) <= 0]], x,
                                        relational=False) == \
        Interval.Ropen(-1, 5)

    assert reduce_rational_inequalities([[(x**2 + 4*x + 3)/(x - 1) > 0]], x,
                                        relational=False) == \
        Union(Interval.open(-3, -1), Interval.Lopen(1, oo))

    assert reduce_rational_inequalities([[(x**2 - 16)/(x - 1)**2 < 0]], x,
                                        relational=False) == \
        Union(Interval.open(-4, 1), Interval.open(1, 4))

    assert reduce_rational_inequalities([[(3*x + 1)/(x + 4) >= 1]], x,
                                        relational=False) == \
        Union(Interval.Ropen(-oo, -4), Interval(Rational(3, 2), oo))

    assert reduce_rational_inequalities([[(x - 8)/x <= 3 - x]], x,
                                        relational=False) == \
        Union(Interval(-oo, -2), Interval.Lopen(0, 4))
Example #2
0
def test_reals():
    assert 5 in S.Reals
    assert pi in S.Reals
    assert -sqrt(2) in S.Reals
    assert (2, 5) not in S.Reals
    assert sqrt(-1) not in S.Reals
    assert S.Reals == Interval.open(-oo, oo)
    assert hash(S.Reals) == hash(Interval.open(-oo, oo))
    assert S.ExtendedReals == Interval(-oo, oo)
    assert hash(S.ExtendedReals) == hash(Interval(-oo, oo))