Solution (source code)

= Solution

Choose an invertible change-of-basis <matrix> $P$ so that $J=PTP^{-1}$ is the <Jordan normal form> of $T$. Write each block as
$$
J_{m_j}(\lambda_j)=\lambda_jI_{m_j}+N_{m_j},
$$
where $N_{m_j}$ has ones on its first superdiagonal and all other entries zero. Define
$$
D_0=\bigoplus_j\lambda_jI_{m_j},\qquad N=\bigoplus_jN_{m_j}.
$$
Every $\lambda_j\ne0$ because $T$ is invertible, so $D_0$ is an invertible <diagonal matrix>. The <matrix> $N$ is strictly upper triangular and hence nilpotent. On each block $D_0$ is a scalar multiple of the identity, so it commutes with $N$ on that block and therefore on the whole space. This gives
$$
\boxed{PTP^{-1}=D_0+N,\qquad D_0N=ND_0}.
$$