Was sin
redefined, maybe by importing sin
from some package,
for example by running the following:
sage: from math import sin
Here is a demo using Sage 8.8.beta3 built for Python 3.
$ sage -q
sage: version()
'SageMath version 8.8.beta3, Release Date: 2019-04-18'
sage: sys.version_info[:3]
(3, 7, 3)
The suggested code works fine out of the box:
sage: var('t')
t
sage: sin(t)
sin(t)
Importing the function sin
from the Python package math
,
it now fails as in the question:
sage: from math import sin
sage: var('t')
t
sage: sin(t)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/xxx/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx
in sage.symbolic.expression.Expression.__float__
(build/cythonized/sage/symbolic/expression.cpp:10846)()
1418 try:
-> 1419 ret = float(self._eval_self(float))
1420 except TypeError:
/xxx/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx
in sage.symbolic.expression.Expression._eval_self
(build/cythonized/sage/symbolic/expression.cpp:9977)()
1226 else:
-> 1227 raise TypeError("Cannot evaluate symbolic expression to a numeric value.")
1228
TypeError: Cannot evaluate symbolic expression to a numeric value.
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
/xxx/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx
in sage.symbolic.expression.Expression.__float__
(build/cythonized/sage/symbolic/expression.cpp:10908)()
1421 try:
-> 1422 c = (self._eval_self(complex))
1423 if imag(c) == 0:
/opt/s/sage/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx
in sage.symbolic.expression.Expression._eval_self
(build/cythonized/sage/symbolic/expression.cpp:9977)()
1226 else:
-> 1227 raise TypeError("Cannot evaluate symbolic expression to a numeric value.")
1228
TypeError: Cannot evaluate symbolic expression to a numeric value.
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-111-17829414d33a> in <module>()
----> 1 sin(t)
/xxx/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx
in sage.symbolic.expression.Expression.__float__
(build/cythonized/sage/symbolic/expression.cpp:11039)()
1426 raise
1427 except TypeError:
-> 1428 raise TypeError("unable to simplify to float approximation")
1429 return ret
1430
TypeError: unable to simplify to float approximation
If sin
was imported from some package like math
, Sage's sin
can still be used:
sage: from math import sin
sage: var('t')
t
sage: sage.functions.trig.sin(t)
sin(t)
Everything running fine for a while and then breaking sounds like some other package got upgraded and that broke Sage. Can you reinstall Sage?
How was Sage installed? Built from source? Using a binary installer from the SageMath download page? Using
apt-get install
? Using Conda? Using Docker? Using Nix? Other?hi sorry for the delay, I installed SageMath using apt-get install on Ubuntu 18.04. Actually I did that recently and know my kernel does not even start. I cleaned all pythonpath and pythonrc from my bashrc. I'm posting the error next :
https://alf3000.github.io/whoami/sage...