# Proof check: Optimal Control and Optimal Path for $J = \int_{0}^{1} (x + 2xu + u^2)dt$

I'm working through some past exam papers, and I've come across this question. I've solved it, but my answer looks absolutely terrible, and I just wanted to verify whether I'd made a mistake anywhere along the way.

The system $\dot x = -x + 4u$, where $u = u(t)$ is not subject to any constraint, is to be controlled from $x(0) = 2$ to $x(1) = 1$, in such a way to minimise; $$J = \int_{0}^{1} (x + 2xu + u^2)dt$$ Find the optimal control $u^*$ and the optimal path $x^*$.

To begin, I set my Hamiltonian function as follows;

$$H = -x - 2xu - u^2 + \psi (-x+4u)$$

Now, we wish to maximise $H$ with respect to $u$, so we have; $$\frac{\partial H}{\partial u} = 0 = -2x - 2u + 4\psi$$ $$\implies u = 2\psi - x$$

Now, I have the following for my state equation; $$\dot x = -x + 4u = -x + 4(2\psi - x) = -5x + 8 \psi$$

I also have the following costate equation; $$\dot \psi = - \frac{\partial H}{\partial x} = 1 + 2u + \psi = 1 + 5\psi - 2x$$

Hence, I have the following; $$\ddot x = -5\dot x + 8\dot \psi$$ $$\implies \ddot x = -5(-x + 4u) + 8(1 + 5\psi - 2x)$$ $$\implies \ddot x = 9x + 8$$

Using the method of undetermined coefficients, I get the following solution for $x(t)$; $$x(t) = Ae^{3t} + Be^{-3t} - \frac{8}{9}$$

Now, when I start putting in my boundary conditions, things start getting messy. $$x(0) = 2 = A + B - 8/9$$ $$\implies \frac{26}{9} - A = B$$ $$\implies x(t) = A(e^{3t} - e^{-3t}) + \frac{26e^{-3t} - 8}{9}$$ $$\implies x(t) = 2A\sinh(3t) + \frac{26e^{-3t} - 8}{9}$$

Then, we have; $$x(1) = 1 = 2A\sinh(3) + \frac{26e^{-3} - 8}{9}$$ $$\implies A = \frac{17 - 26e^{-3}}{18\sinh(3)}$$

Thus, we have; $$x(t) = \frac{(17-26e^{-3})\sinh(3t)}{9\sinh(3)} + \frac{26e^{-3t} - 8}{9}$$

From here, it's quite elementary to get an equation for $\psi(t)$ and $u(t)$, but it's a lot of fiddling around with what seems like an incredibly complicated solution. For context, this is one question out of a total of six in a two-hour exam, and to me, it just seems a tad too complicated.

If anyone would be happy to look over my working, and see if I've made any mistakes, or if I am actually correct, that'd be fantastic!!

The only error I see is actually in your last equation (and I think this is just a typo): the denominator of the first term should be $$9\sinh(3).$$ I think an extra $t$ snuck in there when you were typesetting the question. Everything else looks fine to me.
• Oh hey, I didn't even notice!! Yes, that should be a $3$, not a $3t$.
• No idea. The format of the question seems pretty consistent for the exams over the years, and I don't really have much of a problem manipulating the equations, it's just time consuming to write things like this out. I can always substitute constants, but it's still rather annoying. I would've imagined that the majority of the focus would be generating equations for $x$ and $\psi$.