Suppose I want to find solution to a general nth order differential equation. (If I am right about the logic then) one might say that the solution $y\equiv y(x)$ is that function for which the following action is stationary.
$$ S=\int_{x_1}^{x_2} f\ dx $$
where function $f$ some suitable function. And $\delta S = 0$ will give the equation to be solved to find the solution.
My question is should I consider $f\equiv f(y,\dot{y},\ddot{y},...; x)$ or simply $f\equiv f(y,\dot{y}; x)$. (here $\dot{y}=\frac{dy}{dx}$)
I remember reading in landau-lifschitz that $q$ and $\dot{q}$ are enough to since higher derivatives depend upon them. So last one seems correct but I think nth order differential equation ought to have the $\ddot{q}$ and higher derivatives as variables.
Note I am not just looking for solution of the some physical problem but also some general mathematical problem which may not have any physical basis.