I know how to prove the Euler-Lagrange equation($\frac{\partial f}{\partial y}-\frac{d }{d x} \frac{\partial f}{\partial y_x}$) to minimize the the functional \begin{align} J(y)=\int^{x_2}_{x_1} f(x,y(x),y'(x)) \ dx. \end{align}
My question is how to prove the Euler-Lagrange equation ($\frac{\partial f}{\partial y}-\frac{d }{d x} \frac{\partial f}{\partial y_x}+\frac{d^2}{dx^2} \frac{\partial f}{\partial y_{xx}}$), for the functional
\begin{align} J(y)=\int^{x_2}_{x_1} f(x,y(x),y'(x),y''(x)) \ dx. \end{align}
My Attempt Using $$y(x,\alpha)=y(x,0)+\alpha \eta(x) $$ where $\eta(x)$ is a perturbation, away from $y(x,0)$. The condition for an extrema of $J$ is $\frac{d J(\alpha)}{d \alpha}=0$. $$\frac{d J(\alpha)}{d \alpha}=\frac{d }{d \alpha} \int^{x_2}_{x_1} f(x,y(x),y'(x),y''(x)) dx= \int^{x_2}_{x_1} \frac{d }{d \alpha} f(x,y(x),y'(x),y''(x)) dx $$ We note the total derivative of $\frac{d f}{d \alpha}$ is \begin{align} \frac{d f}{d \alpha}&=\frac{\partial f}{\partial x} \frac{d x}{d \alpha}+\frac{\partial f}{\partial y} \frac{d y}{d \alpha}+\frac{\partial f}{\partial y_x} \frac{d y_x}{d \alpha}+\frac{\partial f}{\partial y_{xx}} \frac{d y_{xx}}{d \alpha} \\ &=\frac{\partial f}{\partial y} \frac{d y}{d \alpha}+\frac{\partial f}{\partial y_x} \frac{d y_x}{d \alpha}+\frac{\partial f}{\partial y_{xx}} \frac{d y_{xx}}{d \alpha} \\ &=\frac{\partial f}{\partial y} \eta(x) + \frac{\partial f}{\partial y_x} \eta'(x)+ \frac{\partial f}{\partial y_{xx}} \eta''(x) \end{align}
so \begin{align} \frac{d f}{d \alpha}&= \int^{x_2}_{x_1} \frac{\partial f}{\partial y} \eta(x) + \frac{\partial f}{\partial y_x} \eta'(x)+ \frac{\partial f}{\partial y_{xx}} \eta''(x) \ dx \end{align} we can use integration by parts and the property $\eta(x_1)=\eta(x_2)=0$ to show that the first two terms are equal to \begin{align} \int^{x_2}_{x_1}[\frac{\partial f}{\partial y}-\frac{d }{d x} \frac{\partial f}{\partial y_x}]\eta(x). \end{align}
For the last part we do integration by parts again using the fact that $\eta'(x)$ vanishes. \begin{align} \int^{x_2}_{x_1} \frac{\partial f}{\partial y_{xx}} \eta''(x) \ dx &= \frac{\partial f}{\partial y_{xx}} \eta'(x)|^{x_2}_{x_1} - \int^{x_2}_{x_1} \frac{d }{dx} \frac{\partial f}{\partial y_{xx}} \eta'(x) \ dx \\ &= 0 - \int^{x_2}_{x_1} \frac{d }{dx} \frac{\partial f}{\partial y_{xx}} \eta'(x) \\ &=-\frac{\partial f}{\partial y_{xx}} \eta(x)|^{x_2}_{x_1} + \int^{x_2}_{x_1} \frac{d^2 }{d x^2} \frac{\partial f}{\partial y_{xx}} \eta(x) \ dx \\ &=\int^{x_2}_{x_1} \frac{d^2 }{d x^2} \frac{\partial f}{\partial y_{xx}} \eta(x) \ dx \\ \end{align}
The final integral is \begin{align} \frac{d f}{d \alpha}&=\int^{x_2}_{x_1}[\frac{\partial f}{\partial y}-\frac{d }{d x} \frac{\partial f}{\partial y_x}+\frac{d^2}{dx^2} \frac{\partial f}{\partial y_{xx}}]\eta(x). \end{align}
with the Fundamental Lemma from the Calculus of Variations, this is enough to prove the answer.
Notes:
- I have seen this post but it does not answer my question.
- I use $y'(x)$ and $y_x$ interchangeably.
- My post should now include full answer.
When you are considering a functional involving the derivatives of order $n$, you must impose boundary conditions on the derivatives of order $(n-1)$, what implies that the $(n-1)$-th derivatives of the perturbation must be zero at the boundary points. Thus the additional term involving a second derivative of the perturbation can be integrated by parts, because the first derivative of the perturbation is zero at the boundary. Doing one more integration by parts you get the result. See the page 41 of the book Calculus of Variations by Gelfand and Fomin.