Ask Your Question

How do I assign solutions of an equation to a variable?

asked 2013-10-02 08:10:03 -0500

david8381 gravatar image

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?


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-10-02 08:52:04 -0500

tmonteil gravatar image

updated 2013-10-02 08:53:57 -0500

You 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
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-10-02 08:10:03 -0500

Seen: 173 times

Last updated: Oct 02 '13