I am trying to implement the same Sage code here: find vector center in python, as follows:
import numpy as np
from scipy.optimize import minimize
def norm(x):
return x/np.linalg.norm(x)
vectors = np.array([[1,2,3],[4,5,6],[7,8,9]])
unit_vectors = [np.divide(v,norm(v)) for v in vectors]
constraints = [lambda x: np.dot(x,u)-1 for u in unit_vectors]
target = lambda x: norm(x)
res = minimize(target,[3,3,3],constraints)
But I keep getting the same problem:
TypeError: <lambda>() takes 1 positional argument but 2 were given
I am not a mathematician, I just want to write a code that can find a center of multidimensional vectors. I tried many things to solve the problem but nothing worked.
Thanks.