Lagrange multipliers can be used to find the extreme of a multivariate function
$f\left({x}_{1},{x}_{2},\mathrm{...},{x}_{n}\right)$
subject to the constraint
$g\left({x}_{1},{x}_{2},\mathrm{...},{x}_{n}\right)=0$

Where,
$f$
and
$g$
are functions with continuous first partial derivatives on the open
set containing the constraint curve, and
$\nabla g\ne 0$
at any point on the curve (where
$\nabla $
is the gradient).

To find the extreme, write:

(1)
$$df=\frac{\partial f}{\partial {x}_{1}}d{x}_{1}+\frac{\partial f}{\partial {x}_{2}}d{x}_{2}+\mathrm{...}+\frac{\partial f}{\partial {x}_{n}}d{x}_{n}=0$$

But, because

$g$
is being held constant, it is also true that

(2)
$$dg=\frac{\partial g}{\partial {x}_{1}}d{x}_{1}+\frac{\partial g}{\partial {x}_{2}}d{x}_{2}+\mathrm{...}+\frac{\partial g}{\partial {x}_{n}}d{x}_{n}=0$$

So multiply

Equation 2 by the as yet undetermined
parameter

$\lambda $
and add to

Equation 2,

(3)
$$\left(\frac{\partial f}{\partial {x}_{1}}+\lambda \frac{\partial g}{\partial {x}_{1}}\right)d{x}_{1}+\left(\frac{\partial f}{\partial {x}_{2}}+\lambda \frac{\partial g}{\partial {x}_{2}}\right)d{x}_{2}+\mathrm{...}+\left(\frac{\partial f}{\partial {x}_{n}}+\lambda \frac{\partial g}{\partial {x}_{n}}\right)d{x}_{n}=0$$

Note that the differentials are all independent, so any combination of
them can be set equal to 0 and the remainder must still give zero. This requires
that:

(4)
$$\left(\frac{\partial f}{\partial {x}_{k}}+\lambda \frac{\partial g}{\partial {x}_{k}}\right)d{x}_{k}=0$$

for all k = 1, ..., n, and the constant

$\lambda $
is called the Lagrange multiplier. For multiple constraints,

${g}_{1}=0$
,

${g}_{2}=0$
, ...,

(5)
$$\nabla f={\lambda}_{1}\nabla {g}_{1}+{\lambda}_{2}\nabla {g}_{2}+\mathrm{...}$$

The Lagrange multiplier method can be applied to contact-impact
problems. In this case, the multivariate function is the expression of total energy subjected to
the contact conditions:

(6)
$$f\left({x}_{1},{x}_{2},\mathrm{...},{x}_{n}\right)\equiv \Pi (x,\dot{x},\ddot{x})$$

(7)
$$g\left({x}_{1},{x}_{2},\mathrm{...},{x}_{n}\right)\equiv Q(x,\dot{x},\ddot{x})=0$$

Where,

$x,\dot{x},\ddot{x}$
are the global vectors of DOF. The application of Lagrange multiplier method
to the previous equations gives the weak form as:

(8)
$$M\ddot{x}+{f}_{int}-{f}_{ext}+L\lambda =0$$

This leads to:

(10)
$$\left[\begin{array}{cc}K& {L}^{T}\\ L& 0\end{array}\right]\left\{\begin{array}{c}x\\ \lambda \end{array}\right\}=\left\{\begin{array}{c}f\\ 0\end{array}\right\}$$

The Lagrange multipliers are physically interpreted as surface
tractions. The equivalence of the modified virtual power principle with the momentum equation,
the traction boundary conditions and the contact conditions (impenetrability and surface
tractions) can be easily demonstrated. ^{1}

It is emphasized that the above weak form is
an inequality. In the discretized form, the Lagrange multiplier fields will be discretized and
the restriction of the normal surface traction to be compressive will result from constraints on
the trial set of Lagrange multipliers.