Apologies if this is obvious, but I'm having trouble using solve to find
out if solutions exist or not (I don't really care what they are, just
whether or not there are any), for simultaneous equations with integer
variables.
For the following example, which has no solutions, solve returns [] (no
solution), or a solution, depending on the order of the symbols given. That
is, it sometimes works but sometimes fails to realize that there is no
solution.
For comparison, Mathematica seems to be correct, i.e. Reduce[l == 2 n && 2
h + l - 4 m - 3 == 0, {h, l, n, m}, Integers] correctly returns 'False'.
Sympy linsolve, on the other hand, never gives a null result, so it seems
to do worse than solve.
Example Python code below. Any advice would be gratefully appreciated!
from sympy import *
(h, l, m, n) = symbols(['h', 'l', 'm', 'n'], integer = True)
# these equations should have no solution as l must be both odd and even
eqnList = [Eq(l, 2*n), Eq(2*h + l - 4*m - 3, 0)]
# however, some orderings of the symbols to solve over fail to give no
solution (empty list)
print(solve(eqnList, [l, n, h, m] )) # returns [] - correct
print(solve(eqnList, [h, m, n, l] )) # returns {h: -l/2 + 2*m + 3/2, n:
l/2} - should give [] ?
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/sympy/0c23f1e5-15e8-4345-a961-f8be9728e127n%40googlegroups.com.