I'm new to Calculus of variations and have a very basic question. Suppose we want to solve the Lagrangian $L=\ddot{q}^2$ using the Euler-Lagrange equation.
My intuition tells me that the solution should be $\ddot{q}=0$, as any other function would result in a larger functional value. Indeed, if I were to substitute $w$ for $\ddot{q}$, we would have $L=w^2$, and applying the Euler-Lagrange equation we would get the solution $w=\ddot{q}=0$.
However, if we apply the higher-order Euler-Lagrange equation directly to $L=\ddot{q}^2$, we obtain $\frac{d^4 q}{dt^4} = 0$. What's going on here?