scientific-programming-exer.../ex_47.py
2019-01-23 15:27:28 +01:00

10 lines
186 B
Python

import numpy as np
from scipy.optimize import minimize
f = lambda x: x*np.sin(7*x)*np.exp(-(x - 2)**2)
x0 = f(np.arange(-20, 20, 0.1)).min()
m = minimize(f, x0, method="CG")
print(m)