TITLE: Which differential equations allow for a variational formulation?
QUESTION [33 upvotes]: 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?

REPLY [2 votes]: Well this is a classical problem known as "The inverse problem in the calculus of variations". There is a huge amount of references on the problem you can google at.  The problem as if the system $y_i''=F(x,y_j,y_j')$, $i=1,2,..,n$ can be identified with extremals of the equation $\int \phi(x,y_j,y_j') \rightarrow min$ amounts to solving the system of pdes for the partial derivatives of $\phi$, say $\phi_{ij}$. Davis [1928] restated the problem as that of finding an integrating factor $P_{ij}$ such that the system $P_{ij}(F_j-y_j'') = E(\phi)$,where $E$ denotes the Euler-Lagrange operato. There appears some condition on self-adjointness The case $n=2 $ was solved by the first Field medalist Jesee Douglas (1941). He used Riquier-Janet theory. For $n>2$ it remain possible except for cumbersome cases. Spencer and Quillen introduced the Spence cohomology to give suficient conditions for the overdetermined system to become integrable. Some references:
1) The inverse problem on the calculus of variations\ldots W. Sarlet, G. thompson, G.E.  Prince. TAMS 354, Num.7, 2897-2919, 2002.
2) Overdetermined systems of linear PDEs. D.C. Spencer., 1969 (sorry Idon't have the complete reference at hand).
3)J. Douglas. Solution to the inverse problem of the calculus of variations. TAMS 50 (1941), 71-128.
Professor Peter Olver (University of Minnesota) is probably one of the major authorities on the topic.