Ask Your Question
0

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

asked 2013-10-02 15:10:03 +0100

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?

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-10-02 15:52:04 +0100

tmonteil gravatar image

updated 2013-10-02 15:53:57 +0100

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

Stats

Asked: 2013-10-02 15:10:03 +0100

Seen: 513 times

Last updated: Oct 02 '13