ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 14 Feb 2014 04:46:55 -0600Missing solution in homogeneous equationhttp://ask.sagemath.org/question/11025/missing-solution-in-homogeneous-equation/ 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.Tue, 11 Feb 2014 21:45:46 -0600http://ask.sagemath.org/question/11025/missing-solution-in-homogeneous-equation/Comment by moroplogo for <pre><code>var('x y')
solve(x*y, [x, y])
</code></pre>
<p>returns only the solution x=0, missing y=0.
Is this a known bug? I am using sage 5.13.</p>
http://ask.sagemath.org/question/11025/missing-solution-in-homogeneous-equation/?comment=16277#post-id-16277It'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]) .Wed, 12 Feb 2014 04:49:52 -0600http://ask.sagemath.org/question/11025/missing-solution-in-homogeneous-equation/?comment=16277#post-id-16277Answer by kcrisman for <pre><code>var('x y')
solve(x*y, [x, y])
</code></pre>
<p>returns only the solution x=0, missing y=0.
Is this a known bug? I am using sage 5.13.</p>
http://ask.sagemath.org/question/11025/missing-solution-in-homogeneous-equation/?answer=16041#post-id-16041First, 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.
Fri, 14 Feb 2014 03:21:06 -0600http://ask.sagemath.org/question/11025/missing-solution-in-homogeneous-equation/?answer=16041#post-id-16041Comment by moroplogo for <p>First, the workaround.</p>
<pre><code>sage: var('y')
y
sage: a = x*y
sage: solve([a,1==1],[x,y])
[[x == r1, y == 0], [x == 0, y == r2]]
</code></pre>
<p>There is an open ticket about this I will try to find later. But at least now I know the reason.</p>
<p>This is interesting - apparently we assume that if one passes in a single expression, there is a single variable that should be solved for.</p>
<pre><code> # 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]
</code></pre>
<p>That explains your result. However, <a href="/users/1729/moroplogo/">@moroplogo</a>'s is even more interesting. What happens is that all arguments get passed to <code>xy.solve()</code></p>
<pre><code>if is_Expression(f): # f is a single expression
ans = f.solve(*args,**kwds)
return ans
</code></pre>
<p>But these are <em>not</em> unpacked! So we have something that actually passes in to Maxima. But what? It's not passing in this:</p>
<pre><code>(%i2) solve(x*y,[x,y]);
(%o2) [[x = %r1, y = 0], [x = 0, y = %r2]]
</code></pre>
<p>and some debugging indicates it should just be passing in the same as <code>solve(x*y,x)</code>. I'm not sure how that extra <code>[1]</code> gets in there.</p>
http://ask.sagemath.org/question/11025/missing-solution-in-homogeneous-equation/?comment=16260#post-id-16260With giac/xcas there are the "same" problem solve([x*y=0],[x,y]) -> ( x 0 ) and solve([x*y=0],x,y) -> ,undefFri, 14 Feb 2014 04:46:55 -0600http://ask.sagemath.org/question/11025/missing-solution-in-homogeneous-equation/?comment=16260#post-id-16260Comment by kcrisman for <p>First, the workaround.</p>
<pre><code>sage: var('y')
y
sage: a = x*y
sage: solve([a,1==1],[x,y])
[[x == r1, y == 0], [x == 0, y == r2]]
</code></pre>
<p>There is an open ticket about this I will try to find later. But at least now I know the reason.</p>
<p>This is interesting - apparently we assume that if one passes in a single expression, there is a single variable that should be solved for.</p>
<pre><code> # 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]
</code></pre>
<p>That explains your result. However, <a href="/users/1729/moroplogo/">@moroplogo</a>'s is even more interesting. What happens is that all arguments get passed to <code>xy.solve()</code></p>
<pre><code>if is_Expression(f): # f is a single expression
ans = f.solve(*args,**kwds)
return ans
</code></pre>
<p>But these are <em>not</em> unpacked! So we have something that actually passes in to Maxima. But what? It's not passing in this:</p>
<pre><code>(%i2) solve(x*y,[x,y]);
(%o2) [[x = %r1, y = 0], [x = 0, y = %r2]]
</code></pre>
<p>and some debugging indicates it should just be passing in the same as <code>solve(x*y,x)</code>. I'm not sure how that extra <code>[1]</code> gets in there.</p>
http://ask.sagemath.org/question/11025/missing-solution-in-homogeneous-equation/?comment=16265#post-id-16265http://trac.sagemath.org/ticket/10750 is probably the closest-related ticket.Fri, 14 Feb 2014 04:20:33 -0600http://ask.sagemath.org/question/11025/missing-solution-in-homogeneous-equation/?comment=16265#post-id-16265Comment by moroplogo for <p>First, the workaround.</p>
<pre><code>sage: var('y')
y
sage: a = x*y
sage: solve([a,1==1],[x,y])
[[x == r1, y == 0], [x == 0, y == r2]]
</code></pre>
<p>There is an open ticket about this I will try to find later. But at least now I know the reason.</p>
<p>This is interesting - apparently we assume that if one passes in a single expression, there is a single variable that should be solved for.</p>
<pre><code> # 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]
</code></pre>
<p>That explains your result. However, <a href="/users/1729/moroplogo/">@moroplogo</a>'s is even more interesting. What happens is that all arguments get passed to <code>xy.solve()</code></p>
<pre><code>if is_Expression(f): # f is a single expression
ans = f.solve(*args,**kwds)
return ans
</code></pre>
<p>But these are <em>not</em> unpacked! So we have something that actually passes in to Maxima. But what? It's not passing in this:</p>
<pre><code>(%i2) solve(x*y,[x,y]);
(%o2) [[x = %r1, y = 0], [x = 0, y = %r2]]
</code></pre>
<p>and some debugging indicates it should just be passing in the same as <code>solve(x*y,x)</code>. I'm not sure how that extra <code>[1]</code> gets in there.</p>
http://ask.sagemath.org/question/11025/missing-solution-in-homogeneous-equation/?comment=16261#post-id-16261There 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]) Fri, 14 Feb 2014 04:37:59 -0600http://ask.sagemath.org/question/11025/missing-solution-in-homogeneous-equation/?comment=16261#post-id-16261