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.Wed, 02 Oct 2013 08:52:04 -0500How do I assign solutions of an equation to a variable?http://ask.sagemath.org/question/10587/how-do-i-assign-solutions-of-an-equation-to-a-variable/a = solve(1-z-z^2==0,z)[0] has the result of a being 'z=-1/2*sqrt(5)-1/2'
But I would like to have just a = '-1/2*sqrt(5)-1/2'
How do I convert the expression to a number?
Thanks!
Wed, 02 Oct 2013 08:10:03 -0500http://ask.sagemath.org/question/10587/how-do-i-assign-solutions-of-an-equation-to-a-variable/Answer by tmonteil for <p>a = solve(1-z-z^2==0,z)[0] has the result of a being 'z=-1/2*sqrt(5)-1/2'</p>
<p>But I would like to have just a = '-1/2*sqrt(5)-1/2'</p>
<p>How do I convert the expression to a number?</p>
<p>Thanks!</p>
http://ask.sagemath.org/question/10587/how-do-i-assign-solutions-of-an-equation-to-a-variable/?answer=15516#post-id-15516You can use the method `.rhs()` or `.right_hand_side()` as follows:
sage: a = solve(1-z-z^2==0,z)[0].rhs()
sage: a
-1/2*sqrt(5) - 1/2
Wed, 02 Oct 2013 08:52:04 -0500http://ask.sagemath.org/question/10587/how-do-i-assign-solutions-of-an-equation-to-a-variable/?answer=15516#post-id-15516