I want to find the optimal control and optimal trajectory for the following problem:
min $J(u) = \int_{0}^{T} [x_1^2+x_2^2+5u^2]dt$ subject to $\dot{x_1} = x_2$, $\dot{x_2} = u$, and $|u| \leq 1$.
Now, let's first write the Hamiltonian and find the conditions to be satisfied:
$H = x_1^2+x_2^2+5u^2 + p_1x_2 + p_2u$
For the costate p, we have: $\dot{p} = -\nabla_xH$
$\dot{p_1} = -2x_1$
$\dot{p_2} = 2x_2 + p_1$
For the state x, we have: $\dot{x} = \nabla_pH$
$\dot{x_1} = x_2$
$\dot{x_2} = u$
For optimal control: $u^*(t) =\mathrm{argmin}_{|u| \leq 1}$ $x_1^2+x_2^2+5u^2 + p_1x_2 + p_2u$ \begin{equation} u^*(t) = \begin{cases} -1,&\text{if } p_2(t)\geq 10\\\\ \frac{-p_2(t)}{10}, &\text{if } 10 \geq p_2(t)\geq -10\\\\ 1, &p_2(t)\leq -10 \end{cases} \end{equation}
I could not figure out how to solve these equations to get the optimal trajectory $x(t)$. It seems somehow I should get $p_2(t)$ but how?