Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 2012-09-30 03:17:13 -0500

DSM gravatar image

One way is to use _convert to coerce the symbolic coefficients to the Real Field:

sage: var("x y")
(x, y)
sage: eq = y == (sqrt(5) + 3) * x^3 + e^pi * x^2 + sqrt(2) * x + 1/27
sage: eq._convert(RR)
y == 5.23606797749979*x^3 + 23.1406926327793*x^2 + 1.41421356237310*x + 0.0370370370370370

There's a ticket -- trac #12577 -- which proposes to expose this (by which I mean get rid of the initial _). Unfortunately the convert method without an underscore already exists, and doesn't seem to be really useful, but we could use something more explicit like change_coefficient_ring. Actually, it could even take a function argument as well as a ring, and could be used for quick transformations without needing to implement an expression walker..