I have three dimensional function randomly defined by a user Z=f(x,y)
def f(x,y):
return ((7*x*y)/(np.exp(x**2+y**2)))
I converted this function to polar coordinates by substituting:
x_c = r*np.cos(theta)+x1; y_c = r*np.sin(theta)+y1;
where
theta = np.linspace(0, 2*np.pi, 30);
r,x1 and y1 are constant
Now I need to find the roots for the function Z(theta) in the polar form using NR method:
from scipy.optimize import newton
Z_func = f(x_c,y_c);
root = newton(Z_func,theta.any());
the error message shows:
q0 = func(*((p0,) + args)) TypeError: 'numpy.ndarray' object is not callable
newton method accepts only a callable function how can I make the function f(x_c,y_c) callable?
I do not want to substitute as shown below and call it in newton method
7*(r*np.cos(theta)+x1)*(r*np.sin(theta)+y1))/(np.exp((r*np.cos(theta)+x1)**2+(r*np.sin(theta)+y1)**2)
because I do not know the function f(x,y) that will be given.
Any idea will be appreciated