Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It's because your f function above is returning a numpy array, rather than a number.

sage: f(1,2)
array([[ 0.45712591]])
sage: f(1,2)[0,0]
0.45712590955624677

So you need to extract that number out. You did it in your last example above. Here's another way:

spherical_plot3d(lambda x,y: f(x,y)[0,0],(x,0,2*pi),(y,0,pi))

It's because your f function above is returning a numpy array, rather than a number.

sage: f(1,2)
array([[ 0.45712591]])
sage: f(1,2)[0,0]
0.45712590955624677

So you need to extract that number out. You did it in your last example above. Here's another way:

spherical_plot3d(lambda x,y: f(x,y)[0,0],(x,0,2*pi),(y,0,pi))

Here is yet another way, since numpy arrays with a single value like that can be cast to floats.

spherical_plot3d(lambda x,y: float(f(x,y)),(x,0,2*pi),(y,0,pi))