First time here? Check out the FAQ!

Ask Your Question
0

Extracting numerical value from a symbolic expression

asked 12 years ago

assadabbasi gravatar image

Hi,

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!

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 12 years ago

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]
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

1 follower

Stats

Asked: 12 years ago

Seen: 1,102 times

Last updated: Feb 20 '13