示例#1
0
def test_rp_eq2():
    a = RationalPolynomial.from_string("(-4 + x^2)/(x+5)")
    b = RationalPolynomial.from_string("(x^2 - 4)/(7+x)")
    assert a != b
示例#2
0
def test_rp_eq3():
    a = RationalPolynomial.from_string("(-4 + x^2)/(x+5)")
    b = RationalPolynomial.from_string("(-x^2 + 4)/(5+x)")
    assert a == -b
示例#3
0
def test_rp_fromstr2():
    a = RationalPolynomial.from_string("(1+2 *x^2)/- (x+2)")
    b = RationalPolynomial.from_string("  (1+2 *x^2)/(x+2)")
    assert a == (-b) and (-a) == b
示例#4
0
def test_rp_fromstr3():
    a = RationalPolynomial.from_string("-(1 +2*x^2)/( x+2 )")
    b = RationalPolynomial.from_string("(1+2 *x^2)/-(x+2 ) ")
    assert a == b
示例#5
0
def test_rp_div3():
    a = RationalPolynomial.from_string("(x^4+3*x-1)/(-7*x^2+2*x-9)")
    b = RationalPolynomial.from_string("(1+2*x^2)/(x+2)")
    c = RationalPolynomial.from_string(
        "(2*x^6 +x^4+6*x^3+3*x-2*x^2-1)/-(7*x^3+12*x^2+5*x+10)")
    assert a != c / b
示例#6
0
def test_rp_neg():
    a = RationalPolynomial.from_string("1/1")
    b = RationalPolynomial.from_string("(1+2*x^2)/(x+2)")
    c = RationalPolynomial.from_string("(1+2*x^2)/(-1*x - 2)")
    assert (-a) * b == c
示例#7
0
def test_rp_mult2():
    a = Polynomial.from_string("x^4+1")
    b = RationalPolynomial.from_string("(1+2*x^2)/(x+2)")
    assert b == b * (a / a)
示例#8
0
def test_rp_mult():
    a = RationalPolynomial.from_string("(1+2*x^2)/(4*x+8)")
    b = RationalPolynomial.from_string("(1+2*x^2)/(x+2)")
    c = RationalPolynomial.from_string("1/4")
    assert b * c == a
示例#9
0
def test_rp_tozero():
    a = RationalPolynomial.from_string("(1+x)/(x+2)")
    b = RationalPolynomial.from_string("0/1")
    assert (a - a) == b
示例#10
0
def test_rp_subtraction2():
    a = RationalPolynomial.from_string("(1+x)/(x+2)")
    b = RationalPolynomial.from_string("(1*x+17)/(x+4)")
    c = RationalPolynomial.from_string("-2/(8+ 1*x^2+ 6*x)")
    assert a - b != c
示例#11
0
def test_rp_addition2():
    a = RationalPolynomial.from_string("(1+x)/(x+2)")
    b = RationalPolynomial.from_string("(1*x+5)/(x+4)")
    c = RationalPolynomial.from_string("(2*x^ 2 + 10 +10*x)/(8+ 1*x^2+ 6*x)")
    assert a + b != c