Ask Your Question

Extracting numerical value from a symbolic expression

asked 2013-02-20 12:26:55 -0500

assadabbasi gravatar image


First of sorry for the title as I am not sure what should be the title of this question.

I used solve() command to solve a system of equations and got a result like this.

[[x1 == (4/3), x2 == (-1/6), x3 == (-1/6)]]

We can say that it is some vertex and I want to have a result as (4/3, -1/6, -1/6) or [4/3, -1/6, -1/6]. At the moment I am doing it manually. Is there any sage command that can automatically extract (4/3, -1/6, -1/6) from the solution [[x1 == (4/3), x2 == (-1/6), x3 == (-1/6)]].

Thanks in advance!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-02-20 13:49:07 -0500

benjaminfjones gravatar image

I don't think there is a built-in solution that does exactly what you want, but it's easy enough to extract a vector solution:

sage: s = solve([x1==4/3, x2==-1/6, x3==-1/6], (x1,x2,x3))
sage: [ x.rhs() for x in s[0] ]                                                 
[4/3, -1/6, -1/6]
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

1 follower


Asked: 2013-02-20 12:26:55 -0500

Seen: 286 times

Last updated: Feb 20 '13