優化示例(黃金)
黃金方法通過縮小極值範圍來最小化單峰函式
import numpy as np
from scipy.optimize import _minimize
from scipy import special
import matplotlib.pyplot as plt
x = np.linspace(0, 10, 500)
y = special.j0(x)
optimize.minimize_scalar(special.j0, method='golden')
plt.plot(x, y)
plt.show()
得到的影象