Jerk mechanics - Lagrangian I have a Lagrangian with the form
$$L = L[q(t,\alpha), \dot{q}(t,\alpha), \ddot{q}(t,\alpha), t],$$
to which I am applying the calculus of variations. The problem is that when I apply the calculus, I obtain the Euler-Lagrange equation
$$-\frac{d^2}{dt^2}\frac{\partial L}{\partial \ddot{q_i}} -\frac{d}{dt}\frac{\partial L}{\partial \dot{q_i}}+\frac{\partial L}{\partial q_i} = 0$$
where the variation is shown as $q(t, \alpha) = q(t, 0) + \alpha \eta(t)$ instead of
$$\frac{d^2}{dt^2}\frac{\partial L}{\partial \ddot{q_i}} -\frac{d}{dt}\frac{\partial L}{\partial \dot{q_i}}+\frac{\partial L}{\partial q_i} = 0.$$
My guess is that I am doing the following calculation wrong.
$$\frac{\partial L}{\partial \ddot{q_i}}\frac{\partial \ddot{q_i}}{\partial \alpha}=\frac{\partial L}{\partial \ddot{q_i}}\frac{\partial^2}{\partial t^2}(\frac{\partial q_i}{\partial \alpha}) = \frac{d^2}{dt^2}[\frac{\partial L}{\partial \ddot{q_i}}\frac{\partial q_i}{\partial \alpha}] - \frac{d^2}{dt^2}[\frac{\partial L}{\partial \ddot{q_i}}]\frac{\partial q_i}{\partial \alpha}.$$
Is the above expansion correct? It will be cumbersome to write the entire derivation here.
 A: Let's start with a few quick mathematical identities.

*

*We start with the product rule:
\begin{equation}
\frac{\partial}{\partial t}\left[f g\right] = \frac{\partial f}{\partial t}g + \frac{\partial g}{\partial t}f
\end{equation}
For reasons we will come to later, we want to put this equation in a form so that the left hand side involves no derivatives on $f$, and the right hand side contains only (a) total derivatives or (b) terms without any derivatives on $g$. This can done by simply rearranging the terms
\begin{equation}
\boxed{ 
f\frac{\partial g}{\partial t} = \frac{\partial}{\partial t}\left[f g\right] - \frac{\partial f}{\partial t}g
}
\end{equation}
This form will be useful later.


*We can differentiate the product rule to arrive at the analog of the product rule for second derivatives
\begin{eqnarray}
\frac{\partial^2}{\partial t^2}\left[f g\right] &=& \frac{\partial}{\partial t}\left[ \frac{\partial f}{\partial t}g + \frac{\partial g}{\partial t} \right] \\
&=& \frac{\partial^2 f}{\partial t^2}g + 2 \frac{\partial f}{\partial t} \frac{\partial g}{\partial t} + f \frac{\partial ^2 g}{\partial t^2} 
\end{eqnarray}
Like before, we want to massage this expression into a form where the left hand side has no derivatives on $f$, and the right hand side is only total derivatives or terms with no derivatives on $g$. As a starting point, we rearrange things as above so the left hand side has no derivatives on $f$
\begin{equation}
f \frac{\partial^2 g}{\partial t^2}  = \frac{\partial^2}{\partial t^2}[fg] -  2\frac{\partial f}{\partial t}\frac{\partial g}{\partial t} - \frac{\partial^2 f}{\partial t^2}g
\end{equation}
We don't like the term $\frac{\partial f}{\partial t}\frac{\partial g}{\partial t}$. It is not a total derivative, and involves a derivative of $f$. We can fix this by using the boxed equation from point 1
\begin{equation}
\frac{\partial f}{\partial t}\frac{\partial g}{\partial t} = \frac{\partial}{\partial t}\left[g\frac{\partial f}{\partial t}\right] - \frac{\partial^2 f}{\partial t^2} g
\end{equation}
Using this we get the form we want
\begin{equation}
\boxed{
f \frac{\partial^2 g}{\partial t^2}  = \frac{\partial}{\partial t}\left\{ \frac{\partial}{\partial t}[fg] - 2 g\frac{\partial f}{\partial t} \right\} +  \frac{\partial^2 f}{\partial t^2}g
}
\end{equation}
As it turns out, the precise form of the total derivative term in curly braces won't matter for us, but I have left it for completeness.

Now let's see how to use the first identity (the product rule) to derive the Euler Lagrange equation for a Lagrangian that depends on $\dot{x}$, ie $L=L(\dot{q})$. We can write the variation as
\begin{equation}
\frac{\partial L}{\partial \alpha} = \frac{\partial L}{\partial \dot{q}}\frac{\partial \dot q}{\partial \alpha} = \frac{\partial L}{\partial \dot{q}} \frac{\partial}{\partial t} \frac{\partial q}{\partial \alpha}
\end{equation}
Now we identify $f=\frac{\partial L}{\partial \dot{q}}$ and $g=\frac{\partial q}{\partial \alpha}$. Then using the boxed equation from point 1, we arrive at
\begin{equation}
\frac{\partial L}{\partial \alpha} = \frac{\partial L}{\partial \dot{q}} \frac{\partial}{\partial t} \frac{\partial q}{\partial \alpha} = \frac{\partial}{\partial t}\left[\frac{\partial L}{\partial \dot{q}} \frac{\partial q}{\partial \alpha} \right] - \left(\frac{\partial }{\partial t}\frac{\partial L}{\partial \dot{q}}\right) \frac{\partial q}{\partial \alpha}
\end{equation}
By the normal logic in the calculus of variations, we can throw away the total derivative term (assuming we fix the endpoints of the path), and the part multiplying the variation $\frac{\partial q}{\partial \alpha}$ must vanish. Thus the Euler-Lagrange equation is
\begin{equation}
-\frac{\partial }{\partial t}\frac{\partial L}{\partial \dot{q}} = 0
\end{equation}
The minus sign isn't very meaningful here but I've left it in so we can compare with the second derivative term.

Finally we have the pieces to solve your problem. The variation of a Lagrangian $L=L(\ddot{q})$ has the form
\begin{equation}
\frac{\partial L}{\partial \alpha} = \frac{\partial L}{\partial \ddot{q}} \frac{\partial^2}{\partial t^2} \frac{\partial q}{\partial \alpha}
\end{equation}
We identify $f= \frac{\partial L}{\partial \ddot q}$ and $g=\frac{\partial q}{\partial \alpha}$. Then using the boxed identify in point 2, we arrive at
\begin{equation}
\frac{\partial L}{\partial \alpha} = \frac{\partial }{\partial t}\left\{\cdots\right\} + \left( \frac{\partial^2}{\partial t^2}\frac{\partial L}{\partial \ddot q}\right) \frac{\partial q}{\partial \alpha}
\end{equation}
where I haven't filled in the total derivative term because it is irrelevant. Following the same calculus-of-variations logic, we find that the Euler-Lagrange equation has the form
\begin{equation}
 \frac{\partial^2}{\partial t^2}\frac{\partial L}{\partial \ddot q} = 0
\end{equation}
Note that there is no minus sign here, unlike for the first derivative term. This answers your question by showing where the relative minus sign comes from.

The above gives a careful derivation. It's also useful to learn the quick way to do this. If we can ignore total derivatives, then integration by parts amounts to the rule
\begin{equation}
f\frac{\partial g}{\partial t} = - \frac{\partial f}{\partial t} g \ \ ({\rm up\ to\ total\ derivative\ terms})
\end{equation}
Then for second derivatives, we get
\begin{equation}
f\frac{\partial^2 g}{\partial t^2} = - \frac{\partial f}{\partial t} \frac{\partial g}{\partial t} = \frac{\partial^2 f}{\partial t^2}g \ \ ({\rm up\ to\ total\ derivative\ terms})
\end{equation}
Using those "identities" you can get to the Euler Lagrange equation in a faster way, so long as you are sure the boundary terms (total derivative terms) don't matter. It's also very easy to generalize this to $n$-th derivatives (although that doesn't come up very often!)
A: The action is a functional of the function $q(t)$, and is defined as
$$S\big[q(t)\big]=\int_{t_0}^{t_1}dt\,L\Big(q(t),\dot{q}(t),\ddot{q}(t)\Big).$$
Let the functional derivative be
$$\frac{\delta S\big[q(t)\big]}{\delta q(t)}=\lim_{\alpha\to0}\frac{S\big[q(t)+\alpha\eta(t)\big]-S\big[q(t)\big]}{\alpha}.$$
We want the action to be stationary under small variations of $q(t)$, i.e. $\frac{\delta S[q(t)]}{\delta q(t)}=0$, and since the Lagrangian also depends on the second derivative of $q$, we need both $\eta(t)$ and its first derivative to vanish at $t_0$ and $t_1$. Then we have
$$0=\frac{\delta S\big[q(t)\big]}{\delta q(t)}=\lim_{\alpha\to0}\frac{S\big[q(t)+\alpha\eta(t)\big]-S\big[q(t)\big]}{\alpha}=\\=\lim_{\alpha\to0}\frac 1\alpha\Bigg(\int_{t_0}^{t_1}dt\,L\Big(q(t)+\alpha\eta(t),\dot{q}(t)+\alpha\dot{\eta}(t),\ddot{q}(t)+\alpha\ddot\eta(t)\Big)-\int_{t_0}^{t_1}dt\,L\Big(q(t),\dot{q}(t),\ddot{q}(t)\Big)\Bigg)=$$
since the variation $\alpha\eta(t)$ is small, a Taylor expansion can be performed
$$=\lim_{\alpha\to0}\frac 1\alpha\Bigg(\int_{t_0}^{t_1}dt\,L\Big(q(t),\dot{q}(t),\ddot{q}(t)\Big)+\alpha\int_{t_0}^{t_1}dt\,\Big(\eta(t)\frac{\partial L}{\partial q}+\dot{\eta}(t)\frac{\partial L}{\partial \dot{q}}+\ddot{\eta}(t)\frac{\partial L}{\partial \ddot{q}}\Big)+\\-\int_{t_0}^{t_1}dt\,L\Big(q(t),\dot{q}(t),\ddot{q}(t)\Big)\Bigg)=\int_{t_0}^{t_1}dt\,\Big(\eta(t)\frac{\partial L}{\partial q}+\dot{\eta}(t)\frac{\partial L}{\partial \dot{q}}+\ddot{\eta}(t)\frac{\partial L}{\partial \ddot{q}}\Big)$$
The second term is
$$\frac{d\eta(t)}{dt}\frac{\partial L}{\partial \dot{q}}=\frac{d}{dt}\Bigg(\eta(t)\frac{\partial L}{\partial \dot{q}}\Bigg)-\eta(t)\frac{d}{dt}\Bigg(\frac{\partial L}{\partial \dot{q}}\Bigg),$$
but the integral of the first summand is $0$ since $\eta(t_0)=\eta(t_1)=0$.
The third term is
$$\frac{d^2\eta(t)}{dt^2}\frac{\partial L}{\partial \ddot{q}}=\frac{d}{dt}\Bigg(\frac{d\eta(t)}{dt}\frac{\partial L}{\partial \ddot{q}}\Bigg)-\frac{d\eta(t)}{dt}\frac{d}{dt}\Bigg(\frac{\partial L}{\partial \ddot{q}}\Bigg)=\frac{d}{dt}\Bigg(\frac{d\eta(t)}{dt}\frac{\partial L}{\partial \ddot{q}}\Bigg)-\frac{d}{dt}\Bigg(\eta(t)\frac{d}{dt}\bigg(\frac{\partial L}{\partial \ddot{q}}\bigg)\Bigg)+\eta(t)\frac{d^2}{dt^2}\Bigg(\frac{\partial L}{\partial \ddot{q}}\Bigg),$$
but the integral of the first two terms is $0$ since $\eta(t)$ and its derivative must vanish at $t_0$ and $t_1$.
With these considerations, we have that
$$0=\int_{t_0}^{t_1}dt\,\eta(t)\Bigg[\frac{\partial L}{\partial q}-\frac{d}{dt}\Bigg(\frac{\partial L}{\partial \dot{q}}\Bigg)+\frac{d^2}{dt^2}\Bigg(\frac{\partial L}{\partial \ddot{q}}\Bigg)\Bigg]$$
must be satisfied for any $\eta(t)$, so the Euler-Lagrange equation is
$$\frac{\partial L}{\partial q}-\frac{d}{dt}\Bigg(\frac{\partial L}{\partial \dot{q}}\Bigg)+\frac{d^2}{dt^2}\Bigg(\frac{\partial L}{\partial \ddot{q}}\Bigg)=0$$
