Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Simplify function numerically

When I have a function that is exact, such as:

x = var("x")
fnc = sqrt(2) * x
print(fnc)

And I want to resolve/approximate all those parts of the function which can be resolved numerically, how can I do this?

fnc.n()

does not work because it throws a TypeError, similarly does

float(fnc)

I've also tried all .simplify() variants, but neither do what I want. I simply want the output to be:

print(magic_function(fnc))
1.4142 * x

How can this be done?