Ask Your Question
0

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

asked 2014-07-21 16:53:33 +0100

Woodgnome gravatar image

updated 2014-07-21 20:42:44 +0100

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 13:59:58 +0100 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2014-07-21 17:49:52 +0100

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 20:46:16 +0100 )edit
0

answered 2014-07-21 18:25:32 +0100

slelievre gravatar image

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 20:46:40 +0100 )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 16:53:33 +0100

Seen: 479 times

Last updated: Jul 21 '14