Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

My guess is that you're trying to call .n() or float not on the number but on the _equation_. For example:

sage: ans = solve((x-11/sqrt(13))**2,x)
sage: ans
[x == 11/13*sqrt(13)]
sage: ans[0]
x == 11/13*sqrt(13)
sage: ans[0].n()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[...]
/Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:17880)()
TypeError: cannot evaluate symbolic expression numerically

You really want to get at the expression on the right:

sage: ans[0].rhs().n()
3.05085107923876

or maybe

sage: ans = solve((x-11/sqrt(13))**2,x,solution_dict=True)
sage: ans[0]
{x: 11/13*sqrt(13)}
sage: ans[0][x]
11/13*sqrt(13)
sage: ans[0][x].n()
3.05085107923876