[SciPy-User] Find the convergent solutions of a multivariate equation efficiently

Camille Chambon camillechambon at yahoo.fr
Sat Mar 21 15:00:51 EDT 2015


Hello,

I have a function:

def my_function(x1, x2):
     y1 = compute_y1(x1)
     y2 = compute_y2(x2)
     x1_new = compute_new_x1(x1, y1, y2)
     x2_new = compute_new_x2(x2, y1, y2)
     return x1_new, x2_new, y1, y2

I would like to find the convergent values of y1 and y2, that is when 
(x1_new - x1) / x1 < epsilon and (x2_new - x2) / x2 < epsilon.

By now, I initialize x1 and x2 and I call main_function numerous times:

epsilon = 0.01
x1, x2 = 0.1, 0.1
x1_new, x2_new = 100.0, 100.0
while abs((x1_new - x1)/x1) >= epsilon or abs((x2_new - x2)/x2) >= epsilon:
     x1, x2 = x1_new, x2_new
     x1_new, x2_new, y1, y2 = my_function(x1, x2)
print 'y1 = ', y1
print 'y2 = ', y2

It works. But I wonder if it's the most efficient method.

I read about scipy.optimize.minimize, but I can not see how it could be 
applied to my problem.

Thanks in advance for your help.

Cheers,

Camille



More information about the SciPy-User mailing list