3
$\begingroup$

Suppose that we have two matrices $\mathbf A$ and $\mathbf B$ which are known to us and both of them are square matrices of the same dimensions.

Now we want to find a square matrix $\mathbf C$ that solves following equation:

$$\mathbf C=\mathbf A\mathbf C\mathbf A^\top+\mathbf B$$

How can we find this $\mathbf C$ matrix in Mathematica?

Just for additional information, it is for finding the state-space unconditional covariance matrix

Thanks

$\endgroup$

1 Answer 1

6
$\begingroup$

LyapunovSolve[] is designed for this:

amat = Array[a, {2, 2}]; bmat = Array[b, {2, 2}];
cmat = LyapunovSolve[{amat, -IdentityMatrix[Length[amat]]},
                     {IdentityMatrix[Length[amat]], Transpose[amat]}, -bmat];

Check:

amat.cmat.Transpose[amat] + bmat - cmat // Simplify
   {{0, 0}, {0, 0}}

Alternatively, you can reformulate as a Kronecker product linear system:

cmat2 = Partition[LinearSolve[KroneckerProduct[amat, amat] - 
                              IdentityMatrix[Length[amat]^2],
                              -Flatten[bmat]], Length[amat]];

Check:

amat.cmat2.Transpose[amat] + bmat - cmat2 // Simplify
   {{0, 0}, {0, 0}}
$\endgroup$
1
  • 3
    $\begingroup$ Thanks for your help. I checked Mathematica documentation and you are right. I should use LyapunovSolve[], but since it is a discrete version, I should use DiscreteLyapunovSolve[]. $\endgroup$
    – George
    Commented Sep 11, 2017 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.