Using a Lagrange multiplier is a method of finding an extreme value of a function with a constraint; for example, finding the extreme values of f(x,y,z) which is constrained by g(x,y,z)=k . This will occur when the contour lines of the function are parallel, the gradients will therefore be parallel as well (since the gradient vector is always orthogonal to the contour lines). As such, the Lagrange multiplier \lambda is a scalar such that

\nabla f(x,y,z)=\lambda\nabla g(x,y,z)

Which results in four unknowns and four equations.

f_x=\lambda g_x,f_y=\lambda g_y,f_z=\lambda g_z,g(x,y,z)=k

This can be represented more concisely with the Lagrangian function

\mathcal{L}(x, y, z,\lambda)=f(x,y,z)+\lambda\,g(x,y,z)+c


Suppose we have a small box with a volume of 580 cm3. We want to find the minimum surface area with which we can construct the box.


The function to be extremized is S(l,w,h) . We will now create a new function, L .

\nabla V(l,w,h)=\lambda\nabla S(l,w,h)
V_l=\lambda S_l,V_w=\lambda S_w,V_h=\lambda S_h,V(l,w,h)=580

There is no one way to solve this system. In this case, w,h,l are 8.33955, indicating that the minimum surface area which can be used for a given volume is that of a perfect cube. Solutions are often impossible to derive analytically and must be approximated. Note that \lambda does not need to be found explicitly.