# Am I solving this constrained variational problem correctly?

I have the following constrained calculus of variations problem (that I came up with myself):

Find the extremals of $$J(y)=\int_a^b y^2(x)+y'^2(x)dx, \text{ subject to } y(a)=y_a,y(b)=y_b, \text{ and }\int_a^b y(x)dx=C$$

For some $a, b$.

Solution: The Euler lagrange equations give:

$$y''(x)=y(x)+\lambda$$ Solving this gives the general solution: $$y(x)=Ae^x-Be^{-x}-\lambda$$

Now solving for $A,B$ gives:

$$A=\frac{(y_a+\lambda)e^{-a}-(y_b+\lambda)e^{-2a}}{1-e^{b-2a}}$$

$$B=\frac{(y_a+\lambda)e^{2b}-(y_b+\lambda)e^b}{1-e^{2b-a}}$$

Now the constraint becomes: $$\int_a^by(x)dx=Ae^x+Be^{-x}-\lambda x\bigg |_a^b=A(e^b-e^a)+B(e^{-b}-e^{-a})-\lambda(b-a)=C$$

Now for simplicity: Assume $a=0,b=1,y_a=y_b=0$.

Then $A=0$,j $B=-\lambda \alpha$, with $\alpha =\frac{e^2-e}{e^2-1}$ and the constraint reduces to: $$\lambda(-\frac \alpha e+\alpha -1)=C$$ Here, simplifying the factor of $\lambda$ gives $$\lambda \cdot 0 = C$$

Now my questions:

Firstly, this is the first constrained variational problem I've tried to solve. Is my approach correct?

Secondly, What is the conclusion that we can draw from the final equation? It does not give a value for $\lambda$. Does this mean that there is no solution? or that all curves that satisfy the constraint are solutions? or something else?

1. (In this answer, we assume that $a\neq b$. By renaming if necessary, we may assume that $a<b$.)
OP's approach is correct in principle, but his result (v1) cannot be right. OP must have made a mistake somewhere in his algebra. The coefficient in front $\lambda$ in the integral $\int_a^b \!\mathrm{d}x~y(x)$ over the solution cannot vanish.
In the physics model from Newtonian point mechanics, $x$ is time; $y$ is position; $y^{\prime}$ is velocity; the mass $m=1$; the Lagrange multiplier $\lambda$ is a constraint force that imposes the constraint; and $\frac{C}{b-a}$ is an average position.
OP's action functional reads (up to normalization) $$J[y]~:=~\frac{1}{2}\int_a^b \!\mathrm{d}x~(y^{\prime 2}(x)+ y^2(x))+ \lambda\left(\int_a^b \!\mathrm{d}x~y(x) -C\right). \tag{1}$$ To derive the EL eq. for $y$ (but not $\lambda$!) we can drop the last term, and use the following action functional instead $$S[y]~:=~\int_a^b \!\mathrm{d}x~\{\frac{1}{2}y^{\prime 2}(x) -V(y(x))\}, \tag{2}$$ where $$V(y)~:=~-\left(\frac{y}{2}+\lambda\right)y \tag{3}$$ is an unstable quadratic potential. The EL eq. for $y$ is just Newton's 2nd law: $$y^{\prime\prime}~=~-\frac{dV}{dy}~=~y+\lambda. \tag{4}$$ While $\lambda$ is a Lagrange multiplier in the action functional (1), it can be viewed as a constant external force in the action functional (2). Regardless of the boundary conditions, by tuning the external force $\lambda$ any way we please, e.g. very big, the average position $\frac{1}{b-a}\int_a^b \!\mathrm{d}x~y(x)$ of the solution must be affected, contradicting OP's result (v1).