1 | initial version |
First, the workaround.
sage: var('y')
y
sage: a = x*y
sage: solve([a,1==1],[x,y])
[[x == r1, y == 0], [x == 0, y == r2]]
There is an open ticket about this I will try to find later. But at least now I know the reason.
This is interesting - apparently we assume that if one passes in a single expression, there is a single variable that should be solved for.
# There *should* be only one variable in the list, since it is
# passed from sage.symbolic.relation.solve() and multiple variables
# there don't call this function.
if isinstance(x, (list, tuple)):
x = x[0]
That explains your result. However, @moroplogo's is even more interesting. What happens is that all arguments get passed to xy.solve()
if is_Expression(f): # f is a single expression
ans = f.solve(*args,**kwds)
return ans
But these are not unpacked! So we have something that actually passes in to Maxima. But what? It's not passing in this:
(%i2) solve(x*y,[x,y]);
(%o2) [[x = %r1, y = 0], [x = 0, y = %r2]]
and some debugging indicates it should just be passing in the same as solve(x*y,x)
. I'm not sure how that extra [1]
gets in there.