Numerical approximation for expression coefficients

i like this post (click again to cancel)
0
i dont like this post (click again to cancel)

I currently have an equation that looks like

x = 4/5(4y - 3)*z - 1/3

How can I get Sage to convert the coefficients to numerical approximations? I want to end up with something like

x = 0.8(4y - 3)*z - 0.333333333

I tried x.n(), but that only gives a "cannot evaluate symbolic expression numerically" error. Also x*1.0 doesn't do anything.

asked Apr 28 '11

Grover gravatar image Grover
3 2

updated Apr 28 '11

Kelvin Li gravatar image Kelvin Li
423 9 16
Since 1.2*x does what you want (well, except being multiplied by 1.2!), but not 1.0*x, I wonder if there is a bug here. See http://groups.google.com/group/sage-devel/browse_thread/thread/b6ab1e4499b07167# for a post about this on sage-devel. kcrisman (Apr 28 '11)
i like this answer (click again to cancel)
2
i dont like this answer (click again to cancel) Grover has selected this answer as correct

If $x$ is to be treated as a polynomial, then the following might suit your needs:

sage: var('y z')
(y, z)
sage: x = 4/5*(4*y - 3)*z - 1/3
sage: x.polynomial(RR)
3.20000000000000*y*z - 2.40000000000000*z - 0.333333333333333

Try

sage: RR?

for more information about RR

link

posted Apr 28 '11

Kelvin Li gravatar image Kelvin Li
423 9 16

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Tags:

Stats:

Asked: Apr 28 '11

Seen: 184 times

Last updated: Apr 28 '11

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.