| Hosted by CoCalc | Download
import numpy as np t = np.arange(5) t t^2 + sin(2*t)
array([0, 1, 2, 3, 4]) array([ 0. , 1.90929743, 3.2431975 , 8.7205845 , 16.98935825])
math.sin(2*t)
Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> TypeError: only length-1 arrays can be converted to Python scalars
f(x) = x^2 + sin(2*x)
f(t)
Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "sage/symbolic/expression.pyx", line 4902, in sage.symbolic.expression.Expression.__call__ (/projects/sage/sage-6.10/src/build/cythonized/sage/symbolic/expression.cpp:28201) return self._parent._call_element_(self, *args, **kwds) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/symbolic/callable.py", line 483, in _call_element_ raise NotImplementedError("Numpy arrays are not supported as arguments for symbolic expressions") NotImplementedError: Numpy arrays are not supported as arguments for symbolic expressions
g = fast_float(f) np.array([g(a) for a in t], dtype=float)
array([ 0. , 1.90929743, 3.2431975 , 8.7205845 , 16.98935825])