ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 30 Jun 2021 16:41:08 +0200numpy cube root 'not callable'https://ask.sagemath.org/question/57822/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.Abbas JaffaryWed, 30 Jun 2021 16:41:08 +0200https://ask.sagemath.org/question/57822/Displaying a numpy plothttps://ask.sagemath.org/question/26122/displaying-a-numpy-plot/ import matplotlib
import numpy as np
import matplotlib.pyplot as plt
plt.figure(figsize=(6, 3))
plt.plot(x, y)
plt.show()
Why doesn't `plt.show()` display my plot? `plt.savefig('myplot.png')` works, however.
thanksGeremiaTue, 10 Mar 2015 00:44:23 +0100https://ask.sagemath.org/question/26122/