#08 (09/14/2023)
Application:Lagrange multiplier
As an application of the theory of implicit functions, the Lagrange
multiplier method is discussed here.
We want to extremize f(x, y)
subject to the constraint, g(x, y) = 0.
Assuming g(x, y) = 0 can be
solved for y as y = y(x), this is substituted into the object
function of f(x, y) as f(x, y(x)) thus we can look at f(x, y(x)) as
a function of x.
The candidates of x's to extremize f can be
obtained by differentiating f with respect to x as
where y′ in Eq.(1) can be obtained from g(x, y) = 0 as
Substituting Eq.(2) to Eq.(1) yields
where λ is a newly introduced parameter called the Lagrange multiplier.
The development above implies that when extremizing f(x, y)
subject to g(x, y) = 0, instead of working on f(x, y), one can
try extremizing
without any constraint, i.e. partially differentiating
Eq.(4) with respect to x, y and λ
as
The above equations form a set of simultaneous equations for x, y and λ.
Example 1
Find the shortest distance from the origin (0, 0, 0)
to the plane, a x + b y + c z = d.
f(x, y, z) = x2 + y2 + z2 → min |
| (8) |
subject to g(x, y, z) = a x + b y + c z − d = 0. |
| (9) |
Instead of minimizing f(x, y, z) with the constraint, one can try
minimizing f*(x, y, z) ≡ f(x, y, z) − λg(x, y, z)
with respect to x, y, z and λ without any
constraint.
Solving the above set of simultaneous equations yields
or equivalently
so the minimum distance is
Alternative approach: Read the problem as
Find the shortest distance from the origin (0, 0, 0)
to the plane, a x + b y + c z = d.
The plane, a x + b y + c z = d, is also expressed as
where a = (a, b, c) and x = (x, y, z). Equation (22) implies that
the vector a is perpendicular to the plane (as was shown in class). Hence, the
vector from the origin that minimizes the distance to the plane must be expressed as
where t is a parameter. By substituting Eq.(23) into Eq.(22), one obtains
Hence, t can be solved as
From Eq.(23), it follows
and the length of x is
Example 2
Find the shortest distance from (1, 0) to x3 − 2 y2 = 0.
(Solution)
Let
f* ≡ (x −1)2 + y2 − λ(x3 − 2 y2), |
|
it follows
The above equations can be solved as (real roots)
(x, y, λ) = ( |
2
3
|
, |
2
3 √3
|
, − |
1
2
|
) or ( |
2
3
|
, − |
2
3 √3
|
, − |
1
2
|
), |
| (31) |
both of which yield
d = | √
|
(x−1)2 + y2
|
= |
⎛ √
|
|
∼ 0.509175. |
| (32) |
Sample MATLAB/Octave code:
x=1; y=1; lambda=1;
for i=0:10
eqs=[ 2*(x-1)-3*x*x*lambda ; 2*y+4 *y *lambda ; -x^3+2*y*y];
jacob=[2-6*x*lambda, 0, -3*x*x; 0, 2+4*lambda, 4*y; -3*x*x, 4*y, 0];
right=inv(jacob)*eqs;
x=x-right(1);
y=y-right(2);
lambda=lambda-right(3);
end;
fprintf('%f %f %f\n', x, y,lambda);
Online C compiler
Online MATLAB/Octave
Wolfram Alpha
File translated from
TEX
by
TTH,
version 4.03.
On 13 Sep 2023, 21:59.