#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
f′(x) = fx + fy y′ = 0,
(1)
where y′ in Eq.(1) can be obtained from g(x, y) = 0 as
y′ = − gx

gy
.
(2)
Substituting Eq.(2) to Eq.(1) yields

fx

gx
= fy

gy
≡ λ,
(3)
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

f*f(x, y) − λg(x, y),
(4)
without any constraint, i.e. partially differentiating Eq.(4) with respect to x, y and λ as
f*

x
=
fx − λgx = 0,
(5)
f*

y
=
fy − λgy = 0,
(6)
f*

∂λ
=
g = 0.
(7)
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 + z2min
(8)

subject to g(x, y, z) = a x + b y + c zd = 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.

f*

x
=
2 x− λa = 0,
(10)
f*

y
=
2 y− λb = 0,
(11)
f*

z
=
2 z− λc = 0,
(12)
f*

∂λ
=
a x + b y + c zd = 0.
(13)
Solving the above set of simultaneous equations yields

x
=
λa

2
(14)
y
=
λb

2
(15)
z
=
λc

2
(16)
λ
=
2 d

a2 + b2 + c2
,
(17)
or equivalently

x
=
ad

a2 + b2 + c2
(18)
y
=
bd

a2 + b2 + c2
(19)
z
=
cd

a2 + b2 + c2
,
(20)
so the minimum distance is


 

x2 + y2 + z2
 
= d




a2 + b2 + c2
.
(21)
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.
lagrange_multi.jpg
The plane, a x + b y + c z = d, is also expressed as

a·x = d,
(22)
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

x = t a,
(23)
where t is a parameter. By substituting Eq.(23) into Eq.(22), one obtains

a ·ta = t a·a = d.
(24)
Hence, t can be solved as
t = d

a·a
.
(25)
From Eq.(23), it follows
x = d

a·a
a,
(26)
and the length of x is

| x |
=
| d

a·a
a |
=
d

|a|2
|a|
=
d

|a|
=
d



 

a2 + b2 + c2
 
.
(27)

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

f*

x
=
2 (x − 1) − 3 x2 λ = 0,
(28)
f*

y
=
2 y + 4 y λ = 0,
(29)
f*

∂λ
=
x3 + 2 y2 = 0.
(30)
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
 
=   ⎛


7

27
 
 ∼ 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.