
#08 (09/16/2024)
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);
fprintf('%f', sqrt((x-1)^2+y^2));
Online C compiler
Online MATLAB/Octave
Wolfram Alpha
Leibniz integral rule
The Leibniz integral rule is known as the Lagrangian derivative or the material
derivative in fluid mechanics.
Problem: Given
I(t) ≡ | ⌠ ⌡
|
b(t)
a(t)
|
f(x, t) d x, |
| (33) |
Find I′(t).
Approaches
- Method 1: (not discussed in class)
-
Let
F(x, t) ≡ | ⌠ ⌡
|
x
0
|
f(y, t) d y. |
| (34) |
Note that the integral variable has been changed to y from x to
avoid confusion with the upper bound so that
Using F(x, t), I(t) can be written as
I(t) = F(x, t)|x = b(t) − F(x,t)|x = a(t), |
| (36) |
hence
| |
|
| ⎛ ⎝
|
∂F
∂x
|
|x = b(t) |
db(t)
dt
|
+ |
∂F
∂t
|
|x = b(t) | ⎞ ⎠
|
− | ⎛ ⎝
|
∂F
∂x
|
|x = a(t) |
da(t)
dt
|
+ |
∂F
∂t
|
|x = a(t) | ⎞ ⎠
|
|
| |
| |
|
f(x,t)|x = b(t) |
db(t)
dt
|
−f(x,t)|x = a(t) |
da(t)
dt
|
+ |
∂F
∂t
|
|x = b(t)|− |
∂F
∂t
|
|x = a(t)| |
| |
| |
|
f(x,t)|x = b(t) |
db(t)
dt
|
−f(x,t)|x = a(t) |
da(t)
dt
|
+ | ⌠ ⌡
|
b(t)
0
|
|
∂f
∂t
|
dy − | ⌠ ⌡
|
a(t)
0
|
|
∂f
∂t
|
dy |
| |
| |
|
f(x,t)|x = b(t) |
db(t)
dt
|
−f(x,t)|x = a(t) |
da(t)
dt
|
+ | ⌠ ⌡
|
b(t)
a(t)
|
|
∂f
∂t
|
dy |
| |
| |
|
f(b(t), t) |
db(t)
dt
|
−f(a(t), t) |
da(t)
dt
|
+ | ⌠ ⌡
|
b(t)
a(t)
|
|
∂f
∂t
|
dy. |
| | (37) |
|
- Method 2:(discussed in class)
-
| |
|
|
| ⌠ ⌡
|
b + ∆b
a + ∆a
|
f(x, t + ∆t) dx − | ⌠ ⌡
|
b
a
|
f(x, t) dx |
∆t
|
|
| |
| |
|
|
| ⌠ ⌡
|
b
a
|
f(x, t + ∆t) dx + | ⌠ ⌡
|
b + ∆b
b
|
f(x, t + ∆t) dx− | ⌠ ⌡
|
a + ∆a
a
|
f(x, t + ∆t) d x − | ⌠ ⌡
|
b
a
|
f(x, t) dx |
∆t
|
|
| |
| |
|
| ⌠ ⌡
|
b
a
|
|
f(x, t + ∆t) − f(x, t)
∆t
|
dx + |
∆b
∆t
|
f(b, t)− |
∆a
∆t
|
f(a, t). |
| | (38) |
|
By letting ∆t → 0,
I′(t) = | ⌠ ⌡
|
b
a
|
|
∂f
∂t
|
dx + b′(t) f(b, t) − a′(t) f(a, t). |
| (39) |
Example 1
I(t) ≡ | ⌠ ⌡
|
t2
−t
|
sin (x2 t) dx. |
|
Example 2
Evaluate
I ≡ | ⌠ ⌡
|
1
0
|
|
x − 1
ln x
|
d x. |
|
by starting with this integral:
I(t) ≡ | ⌠ ⌡
|
1
0
|
|
xt−1
ln x
|
dx. |
|
Example 3
Evaluate
by starting with the known integral
Interpretation
The Leibniz integral rule is also known as the material derivative or the
Lagrangian derivative in fluid mechanics. The function, f(x, t), can be
interpreted as a physical quantity such as the mass density and
momentum that flows with a moving particle. The function, I(t), is
the collection of such a quantity over a region where the material is
defined. Therefore, a′(t) and b′(t) are the velocities of the
boundary of the material. With this interpretation, Eq.(39)
can be written as
| |
|
| ⌠ ⌡
|
b
a
|
|
∂f
∂t
|
dx +[ v f(x, t)]a(t)b(t) |
| |
| |
|
| ⌠ ⌡
|
b
a
|
|
∂f
∂t
|
dx + | ⌠ ⌡
|
b
a
|
|
d
dx
|
( v(x, t) f(x, t)) dx |
| |
| |
|
| ⌠ ⌡
|
b
a
|
| ⎛ ⎝
|
∂f
∂t
|
+ |
d
dx
|
( v(x, t) f(x, t)) | ⎞ ⎠
|
dx. |
| | (40) |
|
The result of Eq.(40) can be extended to two-dimensional space
as
I′(t) = | ⌠ ⌡
|
| ⌠ ⌡
|
Ω
|
| ⎛ ⎝
|
∂f
∂t
|
+∇·(v f) | ⎞ ⎠
|
dS, |
| (41) |
where
I(t) ≡ | ⌠ ⌡
|
| ⌠ ⌡
|
Ω
|
f(x, t) dS. |
|
If we interpret f(x, t) as the mass density, ρ(x,t),
M(t) ≡ ∫∫ρ(x, t) d s is the total mass of the material and
its material derivative must be 0 as the mass has to be conserved
in Newtonian mechanics. Thus,
| |
|
| ⌠ ⌡
|
| ⌠ ⌡
|
Ω
|
| ⎛ ⎝
|
∂ρ
∂t
|
+∇·(v ρ) | ⎞ ⎠
|
dS |
| |
| |
|
| | (42) |
|
which is equivalent to
which is known as the equation of continuity.
File translated from
TEX
by
TTH,
version 4.03.
On 16 Sep 2024, 14:33.