Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

numpy cube root 'not callable'

I would like to plot the numpy.cbrt function in Sage.

The example:

import numpy as np
parametric_plot([u,np.sin(u)], (u,0,pi))

plots a sine wave, but

parametric_plot([u,np.cbrt(u)], (u,0,pi))

produces the error:

TypeError: loop of ufunc does not support argument 0 of type sage.symbolic.expression.Expression which has no callable cbrt method

Isn't Sage passing the interval [0,pi] as an array when constructing the plot? I'd like to know why some numpy functions will work in this manner with Sage, and why others do not, and if there is a workaround.

FWIW:
I am doing this to test numpy numerical precision vs. Sage built-in math functions. Numpy seems to be more precise, even using Sage RealField precision beyond 53 bits.