I get the following error with the function scipy.optimize.fsolve
:
ValueError: operands could not be broadcast together with shapes (2,) (100,100)
the command is the following:
q = lambda alpha : np.mean(np.divide(alpha*np.identity(n)+(1-alpha)*matrix, matrix)-1)
root = scipy.optimize.fsolve(lambda alpha: q(alpha)-0.3, [0, 1])
where n =100 and matrix is a symmetric 100x100 matrix.
The function q can be normally evaluted (e.g. q(0.4), q(0.5) etc. does not give any error), but I cannot apply the method fsolve
.