# Any way to get numeric result of part of symbolic expresssion?

If I have a symbolic expression sqrt(2) + x, is it possible to get this to show as 1,414.... + x?

Edit:

I should probably add that my symbolic expression can be any arbitrary composition of numbers and symbols.

edit retag close merge delete

Could you give us a more serious (real) example of what you want, please ?

( 2014-07-24 06:59:58 -0600 )edit

Sort by » oldest newest most voted

If your symbolic expression is a polynomial and your constants are algebraic numbers, work in a polynomial ring with coefficients in AA or QQbar.

sage: R.<x> = PolynomialRing(AA)
sage: a = AA(2).sqrt()
sage: x - a
x - 1.414213562373095?


Elements of AA or QQbar are exact. Compare:

sage: a = AA(2).sqrt()
sage: b = sqrt(2)
sage: c = n(sqrt(2))
sage: aa = a^2
sage: bb = b^2
sage: cc = c^2
sage: aa == 2
True
sage: bb == 2
2 == 2
sage: cc == 2
False

more

Not sure I understand this, but can your principle still be applied with my latest of the question?

( 2014-07-21 13:46:40 -0600 )edit

Hello,

I would try n(sqrt(2)) + x.

This results in x + 1.41421356237310

more

I've edited my question for clarity.

( 2014-07-21 13:46:16 -0600 )edit