1

I try with fmin_bfgs to find the local minimum of the absolute function abs(x). The initial point is set to 100.0; the expected answer is 0.0. However, I get:

In [184]: op.fmin_bfgs(lambda x:np.abs(x),100.0)
Warning: Desired error not necessarily achieved due to precision loss.
         Current function value: 100.000000
         Iterations: 0
         Function evaluations: 64
         Gradient evaluations: 20
Out[184]: array([100.0])

Why?

zell
  • 9,830
  • 10
  • 62
  • 115

1 Answers1

4

Methods like fmin_bfgs and fmin_slsqp require smooth (continuous derivative) functions in order to provide reliable results. abs(x) has a dicontinuous derivative at its minimum. A method like the Nelder-Mead simplex, which doesn't require continuous derivatives, might provide better results in this case.

Rob Falck
  • 2,324
  • 16
  • 14
  • This solved my problem too, thanks. I've asked a [follow-up question](http://stackoverflow.com/q/36110998/3904031) – uhoh Mar 20 '16 at 06:52