I was learning about Variational Method to solve the differential equation for the following differential equation:
$$\frac{d^2u}{dx^2}-u=-x, 0<x<1$$ $$u(0)=0, u(1)=0$$
However, the textbook I am referring to jumped the next point where is says: "The variational expression for the above DE is:" $$\delta J=\int_0^1 (-\frac{d^2u}{dx^2}+u-x)\delta u dx + [\frac{du}{dx}\delta u]_0^1$$ "Where $\delta$ is the variational operator." The textbook explained that "the first term is due to the differential equation and the second term is unknown Neumann boundary(or natural boundary condition)." Final step of the derivation is that: "The functional is obtained as:" $$J=\int_0^1\{\frac{1}{2}(\frac{du}{dx})^2+\frac{1}{2}u^2-xu\}dx$$
Can anyone explain what is the variational expression and particularly the explanation for the second term? If it is not answerable, can you point out the textbook I need to read to understand. Thank you in advance.