Signed-off-by: Ondrej Certik <ond...@certik.cz>
---
 sympy/solvers/solvers.py            |   44 +++++++++++++++++-----------------
 sympy/solvers/tests/test_solvers.py |   14 +++++++++-
 2 files changed, 34 insertions(+), 24 deletions(-)

diff --git a/sympy/solvers/solvers.py b/sympy/solvers/solvers.py
index c00d372..57bc775 100644
--- a/sympy/solvers/solvers.py
+++ b/sympy/solvers/solvers.py
@@ -183,11 +183,11 @@ def solve(f, *symbols, **flags):
             return solve(P, symbol, **flags)
 
         elif strategy == GS_POLY_CV_1:
-            # we must search for a suitable change of variable
-            # collect exponents
-            exponents_denom = list()
             args = list(f.args)
             if isinstance(f, Add):
+                # we must search for a suitable change of variable
+                # collect exponents
+                exponents_denom = list()
                 for arg in args:
                     if isinstance(arg, Pow):
                         exponents_denom.append(arg.exp.q)
@@ -195,27 +195,27 @@ def solve(f, *symbols, **flags):
                         for mul_arg in arg.args:
                             if isinstance(mul_arg, Pow):
                                 exponents_denom.append(mul_arg.exp.q)
+                assert len(exponents_denom) > 0
+                if len(exponents_denom) == 1:
+                    m = exponents_denom[0]
+                else:
+                    # get the GCD of the denominators
+                    m = ilcm(*exponents_denom)
+                # x -> y**m.
+                # we assume positive for simplification purposes
+                t = Symbol('t', positive=True, dummy=True)
+                f_ = f.subs(symbol, t**m)
+                if guess_solve_strategy(f_, t) != GS_POLY:
+                    raise TypeError("Could not convert to a polynomial 
equation: %s" % f_)
+                cv_sols = solve(f_, t)
+                result = list()
+                for sol in cv_sols:
+                    result.append(sol**(S.One/m))
+
             elif isinstance(f, Mul):
+                result = []
                 for mul_arg in args:
-                    if isinstance(mul_arg, Pow):
-                        exponents_denom.append(mul_arg.exp.q)
-
-            assert len(exponents_denom) > 0
-            if len(exponents_denom) == 1:
-                m = exponents_denom[0]
-            else:
-                # get the GCD of the denominators
-                m = ilcm(*exponents_denom)
-            # x -> y**m.
-            # we assume positive for simplification purposes
-            t = Symbol('t', positive=True, dummy=True)
-            f_ = f.subs(symbol, t**m)
-            if guess_solve_strategy(f_, t) != GS_POLY:
-                raise TypeError("Could not convert to a polynomial equation: 
%s" % f_)
-            cv_sols = solve(f_, t)
-            result = list()
-            for sol in cv_sols:
-                result.append(sol**(S.One/m))
+                    result.extend(solve(mul_arg, symbol))
 
         elif strategy == GS_POLY_CV_2:
             m = 0
diff --git a/sympy/solvers/tests/test_solvers.py 
b/sympy/solvers/tests/test_solvers.py
index 6fab8b3..5f78f8a 100644
--- a/sympy/solvers/tests/test_solvers.py
+++ b/sympy/solvers/tests/test_solvers.py
@@ -48,7 +48,7 @@ def test_guess_strategy():
     assert guess_solve_strategy( 2*cos(x)-y, x ) == GS_TRASCENDENTAL
     assert guess_solve_strategy( exp(x) + exp(-x) - y, x ) == GS_TRASCENDENTAL
 
-def test_solve_polynomial():
+def test_solve_polynomial1():
     x, y = map(Symbol, 'xy')
 
     assert solve(3*x-2, x) == [Rational(2,3)]
@@ -83,7 +83,11 @@ def test_solve_polynomial():
     raises(TypeError, "solve(x**2-pi, pi)")
     raises(ValueError, "solve(x**2-pi)")
 
-def test_solve_polynomial_cv_1():
+def test_solve_polynomial2():
+    x = Symbol('x')
+    assert solve(4, x) == []
+
+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)
@@ -94,6 +98,12 @@ def test_solve_polynomial_cv_1():
     assert solve( x**Rational(1,2) - 1, x) == [1]
     assert solve( x**Rational(1,2) - 2, x) == [sqrt(2)]
 
+def test_solve_polynomial_cv_1b():
+    x, a = symbols('x a')
+
+    assert set(solve(4*x*(1 - a*x**(S(1)/2)), x)) == \
+            set([S(0), (1/a)**(S(1)/2)])
+
 def test_solve_polynomial_cv_2():
     """
     Test for solving on equations that can be converted to a polynomial 
equation
-- 
1.6.2


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-patches" group.
To post to this group, send email to sympy-patches@googlegroups.com
To unsubscribe from this group, send email to 
sympy-patches+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sympy-patches?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to