Ask Your Question

Missing solution in homogeneous equation

asked 2014-02-12 04:45:46 +0200

jllb gravatar image
var('x y')
solve(x*y, [x, y])

returns only the solution x=0, missing y=0. Is this a known bug? I am using sage 5.13.

edit retag flag offensive close merge delete


It's a strange problem indeed! However this is not a well-formed code , you can write this : solve([x*y==0], x , y) and the answer is : ([x == 0], [1]) . If you write this : solve([x*y==0], y ,x) the answer is : ([y == 0], [1]) .

moroplogo gravatar imagemoroplogo ( 2014-02-12 11:49:52 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-02-14 10:21:06 +0200

kcrisman gravatar image

First, the workaround.

sage: var('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.

edit flag offensive delete link more

Comments is probably the closest-related ticket.

kcrisman gravatar imagekcrisman ( 2014-02-14 11:20:33 +0200 )edit

There are also this problems : var('x,y,z') solve([x*y*z==0], x , y ,z) -> ([{x: 0}], [1]) AND solve([x*y*z==0], [x , y ,z]) -> [x == 0] . With cloud.sagemath I obtain this : var('x,y') solve([x*y==0],x,y) -> (x, y) ([x == 0], [1])

moroplogo gravatar imagemoroplogo ( 2014-02-14 11:37:59 +0200 )edit

With giac/xcas there are the "same" problem solve([x*y=0],[x,y]) -> ( x 0 ) and solve([x*y=0],x,y) -> ,undef

moroplogo gravatar imagemoroplogo ( 2014-02-14 11:46:55 +0200 )edit

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-02-12 04:45:46 +0200

Seen: 435 times

Last updated: Feb 14 '14