= Solution
For
$$
L(x,y,y')=y'^2-y^2-2y\sin x,
$$
the <Euler-Lagrange equation> is
$$
\frac d{dx}\frac{\partial L}{\partial y'}
-\frac{\partial L}{\partial y}=0.
$$
Here this becomes
$$
2y''+2y+2\sin x=0,
\qquad\text{or}\qquad
y''+y=-\sin x.
$$
Because the forcing is resonant with the complementary solution, a particular integral is $(x/2)\cos x$. Hence
$$
y=A\cos x+B\sin x+\frac x2\cos x,
$$
and
$$
y'=-A\sin x+B\cos x+\frac12\cos x-\frac x2\sin x.
$$
The <Neumann boundary conditions> give
$$
y'(0)=B+\frac12=0,
\qquad
y'(\pi/2)=-A-\frac\pi4=0.
$$
Thus
$$
\boxed{
y(x)=-\frac\pi4\cos x-\frac12\sin x+\frac x2\cos x}.
$$
Back to article page