I am recently studying commuting matrices. I was reading the book Invariant Subspaces of Matrices with Applications(Godberg, Lancaster and Rodman) and pg.295-296 claims that a matrix $X$ is a solution to the equation $AX = XA$ if and only if $Z = S^{-1}XS$ is a solution to $JZ = ZJ$ where $J =S^{-1}AS$ is the Jordan form of $A$. Further, they claim that if $J = J_{m_1}(\lambda_1) \oplus \cdots \oplus J_{m_s}(\lambda_s)$, then $Z = S^{-1}XS = Y_1 \oplus \cdots \oplus Y_s$ where $Y_i$, $(i = 1,\cdots,s)$ is an upper triangular Toeplitz matrix. So I have this example and could not work the theorem on my example, and I am struggling understanding the theorem.
Let $$A = \begin{bmatrix}1 & 0 & 0 & 0 & 0 & 0 \\ 0.5 & 0.5 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0.333 & 0 & 0 & 0.333 & 0.333 & 0 \\ 0 & 0 & 0 & 0 & 0.5 & 0.5 \\ 0 & 0.333 & 0.333 & 0 & 0 & 0.333 \end{bmatrix}$$
Then,
$$S = \begin{bmatrix}1 & 0 & 0 & 0 & 0 & -1.667 \\ 1 & 0 & 0 & 0 & -1 & -1.667 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ 0.75 & -1.5 & -20.7500 & -2 & 20 & -1 \\ 0.5 & 0 & -4.5 & -1 & 5 & -0.333 \\ 0.5 & 0 & 1.5 & 0 & -2 & -0.333 \end{bmatrix}$$ and
$$J = \begin{bmatrix}1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0.333 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0.333 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0.5 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0.5 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix}$$
What I know is that if I pick X in a way that $[(I \bigotimes A) - (A^T \bigotimes I)]vec(X) = 0$, $AX-XA = 0$ is satisfied, so for the A matrix I proceed with, I found A commutes with the following X matrix:
$$X = \begin{bmatrix}0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ -0.6325 & 0.6325 & 1 & 0 & 0 & 0 \\ -0.3162 & 0.3162 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \end{bmatrix}$$
which then gives:
$$Z = S^{-1}XS = \begin{bmatrix}0 & 0 & 0 & 0 & 0 & 2.6667 \\ 0 & 0 & 0 & 0 & 0 & 0.0002 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0.3162 & 0.0002 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix}$$
After this point, commutator becomes
$$JZ-ZJ = \begin{bmatrix}0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & -0.1741\times 10^{-3} \\ 0 & 0 & 0 & 0 & 0 & 0.0222 \times 10^{-3}\\ 0 & 0 & 0 & 0 & 0 & -0.1000\times 10^{-3} \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \end{bmatrix}$$
Here's my question,
I used MATLAB for all my numerical computations, yet the $J$ and $Z$ seem to be almost commuting, rather then commuting, did I do something wrong or am I confused? I used linprog to find commuting matrices, in that case, I was able to find almost commuting pairs, yet the entries of the commutator was of order $10^{-12}$.
Also, I couldn't understand why my Z matrix is not a direct sum of upper triangular Toeplitz matrices. I am confused with the Theorem. Last thing is do $Z = S^{-1}XS$ imply that same matrix $S$ brings both $A$ and $X$ to their Jordan forms, in my case I doubt, but from a theoretical perspective, they supposed to be I guess.
Thanks, I appreciate any help or tip.
First, the statement "if $J = J_{m_1}(\lambda_1) \oplus \cdots \oplus J_{m_s}(\lambda_s)$ then $Z = S^{-1}XS = Y_1 \oplus \cdots \oplus Y_s$ where $Y_i$, $(i = 1,\cdots,s)$ is an upper triangular Toeplitz matrix." is true only when the eigenvalues $\lambda_1,\dots,\lambda_s$ are distinct. If $J$ has a repeated eigenvalue, this characterization of the centralizer is incomplete.
Second, I checked your calculations with rational numbers in Sympy for precision. I get $$A=\left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0\\\frac{1}{2} & \frac{1}{2} & 0 & 0 & 0 & 0\\0 & 0 & 1 & 0 & 0 & 0\\\frac{1}{3} & 0 & 0 & \frac{1}{3} & \frac{1}{3} & 0\\0 & 0 & 0 & 0 & \frac{1}{2} & \frac{1}{2}\\0 & \frac{1}{3} & \frac{1}{3} & 0 & 0 & \frac{1}{3}\end{matrix}\right]$$ $$S=\left[\begin{matrix}-1 & 0 & 0 & 0 & 0 & 2\\-1 & 0 & 0 & 0 & \frac{1}{2} & 2\\ 3 & 0 & 0 & 0 & 0 & -2\\0 & -1 & 0 & 1 & -6 & 1\\1 & 0 & -3 & \frac{1}{2} & 0 & 0\\1 & 0 & 1 & 0 & 1 & 0\end{matrix}\right]$$ $$J=S^{-1} A S = \left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0\\0 & \frac{1}{3} & 1 & 0 & 0 & 0\\0 & 0 & \frac{1}{3} & 0 & 0 & 0\\0 & 0 & 0 & \frac{1}{2} & 1 & 0\\0 & 0 & 0 & 0 & \frac{1}{2} & 0\\0 & 0 & 0 & 0 & 0 & 1\end{matrix}\right]$$ $$X=\left[\begin{matrix}0 & 0 & 1 & 0 & 0 & 0\\0 & 0 & 1 & 0 & 0 & 0\\0 & 0 & 1 & 0 & 0 & 0\\- \frac{253}{400} & \frac{253}{400} & 1 & 0 & 0 & 0\\- \frac{253}{8 00} & \frac{253}{800} & 1 & 0 & 0 & 0\\0 & 0 & 1 & 0 & 0 & 0\end{matrix}\right ]$$ $$AX-XA = 0$$ $$Z=S^{-1}X S=\left[\begin{matrix}3 & 0 & 0 & 0 & 0 & -2\\0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & \frac{253}{800} & 0\\0 & 0 & 0 & 0 & 0 & 0\\3 & 0 & 0 & 0 & 0 & -2\end{matrix}\right]$$ $$J Z- Z J = 0$$ Which seems fine to me (the blocks belonging to distinct eigenvalues have Toeplitz form. The blocks for a repeated eigenvalue don't.)