Ask Your Question
0

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

asked 2014-07-21 09:53:33 -0600

Woodgnome gravatar image

updated 2014-07-21 13:42:44 -0600

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 flag offensive close merge delete

Comments

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

FrédéricC gravatar imageFrédéricC ( 2014-07-24 06:59:58 -0600 )edit

2 answers

Sort by » oldest newest most voted
0

answered 2014-07-21 11:25:32 -0600

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
edit flag offensive delete link more

Comments

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

Woodgnome gravatar imageWoodgnome ( 2014-07-21 13:46:40 -0600 )edit
0

answered 2014-07-21 10:49:52 -0600

Vasile gravatar image

Hello,

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

This results in x + 1.41421356237310

edit flag offensive delete link more

Comments

I've edited my question for clarity.

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

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: 2014-07-21 09:53:33 -0600

Seen: 99 times

Last updated: Jul 21 '14