I want to defining the following function:
def f(x,y):
return pow(x, 1/3) + y
x = np.linspace(-1, 1, 10)
y = np.linspace(-1, 1, 10)
X, Y = np.meshgrid(x, y)
Z = f(X, Y)
where clearly x is raised to a fractional power. I want to keep x and y symbolic since I want to plot the corresponding surface later.
However, numpy seems to be unable to handle fractional powers:
<ipython-input-96-bb0ed6d3607a>:2: RuntimeWarning: invalid value encountered in float_power
return np.float_power(x, 1/2, dtype=float)
Is there a quick shortaround this problem? I have searched for similar questions on SO but they all involve np.arrays or such with prescribed types of variables.