Ask Your Question

A bug with solve()?

asked 2014-01-20 10:13:47 +0200

alzobnin gravatar image

updated 2023-01-09 23:59:33 +0200

tmonteil gravatar image

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], [1])
sage: solve([y==0,y==0],x,y)
[[x == r3, y == 0]]
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-01-21 06:38:33 +0200

tmonteil gravatar image

updated 2014-01-21 06:40:52 +0200

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()
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-01-20 10:13:47 +0200

Seen: 329 times

Last updated: Jan 21 '14