多元函数多约束拉格朗日乘数法证明

目录

  • 多元函数多约束拉格朗日乘数法证明
  • 0. 一些约定
  • 1. 从简单开始
  • 1.1. 三个未知数,一个约束
  • 1.2. 三个未知数,两个约束
  • 2. 一般情况
  • 2.0. 多元多约束求偏导
  • 2.1. 更复杂的情况

0. 一些约定

为了方便,约定:
函数的偏导数用\(f_x\)代表\(\frac{\partial f}{\partial x}\),当函数为单元的时候,\(f_x\)代表\(\frac{\mathrm{d}f}{\mathrm{d}x}\)。
函数的梯度用\(\nabla f\) 表示,即\(\nabla f=(f_{x_1},\dots,f_{x_n})\)。
函数雅可比矩阵:
\[\frac{\partial(f_1,\dots,f_n)}{\partial(x_1,\dots,x_m)}=
\left(
\matrix{
f_{1x_1}  &\dots  &f_{1x_m}\\
\vdots    &\ddots &\vdots\\
f_{nx_1}  &\dots  &f_{nx_m}
}
\right)
\]
约定雅可比矩阵的行列式这样表示:
\[\left|\frac{\partial(f_1,\dots,f_n)}{\partial(x_1,\dots,x_m)}\right|=
\left|
\matrix{
f_{1x_1}  &\dots  &f_{1x_m}\\
\vdots    &\ddots &\vdots\\
f_{nx_1}  &\dots  &f_{nx_m}
}
\right|
\]
约定:
\[\frac{\partial(f_1,\dots,f_n)}{\partial(x_1,\dots,x_m)_{x_i\rightarrow y_j}}=
\left(
\matrix{
f_{1x_1}  &\dots  &f_{1x_{i-1}} &f_{1y_j} &f_{1x_{i+1}} &\dots  &f_{1x_m}\\
\vdots    &\vdots &\vdots       &\vdots   &\vdots       &\vdots &\vdots\\
f_{nx_1}  &\dots  &f_{nx_{i-1}} &f_{ny_j} &f_{nx_{i+1}} &\dots  &f_{nx_m}\\
}
\right)
\]

1. 从简单开始

1.1. 三个未知数,一个约束

考虑这样的题目:
\[\mbox{maxmize}:f(x,y,z)\\
\mbox{s.t.} g(x,y,z)=0
\]
那么,\(g\)的约束能确定一个隐函数\(z=z(x,y)\),即:
\[\mbox{maxmize}:f(x,y,z(x,y))
\]
那么问题就变成无约束的情况,一个必要条件是:
\[\left\{
\matrix{
\frac{\partial f}{\partial x}+\frac{\partial f}{\partial z}\frac{\partial z}{\partial x}=0\\
\frac{\partial f}{\partial y}+\frac{\partial f}{\partial z}\frac{\partial z}{\partial y}=0\\
}
\right.
\]
那么,由隐函数求导,有:
\[\frac{\partial z}{\partial x}=-\frac{\frac{\partial g}{\partial x}}{\frac{\partial g}{\partial z}}\\
\frac{\partial z}{\partial y}=-\frac{\frac{\partial g}{\partial y}}{\frac{\partial g}{\partial z}}
\]
原约束为:
\[\left\{
\matrix{
\frac{\partial f}{\partial x}-\frac{\partial f}{\partial z}\frac{\frac{\partial g}{\partial x}}{\frac{\partial g}{\partial z}}=0\\
\frac{\partial f}{\partial y}-\frac{\partial f}{\partial z}\frac{\frac{\partial g}{\partial y}}{\frac{\partial g}{\partial z}}=0\\
}
\right.
\]
令:
\[\lambda=\frac{\frac{\partial f}{\partial z}}{\frac{\partial g}{\partial z}}
\]
就有:
\[\left\{
\matrix{
\frac{\partial f}{\partial x}-\lambda\frac{\partial g}{\partial x}=0\\
\frac{\partial f}{\partial y}-\lambda\frac{\partial g}{\partial y}=0\\
\frac{\partial f}{\partial z}-\lambda\frac{\partial g}{\partial z}=0
}
\right.
\]
这就是拉格朗日函数\(L(x,y,z)=f(x,y,z)-\lambda g(x,y,z)\)的由来。

1.2. 三个未知数,两个约束

为了简便,这里之后使用\(f_x\)来代替\(\frac{\partial f}{\partial x}\),当\(f\)为单元函数的时候也这么说,以此类推。

在 1.1 里,这样的讨论似乎不能更好地拓展到多个未知数的情况。

所以,这里我们讨论约束个数更多的情况:
\[\frac{\partial(g,h)}{\partial(x,y,z)}=
\left(
\matrix{
g_x& g_y& g_z\\
h_x& h_y& h_z
}
\right)\mbox{满秩}\\
\mbox{maxmize}:f(x,y,z)\\
\mbox{s.t.} g(x,y,z)=0,h(x,y,z)=0
\]
这种约束的情况下,可以确定隐函数:
\[y=y(x),z=z(x)
\]
即,函数为三维空间中的一根曲线。
那么,必要条件即为:
\[f_x+f_y\cdot y_x+f_z\cdot z_x=0
\]
可以将其看成向量点乘的形式:
\[(f_x,f_y,f_z)\cdot(1,y_x,y_x)=0
\]
将\((f_x,f_y,f_z)\)表示成\(f\)的梯度\(\nabla f\)即:
\[\nabla f\cdot(1,y_x,y_z)=0
\]
即\(\nabla f\)与为曲线的切向量垂直的向量。
由解析几何的知识,可以知道曲线可以表示成两个曲面的交,即:
\[l=g\and h
\]
而且,由于\(\frac{\partial(g,h)}{\partial(x,y,z)}\)满秩,所以\(\nabla g,\nabla h\)线性无关。
所以,在某一点所有与曲线切线垂直的向量所形成的平面是由\(\nabla g\)和\(\nabla h\)所张成的空间,即:
\[\nabla f=\lambda \nabla g+\mu\nabla h
\]
对应到每个分量方程就是:
\[\left\{
\matrix{
f_x-\lambda g_x-\mu h_x=0\\
f_y-\lambda g_y-\mu h_y=0\\
f_y-\lambda g_y-\mu h_y=0
}
\right.
\]
这就是拉格朗日函数\(L(x,y,z)=f(x,y,z)-\lambda g(x,y,z)-\mu h(x,y,z)\)的由来。

2. 一般情况

2.0. 多元多约束求偏导

我们先算这个隐函数所对应的偏导数,\(g_1,\dots,g_m\)分别对\(x_1\)求偏导,有:
\[\left\{
\matrix{
g_{1x_1}+g_{1y_1}y_{1x_1}+\dots+g_{1y_m}y_{mx_1}=0\\
\cdots\\
g_{mx_1}+g_{my_1}y_{mx_1}+\dots+g_{my_m}y_{mx_1}=0
}
\right.
\]
即:
\[\left\{
\matrix{
g_{1y_1}y_{1x_1}+\dots+g_{1y_m}y_{mx_1}=-g_{1x_1}\\
\cdots\\
g_{my_1}y_{1x_1}+\dots+g_{my_m}y_{mx_1}=-g_{mx_1}
}
\right.
\]
写成矩阵形式即为:
\[\frac{\partial(g_1,g_2,\dots,g_m)}{\partial(y_1,y_2,\dots,y_m)}\cdot
\left(
\matrix{
y_{1x_1}\\
y_{2x_1}\\
\cdots\\
y_{mx_1}
}
\right)
=-
\left(
\matrix{
g_{1x_1}\\
g_{2x_1}\\
\cdots\\
g_{mx_1}
}
\right)
\]
将\(g_1,\dots,g_m\)对\(x_1,\dots,x_n\)求偏导的矩阵和起来:
\[\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)}\cdot\frac{\partial(y_1,\dots,y_m)}{\partial(x_1,\dots,x_n)}=-\frac{\partial(g_1,\dots,g_m)}{\partial(x_1,\dots,x_n)}
\]
由克拉默法则,有:
\[y_{ix_j}=-\frac{\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)_{y_i\rightarrow x_j}}\right|}{\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)}\right|}
\]

2.1. 更复杂的情况

我们由多约束的情况过渡到更加一般的情况:
\[\frac{\partial(g_1,\dots,g_m)}{\partial(x_1,\dots,x_n,y_1,\dots,y_m)}\mbox{满秩}\\
\mbox{maxmize}:f(x_1,\dots,x_n,y_1,\dots,y_m)\\
\mbox{s.t.}
\left\{
\matrix{
g_1(x_1,\dots,x_n,y_1,\dots,y_m)=0\\
\cdots\\
g_m(x_1,\dots,x_n,y_1,\dots,y_m)=0
}
\right.
\]
同样,由约束条件可以获得一堆隐函数:
\[\left\{
\matrix{
y_1=y_1(x_1,\dots,x_n)\\
\cdots\\
y_m=y_m(x_1,\dots,x_n)
}
\right.
\]
一个必要条件即为:
\[\left\{
\matrix{
f_{x_1}+\displaystyle\sum_{i=1}^{m}f_{y_i}y_{ix_1}=0\\
\cdots\\
f_{x_n}+\displaystyle\sum_{i=1}^{m}f_{y_i}y_{ix_n}=0\\
}
\right.
\]
同样,将其写成梯度的形式:
\[\left\{
\matrix{
\nabla f\cdot (1,0,\dots,0,y_{1x_1},y_{2x_1},\dots,y_{mx_1})\\
\nabla f\cdot (0,1,\dots,0,y_{1x_2},y_{2x_2},\dots,y_{mx_2})\\
\cdots\\
\nabla f\cdot (0,0,\dots,1,y_{1x_n},y_{2x_n},\dots,y_{mx_n})
}
\right.
\]
由隐函数的算法,有:
\[y_{ix_j}=-\frac{\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)_{y_i\rightarrow x_j}}\right|}{\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)}\right|}
\]
那么,梯度的约束又可写为:
\[\left\{
\matrix{
\nabla f\cdot (\left|
\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)}\right|
,0,\dots,0,
\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)_{y_1\rightarrow x_1}}\right|
,\dots,\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)_{y_m\rightarrow x_1}}\right|)\\
\cdots\\
\nabla f\cdot (0,\dots,0,\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)}\right|,0,\dots,0,\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)_{y_1\rightarrow x_i}}\right|,\dots,\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)_{y_m\rightarrow x_i}}\right|)\\
\cdots\\
\nabla f\cdot (0,\dots,0,\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)_{y_1\rightarrow x_n}}\right|,\dots,\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)_{y_m\rightarrow x_n}})
\right|}
\right.
\]
我们希望知道\(\nabla f\)应该满足什么条件。
一个很巧妙的构造是,注意到:
\[\nabla g_k\cdot (0,\dots,0,\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)}\right|,0,\dots,0,\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)_{y_1\rightarrow x_i}}\right|,\dots,\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)_{y_m\rightarrow x_i}}\right|)\\
=g_{kx_i}\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)}\right|-\sum_{j=1}^{m}g_{ky_j}\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)_{y_j\rightarrow x_i}}\right|
\]
将第\(j\)个行列式的第\(j\)列依次与前面交换\(j-1\)次移动到首列,有:
\[=g_{kx_i}\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)}\right|-\sum_{j=1}^{m}(-1)^{j-1}g_{ky_j}\left|\frac{\partial(g_1,\dots,g_m)}{\partial(x_i,y_1\dots,y_{j-1},y_{j+1},\dots,y_m)}\right|
\]
注意到,该式可以看作行列式:
\[D_{ki}=\left|
\matrix{
g_{kx_i} &g_{ky_1} &g_{ky_2} &\dots  &g_{ky_m}\\
g_{1x_i} &g_{1y_1} &g_{1y_2} &\dots  &g_{1y_m}\\
g_{2x_i} &g_{2y_1} &g_{2y_2} &\dots  &g_{2y_m}\\
\vdots   &\vdots   &\vdots   &\vdots &\vdots\\
g_{mx_i} &g_{my_1} &g_{my_2} &\dots  &g_{my_m}
}
\right|
\]
按第一行展开,那么由于第\(1\)行与第\(k+1\)行相同,故:
\[\nabla g_k\cdot (0,\dots,0,\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)}\right|,0,\dots,0,\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)_{y_1\rightarrow x_i}}\right|,\dots,\left|\frac{\partial(g_1,\dots,g_m)}{\partial(y_1,\dots,y_m)_{y_m\rightarrow x_i}}\right|)\\=D_{ki}=0
\]
那么,可以得到\(\nabla g_1, \nabla g_2,\dots,\nabla g_m\)均满足\(\nabla f\)的条件。
将\(\nabla f\)看作\(n+m\)个未知数组成的向量,那么约束即为\(m\)个方程。
其系数矩阵为:
\[\mbox{A}=
\left(
\matrix{
1      &0      &\dots  &0      &y_{1x_1} &y_{2x_1} &\dots  &y_{mx_1}\\
0      &1      &\dots  &0      &y_{1x_2} &y_{2x_2} &\dots  &y_{mx_2}\\
\vdots &\vdots &\vdots &\vdots &\vdots   &\vdots   &\ddots &\vdots \\
0      &0      &\dots  &1      &y_{1x_n} &y_{2x_n} &\dots  &y_{mx_n}
}
\right)
\]
其方程为:
\[\left(
\matrix{
1      &0      &\dots  &0      &y_{1x_1} &y_{2x_1} &\dots  &y_{mx_1}\\
0      &1      &\dots  &0      &y_{1x_2} &y_{2x_2} &\dots  &y_{mx_2}\\
\vdots &\vdots &\vdots &\vdots &\vdots   &\vdots   &\ddots &\vdots \\
0      &0      &\dots  &1      &y_{1x_n} &y_{2x_n} &\dots  &y_{mx_n}
}
\right)
(\nabla f)^{\mbox{T}}=0
\]
显然,有\(rank(\mbox{A})=n\),
可知,其解空间维数为\(\dim \mbox{V}= n+m-\mbox{rank}(\mbox{A})= m\)。
而正好\(\nabla g_1,\dots,\nabla g_m\)线性无关,故\(\nabla f\in \mbox{V}\)。
那么,就有:
\[\nabla f = \sum_{i=1}^m \lambda_i\nabla g_i
\]
这时,不妨令\(x_{n+i}=y_i\)写成分量的形式,即:
\[\left\{
\matrix{
f_{x_1}-\displaystyle\sum_{i=0}^m \lambda_ig_{ix_1}=0\\
\dots\\
f_{x_{n+m}}-\displaystyle\sum_{i=0}^m \lambda_ig_{ix_{n+m}}=0\\
}
\right.
\]
即为拉格朗日函数\(L(x_1,\dots,x_{n+m})=f(x_1,\dots,x_{n+m})-\displaystyle\sum_{i=0}^m \lambda_ig_{i}\)的由来。