Determine the general form of $u_0, u_1 ~\text{and} ~ u_2$ if a system of difference equations of the form
$$x_{n+1} = Ax_n + Bu_n,$$
where:
$A = \begin{pmatrix} 3 & 2 & 2 \\ -1 & 0 & -1 \\ 0 & 0 & 1 \end{pmatrix}$
and:
$B = \begin{pmatrix} 0 & 0 \\ 0 & 1 \\ 1 & 0 \end{pmatrix}$
is to be controlled for $x_0 = 0 ~ to ~ x_3 = [2, 1, 2]^T$ .
Show this target could have been achieved at $x_2$
Solution So far I have caculated the controlability matrix to be $ C =\begin{pmatrix} 0&0&2&2&6&6\\ 0&1&-1&0&-3&-2\\ 1&0&1&0&1&0 \end{pmatrix}. $ Thus the system is controlable Now putting Cv=x3 i have the 3 equations $$ 2c+2d+6e+6f=2\\ b-c-3e-2f=1\\ c+e+f=2\\ $$ which i have then put into row echleon form which i have found to be $$ a+c+e=2\\ b-c-3e-2f=1\\ c+d+3e+3f=1\\ $$
I proceeded to put these in terms of c,e and f to get the general terms
$a=2-r_1-r_2 , b=1+r_1+3r_2 , c=r_1 , d= 1-3r_3-3r_2-r_1 , e=r_2 , f=r_3,$
however when i substitue this back into my equation to check by doing $$x_1=Ax_0+Bu_0, x_2=ax_1+Bu_1, x_3=Ax_2+Bu_2$$
i dont get $x_3=(2,1,2)^T$
Just expanding the difference equation with $x_0 = 0$ gives $x_2 = ABu_0+Bu_1$, $x_3 = A^2 Bu_0+A Bu_1+ B_2u_2$. Recall that each $u_k \in \mathbb{R}^2$.
If we let $R_k = \begin{bmatrix} A^{k-1}B & A^{k-2}B & \cdots & B\end{bmatrix}$, we can write these equations as $x_2 = R_2 \begin{bmatrix} u_0 \\ u_1 \end{bmatrix} = \begin{bmatrix} 2 & 2 & 0 & 0 \\ -1 & 0 & 0 & 1 \\ 1 & 0 & 1 & 0\end{bmatrix} \begin{bmatrix} u_0 \\ u_1 \end{bmatrix} $, $x_3 = R_3 \begin{bmatrix} u_0 \\ u_1 \\ u_2 \end{bmatrix} = \begin{bmatrix} 6 & 6 & 2 & 2 & 0 & 0 \\ -3 & -2 & -1 & 0 & 0 & 1 \\ 1 & 0 & 1 & 0 & 1 & 0\end{bmatrix} \begin{bmatrix} u_0 \\ u_1 \\ u_2 \end{bmatrix}$. It should be clear that setting $\begin{bmatrix} u_0 \\ u_1 \end{bmatrix} = \begin{bmatrix} 0 \\ 1 \\ 2 \\ 1 \end{bmatrix} $ will result in $x_2 = \begin{bmatrix} 2 \\ 1 \\ 2 \end{bmatrix} $, and setting $\hat{u} = \begin{bmatrix} u_0 \\ u_1 \\ u_2 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \\ 2 \\ 1 \end{bmatrix} $ will result in $x_3 = \begin{bmatrix} 2 \\ 1 \\ 2 \end{bmatrix} $.
Hence the general form of $u = \begin{bmatrix} u_0 \\ u_1 \\ u_2 \end{bmatrix}$ that reaches the desired $x_3$ is given by $\hat{u} + v$, where $v \in\ker R_3$. Since the last three columns of $R_3$ are clearly linearly independent, it is easy to compute the kernel. Let $R_3 = \begin{bmatrix} Q_1 & Q_2 \end{bmatrix}$, then $\begin{bmatrix} x \\ y\end{bmatrix} \in \ker R_3$ iff $y = - Q_2^{-1} Q_1 x$. Choosing $x \in \{e_1,e_2,e_3\}$ gives $\ker R_3 = \operatorname{sp} \{ \begin{bmatrix} 1 \\ 0 \\ 0 \\ -3 \\ -1 \\ 3 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \\ 0 \\ -3 \\ 0 \\ 2 \end{bmatrix}, \begin{bmatrix} 0 \\ 0 \\ 1 \\ -1 \\ -1 \\ 1 \end{bmatrix} \}$.
The answer is that the control that steers $0$ to $x_3$ is given by: $$ \begin{bmatrix} u_0 \\ u_1 \\ u_2 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \\ 2 \\ 1 \end{bmatrix} + \alpha_1 \begin{bmatrix} 1 \\ 0 \\ 0 \\ -3 \\ -1 \\ 3 \end{bmatrix} + \alpha_2 \begin{bmatrix} 0 \\ 1 \\ 0 \\ -3 \\ 0 \\ 2 \end{bmatrix} + \alpha_3 \begin{bmatrix} 0 \\ 0 \\ 1 \\ -1 \\ -1 \\ 1 \end{bmatrix} $$ where $\alpha_k$ are arbitrary.