On 05/07/2015 11:19 AM, Douglas Davis wrote:
> Is there a way to convert a symbolic result from using rational expressions
> and constants to the corresponding expression using reals?
>
> For example if I have a result of
>
> -15/28*2^(2/3)*a*hh^2+32/pi*b^3
>
> I need to convert it to
>
> -0.85039*a*hh^2 + 10.186*b^3
>
You want the (hidden!) _convert() method:
sage: a,b,hh = SR.var('a,b,hh')
sage: f = -15/28*2^(2/3)*a*hh^2+32/pi*b^3
sage: f._convert({'parent':RR})
10.1859163578813*b^3 - 0.850393420697250*a*hh^2
This is useful all the time and has been asked for before. There's a
ticket to make it public:
http://trac.sagemath.org/ticket/12577
Although now it would be nice to add some sugar on top so that e.g.
f.convert(RR) would work without the weird dict. (The dict wasn't needed
back when I created the ticket.)