First time here? Check out the FAQ!

Ask Your Question
0

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

asked 11 years ago

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!

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 11 years ago

tmonteil gravatar image

updated 11 years ago

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
Preview: (hide)
link

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: 11 years ago

Seen: 531 times

Last updated: Oct 02 '13