Lagrange multiplier method
Let $\mathcal{X}\subseteq \R^n$, $f: \mathcal{X}\to\R$, and $h: \R^n \to\R^m$.
$$ \begin{align*} \text{Minimise } & f(\v x) \\ \text{over } & \v x\in\mathcal{X} \\ \text{subject to } & h(\v x) = \v b. \end{align*} $$
We can transform this constrained optimisation problem to an unconstrained one:
$$ \begin{align*} \text{Minimise } & L(\v x, \lambda) = f(\v x) - \v \lambda^T(h(\v x) - \v b), \quad \text{the ``Lagrangian"}, \\ \text{over } &\v x\in\mathcal{X}. \\ \end{align*} $$
This gives a penalty of $-\v \lambda^T$ per unit of constraint violation.
Note that this is just a sufficient condition, not a necessary one.
Example