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, 25 Sep 2015 02:16:08 -0500Understanding the 'solve()' result with braces and brackets ("([{x:z},{x:y}],[1,1])")http://ask.sagemath.org/question/29443/understanding-the-solve-result-with-braces-and-brackets-xzxy11/Having following code
var('x,y,z')
P=-x^2*y + x*y^2 + x^2*z - y^2*z - x*z^2 + y*z^2 == 0
solve(P,x,y,z)
Sage gives me a result of
([{x:z},{x:y}],[1,1])
which I am not really able to interpret, also the help(solve) did not get me any further - is there anyone who can help me out with that?
(btw. as `-(x-y)*(x-z)*(y-z)==0` is an alternate form for writing the polynomial my expected answer would be something like `x=y or x=z or y=z` but in other cases where I'd get a similar answer I would have no idea, so I'd be happy to get this format explained.)
Tue, 15 Sep 2015 02:58:47 -0500http://ask.sagemath.org/question/29443/understanding-the-solve-result-with-braces-and-brackets-xzxy11/Answer by rws for <p>Having following code</p>
<pre><code>var('x,y,z')
P=-x^2*y + x*y^2 + x^2*z - y^2*z - x*z^2 + y*z^2 == 0
solve(P,x,y,z)
</code></pre>
<p>Sage gives me a result of </p>
<pre><code>([{x:z},{x:y}],[1,1])
</code></pre>
<p>which I am not really able to interpret, also the help(solve) did not get me any further - is there anyone who can help me out with that?
(btw. as <code>-(x-y)*(x-z)*(y-z)==0</code> is an alternate form for writing the polynomial my expected answer would be something like <code>x=y or x=z or y=z</code> but in other cases where I'd get a similar answer I would have no idea, so I'd be happy to get this format explained.)</p>
http://ask.sagemath.org/question/29443/understanding-the-solve-result-with-braces-and-brackets-xzxy11/?answer=29445#post-id-29445The result consists of two lists: `[{x: z}, {x: y}]` and `[1, 1]`.
Each list is a possible result that solves the equation. The first list
is a Python dictionary (which by definition has no order but gives the
values that specific variables will need to satisfy the equation); the
second is a list (which simply gives the needed values for the variables
in the order the vars were given as argument. Substitution confirms:
sage: P.subs(x==z)
0 == 0
sage: P.subs(x==y)
0 == 0
sage: P.subs(x==1,y==1)
0 == 0
Tue, 15 Sep 2015 07:41:34 -0500http://ask.sagemath.org/question/29443/understanding-the-solve-result-with-braces-and-brackets-xzxy11/?answer=29445#post-id-29445Comment by rws for <p>The result consists of two lists: <code>[{x: z}, {x: y}]</code> and <code>[1, 1]</code>.
Each list is a possible result that solves the equation. The first list
is a Python dictionary (which by definition has no order but gives the
values that specific variables will need to satisfy the equation); the
second is a list (which simply gives the needed values for the variables
in the order the vars were given as argument. Substitution confirms: </p>
<pre><code>sage: P.subs(x==z)
0 == 0
sage: P.subs(x==y)
0 == 0
sage: P.subs(x==1,y==1)
0 == 0
</code></pre>
http://ask.sagemath.org/question/29443/understanding-the-solve-result-with-braces-and-brackets-xzxy11/?comment=29576#post-id-29576The `y:z` can be deduced from the other two, but I have no idea how the results come up specifically.Fri, 25 Sep 2015 02:16:08 -0500http://ask.sagemath.org/question/29443/understanding-the-solve-result-with-braces-and-brackets-xzxy11/?comment=29576#post-id-29576Comment by Jaleks for <p>The result consists of two lists: <code>[{x: z}, {x: y}]</code> and <code>[1, 1]</code>.
Each list is a possible result that solves the equation. The first list
is a Python dictionary (which by definition has no order but gives the
values that specific variables will need to satisfy the equation); the
second is a list (which simply gives the needed values for the variables
in the order the vars were given as argument. Substitution confirms: </p>
<pre><code>sage: P.subs(x==z)
0 == 0
sage: P.subs(x==y)
0 == 0
sage: P.subs(x==1,y==1)
0 == 0
</code></pre>
http://ask.sagemath.org/question/29443/understanding-the-solve-result-with-braces-and-brackets-xzxy11/?comment=29451#post-id-29451Thanks so far, now I understand a bit more, but: How does it come? I mean, if there is already an `x==y` as solution, for what is it useful to add another result where these both values are just the same?
And where is the `y:z` solution I now would expect?Tue, 15 Sep 2015 09:26:32 -0500http://ask.sagemath.org/question/29443/understanding-the-solve-result-with-braces-and-brackets-xzxy11/?comment=29451#post-id-29451