If someone could help me with this problem I would be greatly appreciative.

Control the system $$\dot{x}=x+u$$ From $$x(0)=0 \space to\space x(T)=2$$ Where $T\in\mathbb{R}_+$ is free

s.t. $$J=\int_{0}^{T}\frac{1}{2}u^2dt$$ is minimised.

### My Approach

Let $$ \\f_0(t,x,u)=\frac{1}{2}u^2 \\f_1(t,x,u)=x+u $$

The Hamiltonian of this problem is given by: $$ \\H=-f_0+\psi \times f_1 \\=-\frac{1}{2}u^2+\psi(x+u) $$

By the PMP we wish to choose $u$ s.t. it maximises $H$, $$ \\\frac{\partial H}{\partial u}=0 \\\Rightarrow\psi=u $$

The costate equation gives us $$ \\\dot\psi= -\frac{\partial H}{\partial x} \\\Rightarrow\dot\psi=-\psi \\\Rightarrow\psi=Ae^{-t} $$

Subbing this back into the system gives $$ \\x(t)=Be^{t}-\frac{A}{2}e^{-t} \\u(t)=Ae^{-t} $$

Now along the optimal trajectory, again by the PMP, $H$ must be $0$. As this applies along any point of the trajectory, we have (after a bit of algebra) $$ \\H(t=0)=0 \\\Rightarrow A = 0 \space or \space B = 0 $$

Now this is where I am confused, if $A=0$ or $B=0$ we have

$$x(t) = -\frac{A}{2}e^{-t} \space or \space x(t) = Be^{t} $$

But given $x(0)=0$ that would imply that in both cases $x(t)=0$. Which clearly does not give the optimal solution as it will never reach $x(T)=2$.

I'm not sure if I have made some fundamental error along the way, or if the system is just not controllable, but would appreciate some guidance either way.