📚 Restricted Maxima and Minima: The Lagrange Multiplier | 受限极值:拉格朗日乘数法
In many real-world scenarios, we need to find the maximum or minimum of a function not over its entire domain, but while satisfying a specific condition or constraint. A classic example is maximising the area of a rectangle given a fixed perimeter. Direct substitution can sometimes solve these problems, but when the constraint is complicated or the function involves several variables, a more powerful method is required. The Lagrange multiplier technique provides an elegant, systematic way to locate such restricted extrema. It transforms a constrained optimisation problem into an unconstrained problem by introducing an auxiliary variable, λ.
在许多实际情景中,我们需要在满足特定条件或约束的情况下求函数的最大值或最小值,而不是在整个定义域上求极值。一个经典例子是在周长固定的前提下最大化矩形面积。直接代入法有时可以解决这类问题,但当约束条件复杂或函数包含多个变量时,就需要一种更强大的工具。拉格朗日乘数法提供了一种优雅、系统的方法来寻找这类受限极值。它通过引入一个辅助变量λ,将约束优化问题转化为无约束问题。
1. Understanding Constrained Optimization | 理解约束优化
is different from free optimisation, where we simply set partial derivatives to zero. The constraint restricts the domain to a specific subset, often a lower-dimensional manifold.
约束优化是指寻找满足约束条件 g(x, y, ...) = k(k 为常数)的点,使得函数 f(x, y, ...) 取得最优值。从几何角度看,我们是在由 g = k 定义的曲线或曲面上寻找 f 的最大值或最小值。这与自由优化不同,在自由优化中只需令偏导数为零。约束条件将定义域限制在一个特定的子集上,通常是一个低维流形。
in. Solving this by substituting the constraint into f reduces the number of variables, but the Lagrange multiplier method avoids messy algebra and scales elegantly to higher dimensions.
例如,若 f(x, y) = x² + y² 表示到原点距离的平方,约束为 y = x + 1,那么我们要在直线 y = x + 1 上寻找离原点最近的点。通过将约束代入 f 可以减少变量个数,但拉格朗日乘数法避免了冗杂的代数运算,并且能够优雅地推广到更高维度。
2. Introducing the Lagrange Multiplier Method | 引入拉格朗日乘数法
function f must be parallel to the gradient of the constraint function g. In other words, ∇f = λ ∇ y direction tangent to the curve should give zero directional derivative for f at the extremum, meaning ∇f has no component perpendicular to ∇g except one that is a multiple of ∇g.
核心思想源于这样一个事实:在局部受限极值点处,目标函数 f 的梯度必须与约束函数 g 的梯度平行。换言之,存在某个标量 λ,使得 ∇f = λ ∇g。这个标量 λ 被称为拉格朗日乘数。推导过程可以这样理解:沿着约束曲线,任何与曲线相切的方向在极值点处的方向导数都应为零,这意味着 ∇f 在 ∇g 的垂直方向上没有分量,只能是 ∇g 的倍数。
tem yields the candidate extremum points. The method naturally extends to three or more variables and multiple constraints, though in IB HL Mathematics we typically focus on one constraint and up to three variables.
对于双变量函数和一个约束 g(x, y) = k,我们列出方程组:∂f/∂x = λ ∂g/∂x,∂f/∂y = λ ∂g/∂y,以及 g(x, y) = k。求解该方程组即可得到可能的极值点。该方法自然可以推广到三个或更多变量以及多个约束条件,不过在 IB HL 数学中,我们通常只处理一个约束和至多三个变量的情形。
3. The Lagrangian Function | 拉格朗日函数
t equation exactly recovers the constraint g(x, y) = k. This transforms the problem into unconstrained calculus in one higher dimension.
为了构造紧凑的表达形式,我们定义拉格朗日函数 L 为 L(x, y, λ) = f(x, y) − λ (g(x, y) − k)。这里 λ 被视为一个额外的变量。f 的受限极值对应 L 的驻点,即所有偏导数为零的点:∂L/∂x = 0,∂L/∂y = 0,∂L/∂λ = 0。最后一个方程恰好还原了约束条件 g(x, y) = k。这便将问题转化为高一维空间中的无约束微积分问题。
hich merely flips the sign of λ. The choice is a matter of convention and does not affect the location of the extremum. The beauty of the Lagrangian is that it consolidates both the optimisation goal and the restriction into a single function amenable to standard differentiation techniques.
有些教材将拉格朗日函数写成 L(x, y, λ) = f(x, y) + λ (k − g(x, y)),这仅仅改变了 λ 的符号。选择哪种形式只是习惯问题,并不影响极值点的位置。拉格朗日函数的优美之处在于它将优化目标与限制条件整合为一个单一函数,便于使用标准的求导技术进行处理。
4. Solving the System of Equations | 求解方程组
Once the Lagrangian is formed, we compute the partial derivatives and set them to zero. For a two-variable problem, this gives three equations. The typical strategy is to eliminate λ from the first two equations, yielding a relationship between x and y, then use the constraint to solve for the coordinates. Care must be taken to handle cases where partial derivatives of g are zero, as division by zero can lose solutions.
一旦构造出拉格朗日函数,我们便求其偏导数并令其为零。对于双变量问题,这会得到三个方程。典型的策略是从前两个方程中消去 λ,得出 x 与 y 之间的关系,然后利用约束条件求出坐标。必须注意处理 g 的偏导数为零的情形,因为除以零可能导致遗漏解。
t gives 2x = 1, hence x = y = 1/2, λ = 1. The minimum value of f is (1/2)² + (1/2)² = 1/2.
考虑 f(x, y) = x² + y² 在约束 x + y = 1 下的极值。拉格朗日函数为 L = x² + y² − λ(x + y − 1)。令偏导数为零:∂L/∂x = 2x − λ = 0,∂L/∂y = 2y − λ = 0,∂L/∂λ = −(x + y − 1) = 0。由前两式得 2x = λ 且 2y = λ,故 x = y。代入约束得 2x = 1,于是 x = y = 1/2,λ = 1。f 的最小值为 (1/2)² + (1/2)² = 1/2。
5. Geometric Interpretation | 几何解释
the level curve of f is tangent to the constraint curve. This tangency condition implies that their gradient vectors are parallel, which is exactly the Lagrange multiplier condition ∇f = λ ∇ moving along the constraint curve would increase or decrease f, contradicting optimality.
从几何角度看,约束条件 g(x, y) = k 定义了平面上的一条曲线。f 的等值线是 f 为常数的曲线。在最优点处,f 的等值线与约束曲线相切。这一相切条件意味着它们的梯度向量平行,这正是拉格朗日乘数条件 ∇f = λ ∇g。如果它们不平行,沿约束曲线移动就会使 f 的值增大或减小,这与最优性相矛盾。
This insight helps visualise why the method works. For a hill-shaped f, the constrained maximum is the highest point that touches the constraint curve while keeping f constant. The Lagrange multiplier λ can be interpreted as the rate of change of the optimal value of f with respect to the constraint constant k, offering a sensitivity measure.
这一见解有助于直观理解该方法的原理。对于山丘状的 f 函数,受限最大值就是在保持 f 不变的情况下与约束曲线相切的最高点。拉格朗日乘数 λ 可以解释为 f 的最优值相对于约束常数 k 的变化率,从而提供了一种灵敏度度量。
6. Example 1: Rectangular Area Maximization | 示例1:矩形面积最大化
x − λ = 0, and x + y = 100. From the first two, y = λ and x = λ, so x = y. Substituting into the constraint gives 2x = 100, so x = 50, y = 50. The maximum area is 2500 m².
一位农民有 200 米围栏,希望围出一个矩形场地使面积最大。设矩形的边长分别为 x 和 y。目标函数是面积 A = xy。约束条件是周长 2x + 2y = 200,即 x + y = 100。建立拉格朗日函数:L = xy − λ(x + y − 100)。于是 ∂L/∂x = y − λ = 0,∂L/∂y = x − λ = 0,且 x + y = 100。由前两式得 y = λ,x = λ,故 x = y。代入约束得 2x = 100,因此 x = 50,y = 50。最大面积为 2500 平方米。
/∂k where k is the perimeter constant, matching the interpretation of λ as a shadow price.
这个经典例子表明,在给定周长下正方形面积最大。该方法还确定了 λ = 50,这表示若增加一米围栏所能获得的额外面积。此时,由于 A = xy 且 x=y=50,λ = ∂A*/∂k,其中 k 是周长的常数值,这符合 λ 作为影子价格的解释。
7. Example 2: Three-Variable Optimization | 示例2:三变量优化
tituting into the constraint: (1/(2λ))² + (1/λ)² + (3/(2λ))² = 1. Compute: (1/(4λ²)) + (1/λ²) + (9/(4λ²)) = (1+4+9)/(4λ²) = 14/(4λ²) = 7/(2λ²) = 1. Hence λ² = 7/2, λ = ±√7/2.
求函数 f(x, y, z) = x + 2y + 3z 在约束 x² + y² + z² = 1 下的极值。构造拉格朗日函数:L = x + 2y + 3z − λ(x² + y² + z² − 1)。求偏导数得 ∂L/∂x = 1 − 2λx = 0,∂L/∂y = 2 − 2λy = 0,∂L/∂z = 3 − 2λz = 0,以及 x² + y² + z² = 1。用 λ 表示 x、y、z:x = 1/(2λ),y = 1/λ,z = 3/(2λ)。代入约束:(1/(2λ))² + (1/λ)² + (3/(2λ))² = 1。计算:(1/(4λ²)) + (1/λ²) + (9/(4λ²)) = (1+4+9)/(4λ²) = 14/(4λ²) = 7/(2λ²) = 1。因此 λ² = 7/2,λ = ±√7/2。
Plugging back, for λ = √7/2, we obtain x = 1/(2√7/2), y = 1/√7/2, z = 3/(2√7/2), and f evaluates to its maximum. For the negative λ, f takes its minimum. This illustrates the method's power in handling non-linear constraints in three dimensions without messy elimination.
代回原式,当 λ = √7/2 时,得到 x = 1/(2√7/2),y = 1/√7/2,z = 3/(2√7/2),此时 f 取得最大值。取负的 λ 时,f 取得最小值。这展示了该方法在处理三维非线性约束时的强大能力,无需进行复杂的消元操作。
8. Interpreting the Lagrange Multiplier λ | 解释拉格朗日乘数λ
m, if the fencing budget allowed 201 m instead of 200 m, the maximum area would increase by about 50 m². This interpretation is especially useful in economics, where λ is the shadow price of a scarce resource.
最优解处的 λ 值具有实际意义。它近似表示当约束常数 k 增加一个单位时,f 的最优值的变化量。严格来说,若记最优值为 f*(k),则 λ = df*/dk。在矩形问题中,若围栏预算允许使用 201 米而非 200 米,最大面积将增加约 50 平方米。这种解释在经济学中特别有用,λ 被称为稀缺资源的影子价格。
als the optimal f at the solution, λ measures the sensitivity. This property makes Lagrange multipliers a bridge between pure mathematics and applied fields such as physics (Lagrangian mechanics) and economics (utility maximization).
究其原因,考察拉格朗日函数 L(x, y, λ) = f − λ(g − k)。在驻点处,∂L/∂k = λ,因为 L 通过 −λ(−1) = λ 依赖于 k。由于在解的位置 L 等于最优的 f,故 λ 度量了敏感性。这一性质使得拉格朗日乘数成为纯数学与应用领域(如物理中的拉格朗日力学和经济学中的效用最大化)之间的桥梁。
9. Common Mistakes and How to Avoid Them | 常见错误及避免方法
f g without checking if it is zero. For example, if ∂g/∂x = 0 at some point, the condition ∇f = λ ∇g might require separate handling. Always consider both possibilities.
一个常见的错误是忘记对 λ 求导,而这一求导恰好给出约束条件。缺少这个方程会使方程组欠定。另一个陷阱是在未检查 g 的偏导数是否为零的情况下就直接相除。例如,如果在某点 ∂g/∂x = 0,那么条件 ∇f = λ ∇g 可能需要单独处理。应始终考虑两种可能情况。
ten in the form g(x, y) = k, not g(x, y) = 0 incorrectly matched. A sign error in the Lagrangian will flip λ but not the extremum locations, yet it can confuse the interpretation.
学生有时会混淆最大化与最小化。拉格朗日乘数法给出的是驻点;分类需要进一步分析。可以比较候选点处的函数值,或者考察加边海森矩阵。此外,务必确保约束写成 g(x, y) = k 的形式,而不是错误地混用 g(x, y) = 0。拉格朗日函数中的符号错误会翻转 λ,但不会改变极值位置,然而可能混淆解释。
10. Practice Problems | 练习题
nterpret λ in each case. Working through these will build fluency in the mechanical steps and deepen geometric insight.
尝试以下问题来巩固理解:求 f(x, y) = x² + y² 在约束 xy = 1 下的最小值;确定内接于椭圆 x²/9 + y²/4 = 1 的矩形面积最大值;对于三变量情形,在 x + y + z = 3 且 x, y, z > 0 的条件下优化 f(x, y, z) = xyz;并解释每种情况下的 λ。通过练习这些题目,你将熟练掌握机械步骤并加深几何直觉。
When solving, always write the Lagrangian, take derivatives, solve the system systematically, and evaluate f at each candidate. Verify that your solution satisfies the constraint. If the domain is bounded, also check boundary behaviour. With practice, the Lagrange multiplier method will become an indispensable tool in your IB Mathematics toolkit.
求解时,务必写出拉格朗日函数,求导,系统求解方程组,并在每个候选点处计算 f 的值。验证你的解满足约束条件。若定义域有界,还应检查边界行为。经过练习,拉格朗日乘数法将成为你 IB 数学工具箱中不可或缺的工具。
Published by TutorHao | Mathematics Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

或截图后用「扫一扫 → 相册」选择本图