Equivalent method for solving lyapunov equality I am trying to show that the lyapunov equality:
$A^{T}P + PA = -Q$
Where $Q = 
\begin{bmatrix}
    1 & 0 \\
    0 & 1 \\
\end{bmatrix}
$
is equivalent to solving:
$M
\begin{bmatrix}
    P_{11}\\
    P_{12}\\
    P_{22}\\       
\end{bmatrix}
= v
$
The stated solution is:
$M:=
\begin{bmatrix}
    -4 & -2 & 0\\
    1 & -2 & -1\\
    0 & 2 & 0\\       
\end{bmatrix}
$
and 
$ v:=
\begin{bmatrix}
    -1 \\
    0  \\
    -1 \\       
\end{bmatrix}
$
I can see that the values for the vector $v$ come from the corresponding $Q_{11},Q_{12},Q_{22}$ values. However, I do not know how the M values are defined. If I multiply out the left side of the equation I get:
$
\begin{bmatrix}
    -4P_{11} - P_{12} - P_{21} & P_{11} - 2P_{12} - P_{22}\\
    P_{11} - 2P_{21} - P_{22} & P_{12} + P_{21}\\      
\end{bmatrix}
$
Which if i try to map this to an M matrix I would get:
$M = 
\begin{bmatrix}
    -4 & -1 & 0\\
    1 & -2 & -1\\
   0 & 1 & 0\\       
\end{bmatrix}
$
Which is close, but not the same as the solution.
 A: If in your case the Lyapunov equality can be written as
$$
\begin{bmatrix}
-4\,P_{11} - P_{12} - P_{21} & P_{11} - 2\,P_{12} - P_{22} \\
P_{11} - 2\,P_{21} - P_{22} & P_{12} + P_{21}
\end{bmatrix} = -
\begin{bmatrix}
Q_{11} & Q_{12} \\ Q_{21} & Q_{22}
\end{bmatrix} \tag{1}
$$
then by stacking the columns of $(1)$ on top of each other, then it can also be written as
$$
\begin{bmatrix}
-4\,P_{11} - P_{12} - P_{21} \\ P_{11} - 2\,P_{21} - P_{22} \\ P_{11} - 2\,P_{12} - P_{22} \\ P_{12} + P_{21}
\end{bmatrix} = -
\begin{bmatrix}
Q_{11} \\ Q_{21} \\ Q_{12} \\ Q_{22}
\end{bmatrix}. \tag{2}
$$
Factoring out $P$ gives
$$
\begin{bmatrix}
-4 & -1 & -1 & 0 \\
1 & -2 & 0 & -1 \\
1 & 0 & -2 & -1 \\
0 & 1 & 1 & 0
\end{bmatrix}
\begin{bmatrix}
P_{11} \\ P_{21} \\ P_{12} \\ P_{22}
\end{bmatrix} = -
\begin{bmatrix}
Q_{11} \\ Q_{21} \\ Q_{12} \\ Q_{22}
\end{bmatrix}. \tag{3}
$$
Now if we assume that $P = P^\top$ and $Q = Q^\top$, which implies $P_{21} = P_{12}$ and $Q_{21} = Q_{12}$, then the second and third equation from $(2)$ and $(3)$ are identical, so one of them can be omitted. Also the second column of the matrix, which gets multiplied by the $P$ vector, gets multiplied by $P_{21}$ which is identical to $P_{12}$. But the third column of the matrix gets multiplied by $P_{12}$. So this can be simplified down to that the sum of the second and third column get multiplied by $P_{12}$. Applying this to $(3)$ allows it to be rewritten as
$$
\begin{bmatrix}
-4 & -2 & 0 \\
1 & -2 & -1 \\
0 & 2 & 0
\end{bmatrix}
\begin{bmatrix}
P_{11} \\ P_{12} \\ P_{22}
\end{bmatrix} = -
\begin{bmatrix}
Q_{11} \\ Q_{12} \\ Q_{22}
\end{bmatrix}. \tag{4}
$$
So from this it can be seen that this indeed matches the stated solution for $M$. You probably just forgot to add the second and third column.
Also the matrix in the formulation in $(3)$ can easily be constructed for any $A \in \mathbb{R}^{2 \times 2}$ using
$$
\hat{M} = 
\begin{bmatrix}
A + I\,A_{11} & I\,A_{12} \\
I\,A_{21} & A + I\,A_{22}
\end{bmatrix}. \tag{5}
$$
So from this it can also be deduced that your $A$ matrix should equal
$$
A = 
\begin{bmatrix}
-2 & -1 \\ 1 & 0
\end{bmatrix}.
$$
In general when $A \in \mathbb{R}^{n \times n}$ then $\hat{M} \in \mathbb{R}^{n^2 \times n^2}$, such that it consists out of a $n$ by $n$ grid of $\mathbb{R}^{n \times n}$ sub-matrices. By denoting $\hat{M}_{ij}$ as the sub-matrix on the $i$th place in the vertical direction and of the $j$th place in the horizontal direction, then each sub-matrix can be constructed using
$$
\hat{M}_{ij} = \left\{
\begin{array}{ll}
A + A_{ij}\,I, & \text{if}\ i = j \\
A_{ij}\,I, & \text{otherwise}
\end{array}\right. \tag{6}
$$
