Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 2716 by [email protected]: solve cannot handle systems involving
roots and constants
http://code.google.com/p/sympy/issues/detail?id=2716
solve(sqrt(x**2-16),x)
[-4, 4]
solve(sqrt(x**2-16)-3,x)
[]
expected result:
[-5, 5]
You can find, below, a patch that is an inelegant workaround to the
problem. A Better solution should check all terms of the addition for the
symbol to be solved for, move all terms with to one side and all terms
without to the other, then attempt to solve.
If I get some time, I'll try to come up with a cleaner and more robust
solution.
solvers/solvers.py
617,623c617,625
< # x -> y**m.
< # we assume positive for simplification purposes
< t = Dummy('t', positive=True)
< f_ = f.subs(symbol, t**m)
< if guess_solve_strategy(f_, t) != GS_POLY:
< msg = "Could not convert to a polynomial
equation: %s" % f_
< result = []
---
# x = y -> x**m == y**m
if len(f.args) == 2:
f_ = (f.args[0])**m - (-f.args[1])**m
if guess_solve_strategy(f_, symbol) != GS_POLY:
msg = "Could not convert to a polynomial
equation: %s" % f_
result = []
else:
soln = _solve(f_, symbol)
result = [s for s in soln if checksol(f, {symbol:
s}) is not False]
625,629c627,639
< soln = [s**m for s in _solve(f_, t)]
< # we might have introduced solutions from another
branch
< # when changing variables; check and keep solutions
< # unless they definitely aren't a solution
< result = [s for s in soln if checksol(f, {symbol: s})
is not False]
---
# x -> y**m.
# we assume positive for simplification purposes
t = Dummy('t', positive=True)
f_ = f.subs(symbol, t**m)
if guess_solve_strategy(f_, t) != GS_POLY:
msg = "Could not convert to a polynomial
equation: %s" % f_
result = []
else:
soln = [s**m for s in _solve(f_, t)]
# we might have introduced solutions from another
branch
# when changing variables; check and keep
solutions
# unless they definitely aren't a solution
result = [s for s in soln if checksol(f, {symbol:
s}) is not False]
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.