Let $N:=A-B$. By assumption, the matrix $N$ is nilpotent.
This means that there exists a positive integer $n$ such that $N^n$ is the zero matrix $O$.

Let $\lambda$ be an eigenvalue of $B$ and let $\mathbf{v}$ be an eigenvector corresponding to $\lambda$. That is, we have $B\mathbf{v}=\lambda \mathbf{v}$ and $\mathbf{v}\neq \mathbf{0}$.
We prove that $\lambda$ is also an eigenvalue of $A$.

Note that since $A$ and $B$ commute each other, it follows that the matrices $N$ and $B-\lambda I$ commute each other as well.
Then we compute
\begin{align*}
(A-\lambda I)^n&=(N+B-\lambda I)^n\\
&=\sum_{i=0}^n \begin{pmatrix}
n \\
i
\end{pmatrix}
N^i(B-\lambda I)^{n-i},
\end{align*}
where the second equality follows by the binomial expansion. (Note that the binomial expansion is true for matrices commuting each other.)
Then we have
\begin{align*}
(A-\lambda I)^n \mathbf{v}&=\sum_{i=0}^{n-1} \begin{pmatrix}
n \\
i
\end{pmatrix}
N^i(B-\lambda I)^{n-i}\mathbf{v}+N^n\mathbf{v}=\mathbf{0}
\end{align*}
since $(B-\lambda I)\mathbf{v}=\mathbf{0}$ and $N^n=O$.

This implies that there exists an integer $k$, $0\leq k \leq n-1$ such that
\[\mathbf{u}:=(A-\lambda I)^k\mathbf{v}\neq \mathbf{0} \text{ and } (A-\lambda I)^{k+1}\mathbf{v}=\mathbf{0}.\]

It yields that $(A-\lambda I)\mathbf{u}=\mathbf{0}$ and $\mathbf{u}\neq \mathbf{0}$, or equivalently $A\mathbf{u}=\lambda \mathbf{u}$.
Hence $\lambda$ is an eigenvalue of $A$.

This proves that each eigenvalue of $B$ is an eigenvalue of $A$.
Note that if $A-B$ is nilpotent, then $B-A$ is also nilpotent.
Thus, switching the roles of $A$ and $B$, we also see that each eigenvalue of $A$ is an eigenvalue of $B$.
Therefore, the eigenvalues of $A$ and $B$ are the same.

Nilpotent Matrices and Non-Singularity of Such Matrices
Let $A$ be an $n \times n$ nilpotent matrix, that is, $A^m=O$ for some positive integer $m$, where $O$ is the $n \times n$ zero matrix.
Prove that $A$ is a singular matrix and also prove that $I-A, I+A$ are both nonsingular matrices, where $I$ is the $n\times n$ identity […]

Nilpotent Matrix and Eigenvalues of the Matrix
An $n\times n$ matrix $A$ is called nilpotent if $A^k=O$, where $O$ is the $n\times n$ zero matrix.
Prove the followings.
(a) The matrix $A$ is nilpotent if and only if all the eigenvalues of $A$ is zero.
(b) The matrix $A$ is nilpotent if and only if […]

An Example of a Matrix that Cannot Be a Commutator
Let $I$ be the $2\times 2$ identity matrix.
Then prove that $-I$ cannot be a commutator $[A, B]:=ABA^{-1}B^{-1}$ for any $2\times 2$ matrices $A$ and $B$ with determinant $1$.
Proof.
Assume that $[A, B]=-I$. Then $ABA^{-1}B^{-1}=-I$ implies
\[ABA^{-1}=-B. […]

Is the Product of a Nilpotent Matrix and an Invertible Matrix Nilpotent?
A square matrix $A$ is called nilpotent if there exists a positive integer $k$ such that $A^k=O$, where $O$ is the zero matrix.
(a) If $A$ is a nilpotent $n \times n$ matrix and $B$ is an $n\times n$ matrix such that $AB=BA$. Show that the product $AB$ is nilpotent.
(b) Let $P$ […]

A Recursive Relationship for a Power of a Matrix
Suppose that the $2 \times 2$ matrix $A$ has eigenvalues $4$ and $-2$. For each integer $n \geq 1$, there are real numbers $b_n , c_n$ which satisfy the relation
\[ A^{n} = b_n A + c_n I , \]
where $I$ is the identity matrix.
Find $b_n$ and $c_n$ for $2 \leq n \leq 5$, and […]

Is the Derivative Linear Transformation Diagonalizable?
Let $\mathrm{P}_2$ denote the vector space of polynomials of degree $2$ or less, and let $T : \mathrm{P}_2 \rightarrow \mathrm{P}_2$ be the derivative linear transformation, defined by
\[ T( ax^2 + bx + c ) = 2ax + b . \]
Is $T$ diagonalizable? If so, find a diagonal matrix which […]

Every Diagonalizable Nilpotent Matrix is the Zero Matrix
Prove that if $A$ is a diagonalizable nilpotent matrix, then $A$ is the zero matrix $O$.
Definition (Nilpotent Matrix)
A square matrix $A$ is called nilpotent if there exists a positive integer $k$ such that $A^k=O$.
Proof.
Main Part
Since $A$ is […]