# A bug with solve()?

I'm trying to solve a toy linear system. Why does the result depend on the order of variables and on the repetition of the equations?

sage: var("x,y")
(x, y)
sage: solve([y==0],x,y)
([], [])
sage: solve([y==0],y,x)
([y == 0], )
sage: solve([y==0,y==0],x,y)
[[x == r3, y == 0]]

edit retag close merge delete

Sort by » oldest newest most voted

I agree that this is a bug, and the function solve() is full of bugs. The symbolic ring lacks semantics, here we do not know where do x and y live (there exists an assumption system, but it does not work correctly). I would advise to avoid the symbolic ring as much as possible, in your case, perhaps the right place is to consider the equation as a linear one over, say, the rationals:

sage: Proj = Matrix(QQ, [0, 1]) ; Proj
[0 1]
sage: Proj.right_kernel()
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[1 0]


And you can check that your last equation is equivalent to your first one:

sage: ProjTwice = Matrix(QQ, [[0, 1],[0,1]]) ; ProjTwice
[0 1]
[0 1]
sage: ProjTwice.right_kernel()
Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[1 0]
sage: Proj.right_kernel() == ProjTwice.right_kernel()
True

more