I have a function and I am trying to find the minimum.
here is my code:
import nyumpy as np
from scipy.optimize import basinhopping, Bounds
from scipy import optimize
x=np.arange(-180.0,180.0)
bounds = Bounds(-180., 180.)
def P1_adj(x):
return 60450.64625041*np.exp(1j*(57.29*1.75056445+x))
print(optimize.minimize(P1_adj, x0=0))
When I run it, I get this error
TypeError: '<' not supported between instances of 'complex' and 'float'
Would you please help me to understand what I am doing wrong? I need to find the x(angle) that makes this function minimum.
optimize.minimizedoes not support complex numbers, functP1_adjreturns acomplex number, which is causing the error.P1_adjfunct calculates theabsolute valueof the complex number instead of returning the complex number itself