I have a problem with numpy,I use the numpy.min() to get expression's minimum value,but when I get the minimum value,how can i get the x and y value on the contrary.The x,y was in the expression.,
x=np.linspace(-300,300,10000)
y=np.linspace(-300,300,10000)
D=np.min((np.sqrt((x)**2+(y)**2)-2))**2+(np.sqrt((x-3)**2+(y-2)**2)-2)**2)
I write the f() as u teach me like this:
def f(self,xy,k):
expression=0
x, y= xy
cols=self.maintablewidget.columnCount()-1
#for k in range(3,cols):
for i in range(1,k):
d=string.atof(self.maintablewidget.item(i-1,k-1).text())
xi=string.atof(self.xytablewidget.item(i-1,0).text())
yi=string.atof(self.xytablewidget.item(i-1,1).text())
expression=np.sum((np.sqrt((x-xi)**2+(y-yi)**2)-d)**2)
return expression
#I do not know how to call the f() here, because the parameter k I do not know pass it
for k in range(3,12):
res=optimize.minimize(self.f,(0,0),k)#here is an error
print(res['x'][0])
print(res['x'],res['fun'])
I do not know how to pass the K to f(self,xy,k),when i call it !