I am working on the following exercise:
Find a matrix B and an invertible matrix P such that
$$A = \begin{bmatrix} 1 & -2 & 1 & 0 \\ 1 & -2 & 1 & 0 \\ 1 & -2 & 1 & 0 \\ 1 & -1 & 0 & 0 \\ \end{bmatrix}$$
is in Jordan Canonical Form.
This is my working so far:
I calculated the characteristic polynomial of $A$ to be $c_A(x) = -x^4$ (which implies that the only eigenvalue of $A$ is $\lambda = 0$) and the minimal polynomial to be $\mu_A(x) = x^2$.
Since $\text{nullity}((A - 0I_4)^2) - \text{nullity}((A - 0I_4)^1) = 4 - 2 = 2$, the JCF of $A$ is composed of two Jordan blocks, each of degree 2. The JCF is
$$B = \begin{bmatrix} 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 \\ \end{bmatrix}.$$
To find $P$, I then proceeded to find two Jordan chains, $v_1, v_2$ and $v_3, v_4$, such that $A^2v_2 = 0$, but $Av_2 \neq 0$ (similarly for $v_4$), and $v_1 = Av_2 - 0v_2$, $v_3 = Av_4 - 0v_4$.
I chose $v_2 = \begin{bmatrix} 0 & 0 & 1 & 0 \\ \end{bmatrix}^T$ (then, $v_1 = \begin{bmatrix} 1 & 1 & 1 & 0 \\ \end{bmatrix}^T$), $v_4 = \begin{bmatrix} 0 & 1 & 0 & 0 \\ \end{bmatrix}^T$ (then, $v_3 = \begin{bmatrix} -2 & -2 & -2 & -1 \\ \end{bmatrix}^T$).
I then put
$$P = \begin{bmatrix} 1 & 0 & -2 & 0 \\ 1 & 0 & -2 & 1 \\ 1 & 1 & -2 & 0 \\ 0 & 0 & -1 & 0 \\ \end{bmatrix}$$
and calculated its inverse to be
$$P^{-1} = \frac{1}{\det(P)}\text{adj}(P) = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 1 & 0 & 0 \\ \end{bmatrix}.$$
However, when I calculated $P^{-1}AP$ this gave me the matrix
$$\begin{bmatrix} 0 & 1 & 0 & -2 \\ 0 & 1 & 0 & -2 \\ 0 & 0 & 0 & -1 \\ 0 & 1 & 0 & -2 \\ \end{bmatrix}.$$
That matrix is clearly not equal to $B$.
Could I have some help to complete this exercise, please? Perhaps I have made an error in calculation or understanding.
Notice that $A^2 = 0$, so $A^2v=0$ for all $v$. Clearly starting with this condition does not help much.
You need to start with the eigenvectors associated with $\lambda=0$. Suppose $v_1$ is one such an eigenvector, then by the Jordan form you have calculated we must have some $v_{11}$ which is not a scalar multiple of $v_1$ satisfying $$Av_{11} = v_1.$$ (So just solve $Av_1=0$ and then solve $Av_{11}=v_1$). Similar equation follows for the second eigenvector $v_2$. It is easiest to see this by letting $$P = [v_1, v_{11},v_2,v_{21}]$$ and of course we must have $v_{11}$ is not a multiple of $v_1$ and $v_{21}$ is not a multiple of $v_2$, and we must have $$AP=PJ.$$ (Note: $J=B$, using the convention to denote the matrix in Jordan form as $J$)