Constrained variational calculus: find extremums of $\int_0^\infty ay(t)^2 + by'(t)^2 + f(t)y(t) \ \text{d}t$ subject to $0 \leq y(t)\leq k$ I wish to find extremums of a functional $J[y]$ that is given by
$$
J[y] =\int_0^\infty ay(t)^2 + by'(t)^2 + f(t)y(t) \ \text{d}t \hspace{0.5cm} \text{subject to} \hspace{0.5cm} 0 \leq y(t)\leq k
$$
with boundary conditions $y(t_0)=y_0, y(t_1)=y_1$ and where $a,b\in\mathbb{R}$.
My attempt:
My approach is to transform the inequality constraints into a single holonomic constraint so we can then proceed to solve using Lagrange multipliers.
Firstly, we begin by transforming 2 inequalities into a single inequality:
$$0 \leq y(t)\leq k \iff y(t)(k - y(t)) \geq 0 \hspace{1cm} (1)$$
Then, change the inequality constraint into an equality constraint by introducing a slack variable $s(t)$:
$$(1) \iff y(t)(k - y(t)) - s(t)^2=0$$
This leads us to form the Lagrangian:
$$L(t,y,y')=ay(t)^2 + by'(t)^2 + f(t)y(t) + \lambda(t)(y(t)(k - y(t)) - s(t)^2)$$
on which we can apply the Euler-Legrange equation:
$$\frac{\partial L(t,y,y')}{\partial y} - \frac{\text{d}}{\text{d} t}\frac{\partial L(t,y,y')}{\partial y'} = 2ay(t) + f(t)+\lambda(t) (k-2y(t)) - 2by''(t)=0 \hspace{1cm}(2)$$
From here we need to solve the following inhomogeneous 2nd order differential equation with non-constant coefficients due to $\lambda(t)$:
$$
(2) \implies 2by''(t)+2y(t)(\lambda(t) - a)=f(t)+k\lambda(t)
$$
This is where I'm now stuck:

*

*How do you solve this differential equation? I'm aware of reduction of order but that requires one solution to be known.

*Also, I notice that the slack variable $s(t)$ doesn't feature in the Euler-Legrange equation $(2)$ - is this correct?

*Do you also need to apply the Euler-Lagrange equation to $\lambda(t)$ and $s(t)$ (i.e. $\frac{\partial L}{\partial \lambda}=0$ and $\frac{\partial L}{\partial s}=0$)?

 A: The Lagrangian reads
$$
L(y(t),y'(t),\lambda(t),s(t),t)=a y(t)^2+b y'(t)^2+f(t) y(t)+\lambda(t)((k-y(t))y(t)-s(t)^2)
$$
and now calling $\Theta = \{y(t),\lambda(t),s(t)\}$ we have the Euler-Lagrange stationary condition.
$$
\frac{d}{dt}\left(\frac{\partial L}{\partial\dot\Theta}\right)-\frac{\partial L}{\partial\Theta}=0
$$
giving
$$
\left\{
\begin{array}{rcl}
 2 b y''(t)-2 a y(t)-f(t)-\lambda (t) (k-2 y(t))&=&0 \\
 s(t)^2-y(t) (k-y(t))&=&0 \\
 2 \lambda (t) s(t)&=&0 \\
\end{array}
\right.
$$
NOTE
The algebraic conditions can be conveniently derived regarding $t$ to furnish a differential system so taken derivatives on the two algebraic equations we have an "equivalent" differential system.
$$
\left\{
\begin{array}{rcl}
 y''(t)&=&\frac{2 a y(t)+f(t)+\lambda (t) (k-2 y(t))}{2 b} \\
 s''(t)&=&\frac{2 a k y(t)-4 a y(t)^2-4 b s'(t)^2-4 b y'(t)^2+f(t) (k-2 y(t))+\lambda (t) (k-2 y(t))^2}{4 b s(t)} \\
 \lambda ''(t)&=&-\frac{2 \lambda (t) \left(a k y(t)-2 a y(t)^2-2 b \left(s'(t)^2+y'(t)^2\right)\right)+8 b s(t) \lambda '(t) s'(t)+f(t) \lambda (t) (k-2 y(t))+\lambda (t)^2 (k-2 y(t))^2}{4 b s(t)^2} \\
\end{array}
\right.
$$
The boundary conditions should be consistent as for instance giving $0\lt y(t_0)\lt  k$ and $0\lt y(t_1)\lt  k$ we need $\lambda(t_0) = \lambda(t_1)=0$ and $s(t_0) = \sqrt{y(t_0)(k-y(t_0))},\ s(t_1) = \sqrt{y(t_1)(k-y(t_1))}$
