
> 
> Consider the 2-dimensional optimal control problem of the LQR kind
>  $$
>  \min\_u \int\_0^\infty (x^T Q x + u^TRu) \, dt \quad\text{such that}\quad \begin{cases}\dot x(t) = Ax(t)+Bu(t) \\ x(0) = \begin{pmatrix}1\\-1\end{pmatrix}\end{cases}
> $$
>  with $x=\begin{pmatrix}x\_1 \\ x\_2\end{pmatrix}$, $u=\begin{pmatrix}u\_1\\u\_2\end{pmatrix}$, $Q=B=I$ (identity), $R=\gamma I$, $A=\begin{pmatrix}-\alpha & \alpha\\\beta & -\beta\end{pmatrix}$, $\alpha>\beta>0$ and $\gamma>0$.
> 
> 
> Solve it using the stationary Riccati equation
>  $$
>  0 = Q+A^TS+SA-SBR^{-1}BS,\quad \text{with}\quad S=\begin{pmatrix}s\_1 & s\_2 \\ s\_2 & s\_3\end{pmatrix}.
> $$
> 
> 
> 


In order to find $x$ and $u$ we have to combine the equation for $\dot x$ with the equation for the optimal control $u = -R^{-1}B^TSx = -\frac1\gamma Sx$. So, firstly, we have to find the expression for $S$.


The Riccati equation is simplified as
$$
 0 = I+A^TS+SA-\frac1\gamma S^2
$$
which is equivalent to the following nonlinear system
 $$
\begin{cases}
 -\dfrac{s\_1^2}{\gamma}-2\alpha s\_1 -\dfrac{s\_2^2}{\gamma}+2\beta s\_2+1=0\\
 \alpha s\_1 - \alpha s\_2 - \beta s\_2 + \beta s\_3 - \dfrac{s\_1s\_2}{\gamma}-\dfrac{s\_2s\_3}{\gamma}=0\\
 -\dfrac{s\_2^2}{\gamma}+2\alpha s\_2 - \dfrac{s\_3^2}{\gamma} - 2\beta s\_3+1 = 0
\end{cases}
$$


How to solve such a non-linear system to find expressions for $s\_1, s\_2$ and $s\_3$? I think there is a fast way to solve either the system or directly the Riccati equation in matrix form, but I don't know how.


The solutions provided by Matlab, using the code below, are so long that it let me think is not the correct way to solve the problem



```
syms x y z a b g
eqn1 = 0 == -x^2/g-2*a*x-y^2/g+2*b*y+1;
eqn2 = 0 == a*x-a*y-b*y+b*z-x*y/g-y*z/g;
eqn3 = 0 == -y^2/g+2*a*y-z^2/g-2*b*z+1;
[x,y,z] = solve([eqn1, eqn2, eqn3], [x, y, z])

```


Solve a 2-dimensional optimal control problem via Riccati nonlinear equation
The solution of a Riccati equation can be found by determining the eigenvectors of the Hamiltonian; see e.g. [here on Wikipedia](https://en.wikipedia.org/wiki/Algebraic_Riccati_equation#Solution). This is your best hope for a closed-form symbolic solution, in my view. In your case, the Hamiltonian is
[
\begin{bmatrix}
-\alpha & \alpha & -\gamma^{-1} & 0\\
\beta & -\beta & 0 & -\gamma^{-1}\\
-1 & 0 & \alpha & -\beta\\
0 & -1 & -\alpha & \beta
\end{bmatrix}.
]
I don't see immediately how to diagonalize it, but maybe someone here has a more trained eye than me.


