> First attempt: loop through each term and try to n() the coefficient.
> Madness.

Based on a suggestion Mike Hansen once gave me --
http://ask.sagemath.org/question/411/substituting-expressions-for-numbers
-- I tend to use subclasses of Converter when I need to do something
like this, so as not to get lost in the madness. :^)  Something like:


from sage.symbolic.expression_conversions import Converter

class Evaluator(Converter):
    def arithmetic(self, ex, operator):
        return reduce(operator, map(self, ex.operands()))
    def pyobject(self, ex, obj):
        return ex.n()

sage: E = Evaluator()
sage: var("u x")
(u, x)
sage: q = ((314069483520)*sqrt(3/(sin(u+2)))*u - 80295755776*x +
4831838208)/(1953125*x^63)
sage: q
33554432/1953125*(9360*sqrt(3)*u*sqrt(1/sin(u + 2)) - 2393*x + 144)/x^63
sage: E(q)
17.179869183999998*(16211.99555884469*u*(1/sin(u + 2.0))^0.5 -
2393.0*x + 144.0)/x^63.0



Doug

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to