# Implicit Riccati Equation Solver (to find the anti-stabilizing solution)

I've found that the latest MATLAB icare() solver includes the possibility to find also the anti-stabilizing solution of the Riccati equation. I haven't found a similar option on Mathematica. Is there something undocumented or any alternative way?

Unfortunately, there is no such option as of now.

But based on this example we can compute such a solution.

{a, b, q, r} = {{{3, 0}, {0, 3}}, {{1, 0}, {0, 1}}, {{1, 0}, {0, 1}}, {{1, 0}, {0, 1}}};

{vals, vecs} =
Eigensystem[ArrayFlatten[{{a, -b.Inverse[r].Transpose[b]}, {-q, -Transpose[a]}}]];

unstableBasis = Extract[vecs, Position[vals, _?(#1 > 0 & ), {1}]];

{{x1, x2}} = Partition[unstableBasis, {2, 2}];

MatrixRank[x1] == 2

x = Simplify[x2.Inverse[x1]]

Simplify[ConjugateTranspose[a].x + x.a - x.b.Inverse[r].ConjugateTranspose[b].x + q]

(* True *)

(* {{3 - Sqrt, 0}, {0, 3 - Sqrt}} *)

(* {{0, 0}, {0, 0}} *)

• Hi Suba! Thanks for answering. I would like to ask how you used Partition in this. Say my matrix system was sized n, would I have to use {n,n}? Also, it is unclear to me why you used {1} in Extract. Apr 17, 2020 at 15:15
• Yes, in general, we would use $\{n,n\}$. That is to partition the $n\ \times 2n$ matrix of eigenvalues into two $n\ \times n$ blocks. I used $\{1\}$ in Position because it's default is $\{0, \infty\}$. In this case, vals is a vector so we can omit $\{1\}$. Apr 17, 2020 at 21:11