範例 1:
Solve the system of nonliear equations
or expressed by
import numpy as np
import scipy.optimize as opt
def fun(x) :
f = [x[0]**2 + x[1]**2 -2, np.exp(x[0]-1) + x[1]**3 -3]
return f
sol = opt.root(fun, x0 = [1, 1])
# print(sol)
print('The solutions are [{:.4f},{:.4f}]'.format(sol.x[0], sol.x[1]))
練習:
Solve each system of nonlinear equations
練習:
計算 的最小值。
提示:這個問題就是前章介紹的多變量函數的最小值。除了使用指令直接求解外,也可以透過間接解非線性多變量聯立方程式的解,即對函數的各變量做偏微分並令其為零,其解可能是多變量函數的最小值解、最大值的解或什麼都不是。