Note
Go to the end to download the full example code.
1.5.12.1. Finding the minimum of a smooth functionΒΆ
Demos various methods to find the minimum of a function.
[<matplotlib.lines.Line2D object at 0x7f791f2890d0>]
Now find the minimum with a few methods
import scipy as sp
# The default (Nelder Mead)
print(sp.optimize.minimize(f, x0=0))
message: Optimization terminated successfully.
success: True
status: 0
fun: -7.945823375615215
x: [-1.306e+00]
nit: 5
jac: [-1.192e-06]
hess_inv: [[ 8.589e-02]]
nfev: 12
njev: 6
plt.show()
Total running time of the script: (0 minutes 0.048 seconds)