# [SciPy-User] Optimize fmin_cg issue

The Helmbolds helmrp@yahoo....
Sun Jul 29 16:22:49 CDT 2012

```There appears to be something NQR (not quite right) with the SciPy optimize fmin_cg routine's handling of certain input values. Consider the following. Yes, I know the inputs are odd and far from the true optimal values, but I was experimenting to see what would happen with steep-sloped objective function. In the following, I use a scale factor to multiply the value of the objective function.

As you will see, the output flags an error in "double_scalars". I dunno what they are, but assume it's a C-code item. Also, <Items in angle brackets like this are my annotations.>

Enter guessed initial value of x, x0 = 10
Enter guessed initial value of y, y0 = 15
Use scale value, scale = 10
<End of user inputs . Run description next.>
With f(z) = 10 * optimize.rosen(z) and fprime(z) = 10 * optimize.rosen_der(z),
use SciPy's 'fmin_cg' Polak-Ribiere method to seek the minimum value of f:
Use start value, z0 = [10 15]:
At start, f(z0) = 7225810.0
At start, fprime(z0) = [3400180 -170000])
At start, Inf-norm of fprime(z0) = 3400180
Use the call:
res = sp.optimize.fmin_cg(f, z0, fprime, gtol=1e-05, norm=sp.Inf)
<End of run description. Output results next.>
Warning (from warnings module):
File "C:\Python27\lib\site-packages\scipy\optimize\linesearch.py", line 432
B = (fb-D-C*db)/(db*db)
RuntimeWarning: overflow encountered in double_scalars
Warning (from warnings module):
File "C:\Python27\lib\site-packages\scipy\optimize\linesearch.py", line 412
A /= denom
RuntimeWarning: divide by zero encountered in double_scalars
Warning (from warnings module):
File "C:\Python27\lib\site-packages\scipy\optimize\linesearch.py", line 413
B /= denom
RuntimeWarning: divide by zero encountered in double_scalars
Warning (from warnings module):
File "C:\Python27\lib\site-packages\scipy\optimize\linesearch.py", line 414
RuntimeWarning: invalid value encountered in double_scalars
Optimization terminated successfully.                                                  <Eh!? What!? >
Current function value: nan
Iterations: 7
Function evaluations: 109