Many ODE's and PDE's arising in nature have a variational formulation. An example of what I mean is the following. Classical motions are solutions $q(t)$ to Lagrange's equation
$$
\frac{d}{dt}\frac{\partial L(q,\dot q)}{\partial\dot q}=\frac{\partial L(q,\dot q)}{\partial q},
$$
and these are critical points of the *functional*
$$
I(q)=\int L(q,\dot q)dt.
$$
Of course one needs to be precise with what considers a solution to both equations. This amounts to specifying regularity and a domain of the functional. This example is an ODE, but many PDE examples are possible as well (for example electromagnetism, or more exotic physical theories). Once one knows a variational description of the problem, many more methods are available to solve the problem. 


Now I do not expect that any PDE or ODE can be viewed (even formally) as a critical point of a suitable action functional. This is because this whole set up reminds me of De Rham cohomology: "which one-forms (the differential equations) are exact (that is, the $d$ of a functional)?". The last sentence is not correct, but the analogy maybe is? Anyway, my question is:



> 
> Are there any criteria to determine if a given differential equation admits a variational formulation?
> 
> 
> 



Which differential equations allow for a variational formulation?
Others give useful references that discuss what is known about the answer, but no statement of the answer itself. The relevant algebraic setting is the variational bicomplex, which is discussed in the works of Anderson and others. In this setting, there are two differentials, the horizontal differential $d\_H$ (representing derivatives with respect to independent variables like $t$) and the vertical differential $d\_V$ (representing variational derivatives with respect to dependent variables like $q(t)$). Each of these differentials is "de Rham-like" and they anticommute with each other, which explains the cohomological flavor of the answer. A rough statement of the answer is as follows.


A Lagrangian $L$ density gives rise to a set of Euler-Lagrange equations $E\_i=0$ as follows:
$$ d\_V L = E\_i ~ d\_V q^i - d\_H\theta , $$
that is, the vertical 1-form $E\_i ~ d\_V q^i$ is vertically exact (up to a horizontally exact term $d\_H \theta$). So, it is **necessary** for $E\_i=0$ to be the Euler-Lagrange system of some Lagrangian that $E\_i ~ d\_V q^i$ is closed up to a horizontally exact term, namely
$$ d\_V(E\_i~d\_V q^i) = d\_H \theta' (= -d\_H d\_V \theta) . $$
In fact, the same condition is also **sufficient**, up to obstructions related to the global topology of the manifold where the dependent variables $q$ take their values. This condition was formulated already classically by [Helmholtz](http://en.wikipedia.org/wiki/Inverse_problem_for_Lagrangian_mechanics).


However, the above statement is restrictive in that it answers the question only when $E\_i=0$ is already in Euler-Lagrange form. However, there are many transformations that one can apply to the system $E\_i=0$ that gives an equivalent system $F\_a=0$. Given only the system $F\_a=0$, is it still possible to decide whether it is equivalent to some system $E\_i=0$ in Euler-Lagrange form? This is the hard inverse problem (aka the *multiplier problem*). The only general result that I'm aware of in that direction is this.



> 
> If there exists a form $\omega$ of vertical degree 2 and horizontal degree $n-1$, where $n$ is the number of independent variables, such that it is both horizontally and vertically closed modulo the equations $F\_a=0$ (namely $d\_V \omega = A^a F\_a$ and $d\_H \omega = B^a F\_a$), then there exists (again, up to global topological obstructions) a Lagrangian density $L$ whose Euler-Lagrange equations $E\_i=0$ are equivalent to a *subsystem* of $F\_a=0$.
> 
> 
> 


To my knowledge, the above observation first appeared in Henneaux ([AnnPhys](http://dx.doi.org/10.1016/0003-4916%2882%2990334-7), 1982) for ODEs and in Bridges, Hydon & Lawson ([MathProcCPS](http://dx.doi.org/10.1017/S0305004109990259), 2010) for PDEs. The calculation demonstrating this observation is given in a bit more detail on this [nLab page](http://ncatlab.org/nlab/show/phase+space#InverseProblem). (**Edit:** At risk of shameless self-promotion, I'll also note that I collected these observations in a self-contained paper ([arXiv](http://arxiv.org/abs/1210.0802); [JMP](http://dx.doi.org/10.1063/1.4828666), 2013).)


It reduces the solution of the hard inverse problem to classifying all such forms $\omega$ (corresponding to the so-called *characteristic cohomology* of the variational bicomplex restricted to $F\_a=0$ in the corresponding degree) and checking that there exists a candidate that gives rise to a Lagrangian density whose Euler-Lagrange system $E\_i=0$ is equivalent to the *full* system $F\_a=0$. The calculation of the corresponding characteristic cohomology of the system $F\_a=0$ is still non-trivial, but there exist ways of attacking it, which include Vinogradov's $\mathcal{C}$-spectral sequence mentioned in other responses.


