The easiest way of finding the minimal state space model I think would be using the Kalman decomposition. This allows you to find a similarity transformation that makes it easy to split the state space model into a minimal (controllable and observable) and non-minimal (not controllable or not observable) form.
When calculating this decomposition you could use the Hautus test, but you could also use the controllability and observability matrix. I made a quick implementation of both in MATLAB, whose code can be seen below.
Hautus test:
function [M, Ak, Bk, Ck, N] = kalman_decomp_hautus(A, B, C)
[V,D] = eig(A);
n = length(A);
M1 = []; M2 = []; M3 = []; M4 = [];
N = zeros(1, 4);
for k = 1 : n
tempC = rank([A - D(k,k) * eye(n) B]) - n;
tempO = rank([A - D(k,k) * eye(n); C]) - n;
if tempC == 0
if tempO == 0
M2 = [M2 V(:,k)];
N(2) = N(2) + 1;
else
M1 = [M1 V(:,k)];
N(1) = N(1) + 1;
end
else
if tempO == 0
M4 = [M4 V(:,k)];
N(4) = N(4) + 1;
else
M3 = [M3 V(:,k)];
N(3) = N(3) + 1;
end
end
end
M = [M1 M2 M3 M4];
Ak = M \ A * M;
Bk = M \ B;
Ck = C * M;
Using this implementation does have the downside that the decomposed state space model matrices can have complex numbers, because if the original $A$ matrix (assuming it is real valued) has complex conjugate eigenvalues then its eigenvectors will be complex conjugate as well, and therefore the similarity transformation also. You could of course try to detect this, but I just wanted a working example.
Controllability and observability matrix:
function [M, Ak, Bk, Ck, N] = kalman_decomp_matrix(A, B, C, tol)
cc = ctrb(A, B);
oo = obsv(A, C);
Sc = rref(cc')'; Sc = Sc(:,1:rank(cc));
Nc = null(cc');
So = rref(oo)'; So = So(:,1:rank(oo));
No = null(oo);
M1 = rref(round(Sc * (Sc \ No),tol)')';
N(1) = rank(M1);
M1 = M1(:,1:N(1));
M2 = rref(round(Sc * (Sc \ So),tol)')';
N(2) = rank(M2);
M2 = M2(:,1:N(2));
M3 = rref(round(Nc * (Nc \ No),tol)')';
N(3) = rank(M3);
M3 = M3(:,1:N(3));
M4 = rref(round(Nc * (Nc \ So),tol)')';
N(4) = rank(M4);
M4 = M4(:,1:N(4));
M = [M1 M2 M3 M4];
Ak = M \ A * M;
Bk = M \ B;
Ck = C * M;
I have not done many tests, but with one test I noticed that finding the intersect of two spans of vectors could give wrong results due to limited numerical accuracy, so I added rounding (using tol=13 seems to omit errors in my case).
Once you have your Kalman decomposition then the minimal realisation of the state space model can be constructed using:
list = N(1) + 1:N(1) + N(2);
Am = Ak(list,list);
Bm = Bk(list,:);
Cm = Ck(:,list);
Dm = D;
If you just want to minimal realisation then you might be able to calculate it faster. But you do need to ensure that the total $M$ matrix is square and full rank.
Since you only mentioned state feedback I assume that you are dealing with a system of the following form
$$
\dot{x} = A\,x + B\,u
$$
with $x \in \mathbb{R}^n$, $u \in \mathbb{R}^m$ and you want to find a state feedback $u = -K\,x$ such that the dynamics of the controllable parts of the system can be chosen. The entire state $x$ is considered to be known and thus observability does not have to be taken into consideration.
By looking at the controllable and uncontrollable states it is possible to find a similarity transformation which decomposes these states, similar to the Kalman decomposition but without also considering the observability. In order to do this you need the controllability matrix $\mathcal{C}$ defined as
$$
\mathcal{C} = \begin{bmatrix}
B & A\,B & \cdots & A^{n-1}B
\end{bmatrix}.
$$
A controllable decomposition can be found using the similarity transformation $T = \begin{bmatrix}T_1 & T_2\end{bmatrix}$, with the columns of $T_1$ having the same span as the controllability matrix and $T_2$ chosen such that $T$ is invertible. In the new coordinates, denoted by $x = T\,\hat{x}$, the dynamics are as follows
$$
\dot{\hat{x}} = \underbrace{T^{-1} A\,T}_{\hat{A}}\,\hat{x} + \underbrace{T^{-1} B}_{\hat{B}}\,u
$$
such that
$$
\hat{A} =
\begin{bmatrix}
A_{11} & A_{12} \\ 0 & A_{22}
\end{bmatrix}, \quad
\hat{B} =
\begin{bmatrix}
B_1 \\ 0
\end{bmatrix}
$$
where $A_{11}$ has the same size as the rank of $\mathcal{C}$ and the pair $(A_{11}, B_1)$ is controllable (their associated controllability matrix is full rank). So for this pair you can do pole placement, such that the poles of $A_{11}-B_1\,K_1$ can be chosen arbitrarily. Therefore, $u = -\begin{bmatrix}K_1 & 0\end{bmatrix} \hat{x}$ will place the controllable poles of $\hat{A}$ arbitrarily as well.
By using the definition of $\hat{x}$ it is possible to express this state feedback in terms of $x$ instead, namely $\hat{x} = T^{-1} x$. Or in other words your feedback gain can be found with $K = \begin{bmatrix}K_1 & 0\end{bmatrix}\,T^{-1}$.
For example given the system
$$
A =
\begin{bmatrix}
4 & 0 & 0 \\
-4 & 0 & -2 \\
-2 & -2 & 0
\end{bmatrix}, \quad
B =
\begin{bmatrix}
1 \\
0 \\
-1
\end{bmatrix},
$$
which has the eigenvalues $2$, $-2$ and $4$. This pair has the following controllability matrix
$$
\mathcal{C} =
\begin{bmatrix}
1 & 4 & 16 \\
0 & -2 & -12 \\
-1 & -2 & -4
\end{bmatrix},
$$
with has rank 2. It can be shown that its first two columns are linearly independent of each other, so an option for the similarity transformation would be
$$
T =
\begin{bmatrix}
1 & 2 & 0 \\
0 & -1 & 0 \\
-1 & -1 & 1
\end{bmatrix}.
$$
For the added last column it can be shown that it makes $T$ invertible (full rank). Performing the similarity transformation gives
$$
\hat{A} =
\begin{bmatrix}
0 & -4 & -4 \\
2 & 6 & 2 \\
0 & 0 & -2
\end{bmatrix}, \quad
\hat{B} =
\begin{bmatrix}
1 \\
0 \\
0
\end{bmatrix},
$$
such that
$$
A_{11} =
\begin{bmatrix}
0 & -4 \\
2 & 6
\end{bmatrix}, \quad
B_1 =
\begin{bmatrix}
1 \\
0
\end{bmatrix}.
$$
Finding a feedback gain for this pair, which places the poles at $-1$ and $-2$ gives $K_1 = \begin{bmatrix}9 & 24\end{bmatrix}$. So the actual state feedback gain can be calculated with
$$
K = \begin{bmatrix}K_1 & 0\end{bmatrix}\,T^{-1} =
\begin{bmatrix}9 & -6 & 0\end{bmatrix},
$$
which also places the two controllable poles of $A$, which are initially located at $2$ and $4$, at $-1$ and $-2$ respectively.
Best Answer
$\lambda_i$ is said to be a controllable eigenvalue if $\text{rank}\begin{bmatrix}A - \lambda_i I & B\end{bmatrix} = n$.
$\begin{bmatrix} A - \lambda_i & B\end{bmatrix} = \begin{bmatrix} 1-\lambda_i & -5 & b_1 \\ -5 & 1 - \lambda_i & b_2\end{bmatrix}$
For $\lambda_i = 6$
$\begin{bmatrix} A - \lambda_i & B\end{bmatrix} = \begin{bmatrix} -5 & -5 & b_1 \\ -5 & -5 & b_2\end{bmatrix} \sim \begin{bmatrix} -5 & -5 & b_1 \\ 0 & 0 & b_2 - b_1\end{bmatrix}$, this has full rank for $b_2 - b_1 \neq 0$.
For $\lambda_i = -4$
$\begin{bmatrix} A - \lambda_i & B\end{bmatrix} = \begin{bmatrix} 5 & -5 & b_1 \\ -5 & 5 & b_2\end{bmatrix} \sim \begin{bmatrix} 5 & -5 & b_1 \\ 0 & 0 & b_2 + b_1\end{bmatrix}$, this has not full rank for $b_2 + b_1 = 0$.
Hence take $b_1 = -1$ and $b_2 = 1$ thus $B = \begin{bmatrix} -1 \\ 1 \end{bmatrix}$