Ask Your Question

# Extracting numerical value from a symbolic expression

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!

edit retag close merge delete

## 1 Answer

Sort by ยป oldest newest most voted

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]

more

## Your Answer

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

Add Answer

## Stats

Asked: 2013-02-20 19:26:55 +0200

Seen: 1,012 times

Last updated: Feb 20 '13