"Lagrange Multipliers" is the name given to a method of finding the extrema of a function subject to a constraint.
Suppose you have an objective function, f(x,y,z), that you wish to minimize (or maximize) subject to the constraint g(x,y,z)=c. Imagine the shape of the contours of f as the value of f increases. At some point, as you blow f up like a balloon, its surface will touch the constraint. At that point, the contour of f is exactly parallel to the constraint. That is, the gradient of f is parallel to the gradient of g at this constrained minimum. Being parallel means the gradient of f equals the gradient of g times some constant, called the lagrange multiplier. This boils down to the fact that all the partial derivatives of f equal the corresponding partial derivatives of g times the lagrange multiplier.
For simplicity, we start by defining the constraint function, g, so that g(x,y,z)=0 is the constraint we want. (If we started with the constraint g(x,y,z)=c, then we define a different function g(x,y,z)-c=0, and we simply call the new function g.)
Next, we want to find where the gradient of f(x,y,z) equals the gradient of −λg(x,y,z), so we define a new function, called the Lagrangian function,
F(x,y,z,λ) = f(x,y,z) + λg(x,y,z)
Now, we find the partial derivatives of F with respect to each of its four variables, and set them all to zero, giving us four equations in four unknowns. This gives us the stationary point(s) of F, and we have found the constrained maxima and minima of f.
Clearly this is not a good example, because the solution could not be found. This is a question that came up on NRICH, and it turned out that the student wasn't supposed to find a solution, just show that one exists!
Minimize f(x,y,z) = (x-x0)2+(y-y0)2+(z-z0)2 (the squared distance of x,y,z from the given point) subject to the constraint x2/a2+y2/b2+z2/c2-1=0 (it lies on the given ellipsoid).
F(x,y,z,λ) = (x-x0)2+(y-y0)2+(z-z0)2 + λ(x2/a2+y2/b2+z2/c2-1)
The partial derivatives are
dF/dx = 2(x-x0) + 2wx/a2
dF/dy = 2(y-y0) + 2wy/b2
dF/dz = 2(z-z0) + 2wz/c2
dF/dw = x2/a2+y2/b2+z2/c2-1
Setting these four equations to zero, and solving for x,y,z,λ,
0 = 2(x-x0) + 2wx/a2
0 = 2(y-y0) + 2wy/b2
0 = 2(z-z0) + 2wz/c2
0 = x2/a2+y2/b2+z2/c2-1
From the first three, we get
x = a2f/(a2+λ)
y = b2g/(b2+λ)
z = c2h/(c2+λ)
Substituting these values of x, y, z into the fourth equation gives us
0 = (a2f/(a2+λ))2/a2+(b2g/(b2+λ))2/b2+(c2h/(c2+λ))2/c2-1
which simplifies to
0 = a2f2/(a2+λ)2+b2g2/(b2+λ)2+c2h2/(c2+λ)2-1
Unfortunately, I wasn't able to find a solution to this equation.
The webmaster and author of this Math Help site is Graeme McRae.