  Lagrangian formalism is established for differential equations with special
functions of mathematical physics as solutions. Formalism is based on either
standard or non-standard Lagrangians. This work shows that the procedure of
deriving the standard Lagrangians leads to Lagrangians for which the
Euler--Lagrange equation vanishes identically, and that only some of these
Lagrangians become the null Lagrangians with the well-defined gauge functions.
It is also demonstrated that the non-standard Lagrangians require that the
Euler--Lagrange equations are amended by the auxiliary conditions, which is a
new phenomenon in the calculus of variations. The~existence of the auxiliary
conditions has profound implications on the validity of the Helmholtz
conditions. The obtained results are used to derive the Lagrangians for the
Airy, Bessel, Legendre and Hermite equations. The presented examples clearly
demonstrate that the developed Lagrangian formalism is applicable to all
considered differential equations, including the Airy (and other similar)
equations, and that the regular and modified Bessel equations are the only ones
with the gauge functions. Possible implications of the existence of the gauge
functions for these equations are~discussed.
