拉格朗日乘数法

拉格朗日乘数

定义

拉格朗日乘数法是一种寻找 f\left(x_{1}, x_{2}, \ldots, x_{n}\right) 在约束 g\left(x_{1}, x_{2}, \ldots, x_{n}\right)=0 下的局部最大最小值的数学方法。

如果不用拉格朗日乘数法,通常我们要通过 g\left(x_{1}, x_{2}, \ldots, x_{n}\right)=0 解出某一个变量相对于其他变量的关系然后再带入公式 f\left(x_{1}, x_{2}, \ldots, x_{n}\right) 解一个只有 n-1 个变量的无约束问题,通常这样做比较困难。

对于上述问题可以转变成求下列拉格朗日函数的极值:
\mathcal{L}\left(x_{1}, x_{2}, \ldots, x_{n}, \lambda \right) = f\left(x_{1}, x_{2}, \ldots, x_{n}\right) - \lambda \cdot g\left(x_{1}, x_{2}, \ldots, x_{n}\right)\tag{1}

其中 \lambda 就是所谓的拉格朗日乘数。

更一般的 n 个变量和 k 个约束的情况就是:
\mathcal{L}\left(x_{1}, \dots, x_{n}, \lambda_{1}, \dots, \lambda_{k}\right)=f\left(x_{1}, \dots, x_{n}\right)-\sum_{i=1}^{k} \lambda_{i} g_{i}\left(x_{1}, \dots, x_{n}\right)\tag{2}

流程

公式 (1) 求极值转化为求下述方程组:
\begin{array}{c}{\frac{\partial f\left(x_{1}, x_{2}, \ldots, x_{n}\right)}{\partial x_{1}}=\lambda \frac{\partial g\left(x_{1}, x_{2}, \ldots, x_{n}\right)}{\partial x_{1}}} \\ {\frac{\partial f\left(x_{1}, x_{2}, \ldots, x_{n}\right)}{\partial x_{2}}=\lambda \frac{\partial g\left(x_{1}, x_{2}, \ldots, x_{n}\right)}{\partial x_{2}}} \\ {\vdots} \\ {\frac{\partial f\left(x_{1}, x_{2}, \ldots, x_{n}\right)}{\partial x_{n}}=\lambda \frac{\partial g\left(x_{1}, x_{2}, \ldots, x_{n}\right)}{\partial x_{n}}}\end{array}\tag{3}
由于有 n+1 个变量多出一个方程就是约束 g\left(x_{1}, x_{2}, \ldots, x_{n}\right)=0

参考文献

https://zhuanlan.zhihu.com/p/31458541
https://brilliant.org/wiki/lagrange-multipliers/
https://zh.wikipedia.org/wiki/%E6%8B%89%E6%A0%BC%E6%9C%97%E6%97%A5%E4%B9%98%E6%95%B0