See Lagrange multipliers Suppose we are minimizing

subject to . This is equivalent to minimizing:

Note that here does not depend on because we are only taking . On the other hand, suppose the condition was . Then we want to minimize:

This way, the Euler-Lagrange for the function will give condition .