# How do you avoid Null in matrix? [closed]

The following matrix equation is a Lyapunov equation,

$$mA.x+ x.mA^T=-mC,$$

the matrix $$mA$$ is given by

$$ mA= $$\begin{pmatrix} -\frac {\gamma}{2} & \omega_{m} & 0 & 0\\\\ -\omega_{m} &-\frac {\gamma}{2} & -2G & 0\\\\ 0 & 0 & -\frac {\kappa}{2} & -\Delta\\\\ -2G & 0 & \Delta & -\frac {\kappa}{2} \end{pmatrix}$$ $$

and the matrix $$mC$$ is given by

$$mC= \begin{pmatrix} 0 & 0 & 0 & 0\\\\ 0 & \gamma (2n+1) & 0 & 0\\\\ 0 & 0 & \kappa & 0\\\\ 0 & 0 & 0 & \kappa \end{pmatrix}$$

With[{x = Array[x, Dimensions[mA]]},  x /. Solve[mA .x + x. mA^T + mC == 0,Flatten@x]]


I got an output like this How can linear matrix equations like these be solved in terms of the given parameters?

• Note that LyapunovSolve is the first hit when searching for "Lyapunov equation" in the documentation center. – Michael E2 Jun 22 '19 at 23:52
• People here generally like users to post code as Mathematica code instead of (i.e. in addition to) just images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this meta Q&A helpful – Michael E2 Jun 22 '19 at 23:53

There's LyapunovSolve[]:
LyapunovSolve[mA, -mC]