# Example 12
## Kallman Full Decomposition

$$
\begin{align*}
    A &= \begin{bmatrix}
        -4 & -3 & 0 & -2 \\
        6 & 5 & 0 & 2 \\
        4 & 1 & 1 & -6 \\
        -1 & -1 & 0 & -3 \\
    \end{bmatrix}\\

    B &= \begin{bmatrix}
        -1  \\
        1  \\
        2  \\
        0  \\
    \end{bmatrix}\\

    C &= \begin{bmatrix}
        -3 & -2 & 0 & 1 \\
    \end{bmatrix}\\

    D &= \begin{bmatrix}
        0
    \end{bmatrix}\\

    K_r &= \begin{bmatrix}
        -1 & 1  & -1 &  1 \\
        1  & -1 &  1 &  -1 \\
        2  & -1 &  2 &   -1\\
        0  & 0  &  0 &  0
    \end{bmatrix}\\

    K_{no} &= \begin{bmatrix}
        
-3	&-2	&0	&1\\
-1	&-2	&0	&-1\\
-7	&-6	&0	  &1\\
-9	&-10&	0	&-1\\
    \end{bmatrix}\\

\end{align*}\\
\text{To find all the bases, for $P_{K_r}$ you should find the}\\
\text{independent columns and find the system}\\

\text{For $P_{K_{no}}$ you should find the system by looking at}\\
\text{rows, solve it and then find some bases}\\
\begin{align*}

    P_{K_r} &= \begin{bmatrix}
        0&1\\
        0&-1\\
        1&0\\
        0&0
    \end{bmatrix}\\

    X_r &= \begin{cases}
        x_1 =-x_2 \\
        x_4 = 0
    \end{cases}\\

    X_{no} &= \begin{cases}
       -3x_1 - 2x_2 + x_4 = 0 \\
       -x_1 -2x_2 -x_4 = 0
    \end{cases} \rightarrow \\

    &\rightarrow \begin{cases}
       x_1 = x_4 \\
       x_1 = -x_2
    \end{cases} \\

    P_{K_{no}} &= \begin{bmatrix}
        1 & 0\\
        -1 & 0\\
        0 & 1 \\
        1 & 0
    \end{bmatrix}

    
\end{align*} \\
\text{Now, let's get all $X_r$ and $X_{no}$ elements}\\

\begin{align*}
    X_r &= \left\{
        \alpha  \begin{bmatrix}
            0\\
            0\\
            1\\
            0
        \end{bmatrix}
        + 
        \beta \begin{bmatrix}
            1\\
            -1\\
            0\\
            0
        \end{bmatrix}
    \right\}\\

    X_{no} &= \left\{
        \alpha  \begin{bmatrix}
            1 \\
            -1\\
            0 \\
            1 
        \end{bmatrix}
        + 
        \beta \begin{bmatrix}
            0\\
             0\\
            1 \\
            0
        \end{bmatrix}
    \right\}
\end{align*}\\
$$
Now, let's get $X_1$, $X_2$, $X_3$, $X_4$

$$
\begin{align*}
X_1 &= X_r \cap X_{no} = \begin{cases}
        x_1 =-x_2 \\
        x_4 = 0 \\
        x_1 = x_4 
    \end{cases}\\

X_1 &= \begin{bmatrix}
    0 \\ 0 \\ x_3 \\ 0
\end{bmatrix}\\

0 &= X_1^T X_1^\perp \rightarrow \\

&\rightarrow  \begin{bmatrix}
    0 & 0 & x_3 & 0
\end{bmatrix}
\begin{bmatrix}
    x_a \\ x_b \\ x_c \\ x_d
\end{bmatrix} = 0 \rightarrow \\
&\rightarrow\begin{cases}
    x_c = 0
\end{cases} \\

X_1^\perp &= \begin{bmatrix}
    x_a \\ x_b \\ 0 \\ x_d
\end{bmatrix}\\

X_2 &= X_r \cap X_1^\perp = \begin{cases}
    x_1 = -x_2 \\
    x_3 = 0 \\
    x_4 = 0 \\
\end{cases}\\

X_2 &= \begin{bmatrix}
    x_1 \\ -x_1 \\ 0 \\ 0
\end{bmatrix}\\

X_3 &= X_{no} \cap X_1^\perp = \begin{cases}
    x_1 = -x_2 \\
    x_1 = x_4 \\
    x_3 = 0 \\
\end{cases}\\

X_3 &= \begin{bmatrix}
    x_1 \\ -x_1 \\ 0 \\ x_1
\end{bmatrix}\\

0 &= X_2^T X_2^\perp = 
\begin{bmatrix}
    1 & -1 & 0 & 0
\end{bmatrix}
\begin{bmatrix}
    x_a \\ x_b \\ x_c \\ x_d
\end{bmatrix}\rightarrow \\
&\rightarrow\begin{cases}
    x_a - x_b = 0
\end{cases} \\
\\

0 &= X_3^T X_3^\perp = 
\begin{bmatrix}
    1 & -1 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
    x_a \\ x_b \\ x_c \\ x_d
\end{bmatrix}\rightarrow \\
&\rightarrow\begin{cases}
    x_a - x_b + x_d = 0
\end{cases} \\
\\

X_4 &=  X_1^\perp \cap X_2^\perp \cap X_3^\perp = \\
    &= \begin{cases}
            x_3 = 0 \\
            x_1 = x_2 \\
            x_4 = 0\\
    \end{cases} = \\
    &= \begin{bmatrix}
        x_1 \\ x_2 \\ 0 \\ 0    
    \end{bmatrix}


\end{align*}


$$

Now we find the change state matrix:
$$
\begin{align*}
    Q^{-1} &= \begin{bmatrix}
        X_1 & X_2 & X_3 & X_4
    \end{bmatrix} = \\
    &= \begin{bmatrix}
        0 & 1 & 1 & 1\\
        0 & -1 & -1 & 1\\
        1 & 0&0&0\\
        0&0&1&0
    \end{bmatrix}
\end{align*}
$$

Compute: 
$$
\begin{align*}
    \hat{A} &= QAQ^{-1}\\
    \hat{B} &= QB \\
    \hat{C} &= CQ^{-1}
\end{align*}
$$
