TITLE: Optimal control problem with minimization of cost
QUESTION [5 upvotes]: Consider the scalar system $\dot{x}=x+u$, given the constraint $u(t+T)=u(t)$. Find the control that drive $x(0)=1$ to $x(2T)=0$ and minimizes $$\int_0^{2T}u^2(t)\,\mathrm{d}t$$
Attempt: substituting $u(t)$ we get $$J=2\int_0^T (\dot{x}^2-2x\dot{x}+x^2 )dt$$
Now i can use Euler Lagrange's eq to find a differential equation of the form $$\ddot{x}=x \implies x(t)=c_1e^{t}+c_2e^{-t}$$
Now i can find $c_1$ and $c_2$ using Initial conditions, then find $x(t)$ and after that i can get the optimal control $u^{*}=\dot{x}-x$.
Is my attemp correct ? i'm unsure about using the constrain given, in the first step of the integral i took out the factor $2$ with incorporates the constrain, is this a valid method ?

REPLY [4 votes]: Here is a straightforward elementary approach:

The unique $x$-solutions to the initial value problem 
$$\dot{x}-x~=~u, \qquad x(0)~=~1,\tag{1}$$ 
and the final value problem 
$$\dot{x}-x~=~u, \qquad x(2T)~=~0,\tag{2}$$ 
are
$$ x(t) ~\stackrel{(1)}{=}~e^t \left(1 + \int_0^t \!ds ~e^{-s}u(s)\right),\tag{3} $$
and
$$ x(t)~\stackrel{(2)}{=}~-e^t  \int_t^{2T} \!ds ~e^{-s}u(s)~=~-e^t  \int_t^{2T} \!ds ~e^{-s}u(s\!-\!T),\tag{4}$$
respectively. In the last equality of eq. (4) we used that $u$ is $T$-periodic.
We demand that the two $x$-solutions (3) and (4) agree at $t=T$, which leads to a constraint
$$ 1 + \int_0^T \!ds ~e^{-s}u(s)
~\stackrel{(3)+(4)}{=}~-\int_T^{2T} \!ds ~e^{-s}u(s\!-\!T)~=~-e^{-T}\int_0^T \!dt ~e^{-t}u(t),\tag{5}$$
or equivalently
$$\chi~:=~\int_0^T \!dt ~e^{-t}u(t)+\frac{1}{1+e^{-T}}~\stackrel{(5)}{=}~0. \tag{6}$$
The constraint (6) is implemented via a Lagrange multiplier. We want to minimize the functional
$$ J[u,\lambda]~:=~\frac{1}{2}\int_0^T \!dt ~u(t)^2~+~\lambda\chi ~\stackrel{(6)}{=}~\int_0^T \!dt \left( \frac{u(t)^2}{2} +\lambda e^{-t}u(t)\right) + \frac{\lambda}{1+e^{-T}}. \tag{7}$$
The Euler-Lagrange (EL) equation for the control $u$ is
$$ u(t)~=~-\lambda e^{-t}, \qquad t~\in~ [0,T],\tag{8}$$
and hence by $T$-periodicity
$$ u(t)~=~u(t\!-\!T)~=~-\lambda e^{T-t}, \qquad t~\in~ ]T,2T].\tag{9}$$
Inserting the $u$-solution (8) into the constraint (6) we find
$$ \frac{1}{1+e^{-T}}~\stackrel{(6)+(8)}{=}~
\lambda\int_0^T \!dt ~e^{-2t}~=~\frac{\lambda}{2}(1-e^{-2T}),\tag{10}$$
so the Lagrange multiplier is
$$ \lambda~\stackrel{(10)}{=}~\frac{2}{(1+e^{-T})(1-e^{-2T})}.\tag{11} $$
The optimal $x$-solution becomes
$$ x(t)~\stackrel{(3)+(8)}{=}~e^{t}\left(1-\frac{\lambda}{2}(1- e^{-2t})\right), \qquad t~\in~ [0,T];\tag{12}$$
$$ x(t)~\stackrel{(4)+(8)}{=}~\frac{\lambda}{2}e^{T-t}(1- e^{-2t}), \qquad t~\in~ [T,2T].\tag{13}$$