10 lines
186 B
Python
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)
|