Integrated Solvers at SciPy

Can solvers in SciPy deal with complex values ​​(for example, x = x '+ i * x ")? I am particularly interested in using a minimization function like Nelder-Mead. Usually I am a Matlab user and I know that Matlab does not have complex solvers. If SciPy can do this, then I definitely believe it! Thanks in advance.

+4
source share
1 answer

Neither scipy.optimize.fmin nor scipy.optimize.leastsq seem to play good with complex numbers. For example, fmin(lambda x: np.linalg.norm(x - np.array((1.2, 3+2j))), np.array((0j, 0j))) converges to array([ 1.19996429, 2.99997809]) , and leastsq just fails. To make it work, I would put your complex numbers in R ^ 2, I think. So that,

 fmin(lambda x: np.linalg.norm(x - np.array((1.2, 0, 3,2))), np.array((0,0, 0,0))) 

which converges to

 array([ 1.20000095e+00, -4.11719096e-05, 2.99999705e+00, 2.00001270e+00]) 

But yes, it would be nice if these functions played well with complex numbers.

+2
source

Source: https://habr.com/ru/post/1483824/


All Articles