Determine the stationary function u(x) for the dual functional $$I[u]=-u(\pi)u'(\pi)+\frac{1}{2}\int_{0}^{\pi}[(u')^2-u^2+2u]dx$$
I am having a difficult time solving this problem. I am not sure how to go about the integration by parts and the rest. The answer provided is $u(x)=cosx+1$. If you could explain in detail how to solve this problem I would really appreciate it. Thank you.
You need to solve the problem
$$ \frac{d}{dt}\left(\frac{\partial L}{\partial \dot{u}} \right) - \frac{\partial L}{\partial u} = 0 \tag{1} $$
where
$$ L(u, \dot{u}) = \frac{1}{2}\dot{u}^2 - \frac{1}{2}u^2 + u $$
Eq. (1) then becomes
$$ \ddot{u} - (-u + 1) = 0 ~~~\Rightarrow~~~ \frac{d^2 u}{dt^2} + u = 1 $$
whose solutions are
$$ u(t) = 1 + a\cos t + b\sin t $$
Some additional information will be required to solve the problem, such as the value of $u$ at the borders of the domain $u(0)$ and $u(\pi)$