# [Scipy-tickets] [SciPy] #1494: fmin_bfgs stuck in infinite loop (but only with new version)

SciPy Trac scipy-tickets@scipy....
Sat Aug 13 18:04:56 CDT 2011

```#1494: fmin_bfgs stuck in infinite loop (but only with new version)
---------------------------------+------------------------------------------
Reporter:  scipydevwikiaccount  |       Owner:  somebody
Type:  defect               |      Status:  new
Priority:  normal               |   Milestone:  Unscheduled
Component:  Other                |     Version:  0.9.0
Keywords:                       |
---------------------------------+------------------------------------------

Comment(by scipydevwikiaccount):

Excuse my previous incorrect formatting. Let me repost my corrected
message:

Hello. I have run into a frustrating problem where
scipy.optimize.fmin_bfgs will get stuck in an infinite loop. This problem
has only shown up with a more recent version of scipy.

I have developed a very simple exmaple which demonstrates this problem by
trying to minimize the function -1/e**x, for which the optimal value is at
-infinity.

A simple program to reproduce the error:

{{{
import numpy,scipy,scipy.optimize
f=lambda x: -numpy.e**-x
fp=lambda x: -f(x)
x0=numpy.asarray([0])
x=scipy.optimize.fmin_bfgs(f,x0,fp)
print 'before: x=%s, after: x=%s' % (x0,x)
}}}

Using python 2.6, numpy 1.4.0, and scipy 0.7.2, the code successfuly
finishs with a reasonably large negative value:
{{{
\$ python crash.py Warning: Desired error not necessarily achieveddue to
precision loss

Current function value: -5184705528587058413568.000000 Iterations: 1
Function evaluations: 6 Gradient evaluations: 5

before: x=[0], after: x=[-50.]
}}}

Using python 2.7, numpy 1.6.1, and scipy 0.9.0, the code gets stuck in an
infinite loop and never terminates.

--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1494#comment:1>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
```