Minimize here f(x,y,z) equal to (x − 5)2 + (y − 0)2 + (z − -7)2, constrained by
g(x,y,z) equal to x + y + z − 1 = 0.
∇f is [2(x − 5), 2y, 2(z + 7)]; ∇g is [1, 1, 1].
Equate ∇f to λ∇g. That is to say:
2x − 10 = λ;
2y = λ;
2z + 14 = λ.
This stack of equations leads to:
x = (10 + λ)/2;
y = λ/2;
z = (λ − 14)/2.
Place these last 3 expressions into x + y + z = 1 to reach
{10 + λ + λ + λ − 14}/2 = 1 which goes to 3λ − 4 = 2 or λ = 2.
Then take:
x = (10 + 2)/2 or 6;
y = 2/2 or 1;
z = (2 − 14)/2 or -6.
Obtain the distance sought as √[(6 − 5)2 + (1 − 0)2 + (-6 − -7)2] which reduces to √3.
*************************************************************************************
As confirmation, minimize the square of the distance between (5, 0, -7) and a chosen
point (x,y,z) that obeys x + y + z = 1.
Set down f(x,y,z) = (x − 5)2 + (y − 0)2 + (z − -7)2.
Consider z a function of x and y and take:
fx = 2(x − 5) + 2(z + 7)∂z/∂x;
fy = 2(y − 0) + 2(z + 7)∂z/∂y.
Now differentiate x + y + z = 1 with respect to x & y
to gain:
1 + ∂z/∂x = 0;
1 + ∂z/∂y = 0.
From this last, obtain ∂z/∂x = ∂z/∂y = -1.
Next equate fx = fy = 0 to enable:
(x − 5) + (z + 7)(-1) = 0;
(y − 0) + (z + 7)(-1) = 0.
Rewrite as:
x − z = 12;
y − z = 7.
From the last two equations, write
x − y = 5;
z = y − 7.
Finally, gain
x = y + 5;
z = y − 7.
Use x + y + z = 1 and write
(y + 5) + y + (y − 7) or 3y − 2 = 1 which gives y as 1.
This unlocks (x,y,z) as (6,1,-6).
Again, the distance sought is √[(6 − 5)2 + (1 − 0)2 + (-6 − -7)2] or √3
in agreement with the solution found by Lagrange Multipliers.