Beispiel #1
0
def test_guess_poly_cv():
    x, y = symbols('xy')
    # polynomial equations via a change of variable
    assert guess_solve_strategy( x**Rational(1,2) + 1, x ) == GS_POLY_CV_1
    assert guess_solve_strategy( x**Rational(1,3) + x**Rational(1,2) + 1, x ) == GS_POLY_CV_1
    assert guess_solve_strategy( 4*x*(1 - sqrt(x)), x ) == GS_POLY_CV_1

    # polynomial equation multiplying both sides by x**n
    assert guess_solve_strategy( x + 1/x + y, x ) == GS_POLY_CV_2
Beispiel #2
0
def test_guess_rational_cv():
    # rational functions
    x, y = symbols('xy')
    assert guess_solve_strategy( (x+1)/(x**2 + 2), x) == GS_RATIONAL
    assert guess_solve_strategy( (x - y**3)/(y**2*(1 - y**2)**(S(1)/2)), y) == GS_RATIONAL_CV_1

    # rational functions via the change of variable y -> x**n
    assert guess_solve_strategy( (x**Rational(1,2) + 1)/(x**Rational(1,3) + x**Rational(1,2) + 1), x ) \
                                == GS_RATIONAL_CV_1
Beispiel #3
0
def test_guess_rational_cv():
    # rational functions
    x, y = symbols('xy')
    assert guess_solve_strategy( (x+1)/(x**2 + 2), x) == GS_RATIONAL
    assert guess_solve_strategy( (x - y**3)/(y**2*(1 - y**2)**(S(1)/2)), y) == GS_RATIONAL_CV_1

    # rational functions via the change of variable y -> x**n
    assert guess_solve_strategy( (x**Rational(1,2) + 1)/(x**Rational(1,3) + x**Rational(1,2) + 1), x ) \
                                == GS_RATIONAL_CV_1
Beispiel #4
0
def test_guess_poly_cv():
    x, y = symbols('xy')
    # polynomial equations via a change of variable
    assert guess_solve_strategy( x**Rational(1,2) + 1, x ) == GS_POLY_CV_1
    assert guess_solve_strategy( x**Rational(1,3) + x**Rational(1,2) + 1, x ) == GS_POLY_CV_1
    assert guess_solve_strategy( 4*x*(1 - sqrt(x)), x ) == GS_POLY_CV_1

    # polynomial equation multiplying both sides by x**n
    assert guess_solve_strategy( x + 1/x + y, x ) == GS_POLY_CV_2
Beispiel #5
0
def test_guess_transcendental():
    x, y, a, b = symbols('xyab')
    #transcendental functions
    assert guess_solve_strategy( exp(x) + 1, x ) == GS_TRANSCENDENTAL
    assert guess_solve_strategy( 2*cos(x)-y, x ) == GS_TRANSCENDENTAL
    assert guess_solve_strategy( exp(x) + exp(-x) - y, x ) == GS_TRANSCENDENTAL
    assert guess_solve_strategy(3**x-10, x) == GS_TRANSCENDENTAL
    assert guess_solve_strategy(-3**x+10, x) == GS_TRANSCENDENTAL

    assert guess_solve_strategy(a*x**b-y, x) == GS_TRANSCENDENTAL
Beispiel #6
0
def test_guess_transcendental():
    x, y, a, b = symbols('x,y,a,b')
    #transcendental functions
    assert guess_solve_strategy(exp(x) + 1, x) == GS_TRANSCENDENTAL
    assert guess_solve_strategy(2 * cos(x) - y, x) == GS_TRANSCENDENTAL
    assert guess_solve_strategy(exp(x) + exp(-x) - y, x) == GS_TRANSCENDENTAL
    assert guess_solve_strategy(3**x - 10, x) == GS_TRANSCENDENTAL
    assert guess_solve_strategy(-3**x + 10, x) == GS_TRANSCENDENTAL

    assert guess_solve_strategy(a * x**b - y, x) == GS_TRANSCENDENTAL
Beispiel #7
0
def test_guess_poly():
    """
    See solvers.guess_solve_strategy
    """
    x, y, a = symbols('xya')

    # polynomial equations
    assert guess_solve_strategy( S(4), x ) == GS_POLY
    assert guess_solve_strategy( x, x ) == GS_POLY
    assert guess_solve_strategy( x + a, x ) == GS_POLY
    assert guess_solve_strategy( 2*x, x ) == GS_POLY
    assert guess_solve_strategy( x + sqrt(2), x) == GS_POLY
    assert guess_solve_strategy( x + 2**Rational(1,4), x) == GS_POLY
    assert guess_solve_strategy( x**2 + 1, x ) == GS_POLY
    assert guess_solve_strategy( x**2 - 1, x ) == GS_POLY
    assert guess_solve_strategy( x*y + y, x ) == GS_POLY
    assert guess_solve_strategy( x*exp(y) + y, x) == GS_POLY
    assert guess_solve_strategy( (x - y**3)/(y**2*(1 - y**2)**(S(1)/2)), x) == GS_POLY
Beispiel #8
0
def test_guess_poly():
    """
    See solvers.guess_solve_strategy
    """
    x, y, a = symbols('x,y,a')

    # polynomial equations
    assert guess_solve_strategy(S(4), x) == GS_POLY
    assert guess_solve_strategy(x, x) == GS_POLY
    assert guess_solve_strategy(x + a, x) == GS_POLY
    assert guess_solve_strategy(2 * x, x) == GS_POLY
    assert guess_solve_strategy(x + sqrt(2), x) == GS_POLY
    assert guess_solve_strategy(x + 2**Rational(1, 4), x) == GS_POLY
    assert guess_solve_strategy(x**2 + 1, x) == GS_POLY
    assert guess_solve_strategy(x**2 - 1, x) == GS_POLY
    assert guess_solve_strategy(x * y + y, x) == GS_POLY
    assert guess_solve_strategy(x * exp(y) + y, x) == GS_POLY
    assert guess_solve_strategy((x - y**3) / (y**2 * (1 - y**2)**(S(1) / 2)),
                                x) == GS_POLY
Beispiel #9
0
def test_guess_strategy():
    """
    See solvers._guess_solve_strategy
    """
    x, y = symbols('xy')

    # polynomial equations
    assert guess_solve_strategy( S(4), x ) == GS_POLY
    assert guess_solve_strategy( x, x ) == GS_POLY
    assert guess_solve_strategy( 2*x, x ) == GS_POLY
    assert guess_solve_strategy( x + sqrt(2), x) == GS_POLY
    assert guess_solve_strategy( x + 2**Rational(1,4), x) == GS_POLY
    assert guess_solve_strategy( x**2 + 1, x ) == GS_POLY
    assert guess_solve_strategy( x**2 - 1, x ) == GS_POLY
    assert guess_solve_strategy( x*y + y, x ) == GS_POLY
    assert guess_solve_strategy( x*exp(y) + y, x) == GS_POLY
    assert guess_solve_strategy( (x - y**3)/(y**2*(1 - y**2)**(S(1)/2)), x) == GS_POLY

    # polynomial equations via a change of variable
    assert guess_solve_strategy( x**Rational(1,2) + 1, x ) == GS_POLY_CV_1
    assert guess_solve_strategy( x**Rational(1,3) + x**Rational(1,2) + 1, x ) == GS_POLY_CV_1
    assert guess_solve_strategy( 4*x*(1 - sqrt(x)), x ) == GS_POLY_CV_1

    # polynomial equation multiplying both sides by x**n
    assert guess_solve_strategy( x + 1/x + y, x )

    # rational functions
    assert guess_solve_strategy( (x+1)/(x**2 + 2), x) == GS_RATIONAL
    assert guess_solve_strategy( (x - y**3)/(y**2*(1 - y**2)**(S(1)/2)), y) == GS_RATIONAL_CV_1

    # rational functions via the change of variable y -> x**n
    assert guess_solve_strategy( (x**Rational(1,2) + 1)/(x**Rational(1,3) + x**Rational(1,2) + 1), x ) \
                                == GS_RATIONAL_CV_1

    #trascendental functions
    assert guess_solve_strategy( exp(x) + 1, x ) == GS_TRASCENDENTAL
    assert guess_solve_strategy( 2*cos(x)-y, x ) == GS_TRASCENDENTAL
    assert guess_solve_strategy( exp(x) + exp(-x) - y, x ) == GS_TRASCENDENTAL
Beispiel #10
0
def test_guess_strategy():
    """
    See solvers._guess_solve_strategy
    """
    x, y = symbols('xy')

    # polynomial equations
    assert guess_solve_strategy( x, x ) == GS_POLY
    assert guess_solve_strategy( 2*x, x ) == GS_POLY
    assert guess_solve_strategy( x + sqrt(2), x) == GS_POLY
    assert guess_solve_strategy( x + 2**Rational(1,4), x) == GS_POLY
    assert guess_solve_strategy( x**2 + 1, x ) == GS_POLY
    assert guess_solve_strategy( x**2 - 1, x ) == GS_POLY
    assert guess_solve_strategy( x*y + y, x ) == GS_POLY
    assert guess_solve_strategy( x*exp(y) + y, x) == GS_POLY
    assert guess_solve_strategy( (x - y**3)/(y**2*(1 - y**2)**(S(1)/2)), x) == GS_POLY

    # polynomial equations via a change of variable
    assert guess_solve_strategy( x**Rational(1,2) + 1, x ) == GS_POLY_CV_1
    assert guess_solve_strategy( x**Rational(1,3) + x**Rational(1,2) + 1, x ) == GS_POLY_CV_1
    assert guess_solve_strategy( 4*x*(1 - sqrt(x)), x ) == GS_POLY_CV_1

    # polynomial equation multiplying both sides by x**n
    assert guess_solve_strategy( x + 1/x + y, x )

    # rational functions
    assert guess_solve_strategy( (x+1)/(x**2 + 2), x) == GS_RATIONAL
    assert guess_solve_strategy( (x - y**3)/(y**2*(1 - y**2)**(S(1)/2)), y) == GS_RATIONAL_CV_1

    # rational functions via the change of variable y -> x**n
    assert guess_solve_strategy( (x**Rational(1,2) + 1)/(x**Rational(1,3) + x**Rational(1,2) + 1), x ) \
                                == GS_RATIONAL_CV_1

    #trascendental functions
    assert guess_solve_strategy( exp(x) + 1, x ) == GS_TRASCENDENTAL
    assert guess_solve_strategy( 2*cos(x)-y, x ) == GS_TRASCENDENTAL
    assert guess_solve_strategy( exp(x) + exp(-x) - y, x ) == GS_TRASCENDENTAL