Higher-Order Derivatives in the Lagrangian I am trying to derive the equations of motion for a Lagrangian which depends on $(q, \dot{q}, \ddot{q}).$ I proceed by the typical route via Hamilton's Principle, $\delta S = 0$ by effecting a variation $\epsilon \eta$ on the path with $\eta$ smooth and vanishing on the endpoints. After some integrating by parts and vanishing of surface terms, I arrive at (to first order in $\epsilon$):
$$\delta S = \int\left[\eta\frac{\partial L}{\partial q} - \eta\frac{\mathrm{d}}{\mathrm{d} t}\left(\frac{\partial L}{\partial \dot{q}}\right) + \eta\frac{\mathrm{d}^2}{\mathrm{d}t^2}\left(\frac{\partial L}{\partial \ddot{q}}\right) + \frac{\mathrm{d}^2}{\mathrm{d}t^2}\left(\frac{\partial L}{\partial \ddot{q}} \eta \right)\right]\mathrm{d} t.$$
It is clear to me that either the last term in the integral above should vanish, or else I made an error and it ought not to appear at all. If it is the former case, by what argument does this term vanish?
 A: You have to impose that
$\eta(t_0)=\eta(t_1)=\dot{\eta}(t_0)=\dot{\eta}(t_1)=0$ where $t_0$ and $t_1$ are the endpoints of the time interval over which you are integrating. Then, the last term is:
\begin{equation}
\int_{t_0}^{t_1}\frac{d^2}{dt^2}
\left(\frac{\partial L}{\partial\ddot{q}}\eta\right)dt =
\left[\frac{d}{dt}\left(\frac{\partial L}{\partial\ddot{q}}\eta\right)\right]_{t_0}^{t_1} =
\left[\eta\frac{d}{dt}\left(\frac{\partial L}{\partial\ddot{q}}\right)\right]_{t_0}^{t_1}+
\left[\dot{\eta}\frac{\partial L}{\partial\ddot{q}}\right]_{t_0}^{t_1} = 0
\end{equation}
The Euler-Lagrange equation is then:
\begin{equation}
\frac{\partial L}{\partial q} -
\frac{d}{dt}\left(\frac{\partial L}{\partial \dot{q}}\right) +
\frac{d^2}{dt^2}\left(\frac{\partial L}{\partial \ddot{q}}\right) =
0
\end{equation}
As a justification for the conditions over $\eta$ and its derivative at the endpoints observe that, in general, $\partial L/\partial\ddot{q}$ may depend on $\ddot{q}$, so the equation of motion will be of fourth order. To obtain a solution, four conditions will be needed. In the case of $L$ depending only on $q$ and $\dot{q}$, for a second order equation we needed two conditions: fixing $q(t_0)$ and $q(t_1)$. In the fourth order case, it is reasonable to fix $q(t_0)$, $q(t_1)$, $\dot{q}(t_0)$ and $\dot{q}(t_1)$.
Therefore, as $\delta q=\epsilon\eta$ and $\delta \dot{q}=\epsilon\dot{\eta}$ we have that $\eta(t_0)=\eta(t_1)=\dot{\eta}(t_0)=\dot{\eta}(t_1)=0$.
