scientific-programming-exer.../ex_47.py

10 lines
186 B
Python
Raw Normal View History

2019-01-23 14:27:28 +00:00
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)