Solve $$v(y_1,y_2)=\displaystyle \int_0^\pi(y_1'^2-y_2'^2)dx $$ $$ y_1(0)=y_2(0)=y_1(\pi)=0 , \ y_2(\pi)=\frac{\pi}{2} $$ $$ y_1'-y_2 +\cos(x)=0 $$.
After solving Euler-Lagrange equation for $F(x,y_1,y_2,y_1',y_2')=y_1'^2-y_2'^2 +\lambda( y_1'-y_2 +\cos(x))\ $ , I am getting $$ y_1=Ax+B \ ,\ y_2= \frac{\lambda}{4}x^2+Cx+D$$ But the given answer is $y_1=\frac{x}{2}\sin(x) \ , y_2=\frac{1}{2}(\sin(x)-x\cos(x))$ which is clearly not the same to what I have got. Where am I wrong? Could you please help me?
In this type of problem, the parameter $\lambda$ must be a function of $x$. This is so, because $y_1'$ is involved in the constraint equation.
The augmented Lagrangian is then $$\mathcal{L}=\tfrac{1}{2}(y_1'^2-y_2'^2) + \tfrac{\lambda}{2}(y'_1-y_2+\cos{x})$$
Now, due to the fact that the integral $$\int_{0}^{\pi}\mathcal{L}\,dx$$ must be an extremum along the path $$\frac{d}{dx}\left(\frac{\partial \mathcal{L}}{\partial y'_i}\right)-\frac{\partial\mathcal{L}}{\partial y_i}=0\qquad i=1,2$$ subjected to the contraint $$y'_1-y_2 +\cos{x}=0$$
Leads to the following system of linear differential equations $$\begin{align} y_1''+\tfrac{1}{2}\lambda'&=0\tag1\\ y_2''-\tfrac{1}{2}\lambda&=0\tag2\\ y'_1-y_2+\cos{x}&=0 \tag3 \end{align}$$ From $(1)$ $$y_1'=c_1-\tfrac{1}{2}\lambda\tag4$$ from the latter equation and $(2)$ $$y_2=\cos{x}+\tfrac{1}{2}(c_1-\lambda)\tag5$$ and $(3)$ turns to $$\lambda''+\lambda+\cos{x}=0\tag6$$
Solve first for $\lambda$ in $(6)$, and substitute it in $(4)$ and $(5)$ to obtain $y_1$ and $y_2$.
Finally solve the linear system for the constants $c_1$, $c_2$, $c_3$ and $c_4$ with the given extremal values on $x=0$ and $x=\pi$.
Hope I have not committed any mistake.