In general terms, Lagrange's identity for any pair of functions u and v in function space C2 (that is, twice differentiable) in n dimensions is:[1]
where:
and

The operator L and its adjoint operator L* are given by:
and
![{\displaystyle L^{*}[v]=\sum _{i,\ j=1}^{n}{\frac {\partial ^{2}(a_{i,j}v)}{\partial x_{i}\partial x_{j}}}-\sum _{i=1}^{n}{\frac {\partial (b_{i}v)}{\partial x_{i}}}+cv.}](//wikimedia.org/api/rest_v1/media/math/render/svg/2cda75f614ac11fe6747ff950ea12ace83519575)
If Lagrange's identity is integrated over a bounded region, then the divergence theorem can be used to form Green's second identity in the form:
![{\displaystyle \int _{\Omega }vL[u]\,d\Omega =\int _{\Omega }uL^{*}[v]\ d\Omega +\int _{S}{\boldsymbol {M\cdot n}}\,dS,}](//wikimedia.org/api/rest_v1/media/math/render/svg/825ddda2c47b8638a79efac13e3646ac88e7f91a)
where S is the surface bounding the volume Ω and n is the unit outward normal to the surface S.
Ordinary differential equations
Any second order ordinary differential equation of the form:
can be put in the form:[2]

This general form motivates introduction of the Sturm–Liouville operator L, defined as an operation upon a function f such that:

It can be shown that for any u and v for which the various derivatives exist, Lagrange's identity for ordinary differential equations holds:[2]
![{\displaystyle uLv-vLu=-{\frac {d}{dx}}\left[p(x)\left(v{\frac {du}{dx}}-u{\frac {dv}{dx}}\right)\right].}](//wikimedia.org/api/rest_v1/media/math/render/svg/5e2a774b6dabec972f4579c2221eeefde4d355ee)
For ordinary differential equations defined in the interval [0, 1], Lagrange's identity can be integrated to obtain an integral form (also known as Green's formula):[3][4][5][6]
![{\displaystyle \int _{0}^{1}dx\ (uLv-vLu)=\left[p(x)\left(u{\frac {dv}{dx}}-v{\frac {du}{dx}}\right)\right]_{0}^{1},}](//wikimedia.org/api/rest_v1/media/math/render/svg/675ca8c7fdff38c6a51a71ed5345936266c52d4c)
where
,
,
and
are functions of
.
and
having continuous second derivatives on the interval
.
We have:
and
![{\displaystyle vLu=v\left[{\frac {d}{dx}}\left(p(x){\frac {du}{dx}}\right)+q(x)u\right].}](//wikimedia.org/api/rest_v1/media/math/render/svg/152fd1d103a7c18abf78434623a5dd5e73028d10)
Subtracting:

The leading multiplied u and v can be moved inside the differentiation, because the extra differentiated terms in u and v are the same in the two subtracted terms and simply cancel each other. Thus,
which is Lagrange's identity. Integrating from zero to one:
as was to be shown.