how can i find the matrix $P$ that diagonalizes the matrix $A$? I want to find matrix $P$ that diagonalizes the matrix $A$:
$$
        \begin{bmatrix}
        4 & 0 & 1 \\
        2 & 3 & 2 \\
        1 & 0 & 4 \\
        \end{bmatrix}
$$

You need to calculate the eigenvectors which are (1,2,1), (-1,0-1) and (0,1,0). So we have the passage matrix
\begin{equation}P=\left(\begin{array}{ccc}
1 & -1& 0\\
2 & 0 & 1\\
1 & 1 & 0
\end{array}\right)
\end{equation}
\begin{equation}P^{-1}=\left(\begin{array}{ccc}
1/2 & 0& 1/2\\
-1/2 & 0 & 1/2\\
-1 & 1 & -1
\end{array}\right)
\end{equation}
The inverse of P is
\begin{equation}D=P^{-1}AP=\left(\begin{array}{ccc}
5 & 0& 0\\
0 & 3 & 0\\
0 & 0 & 3
\end{array}\right)
\end{equation}
So we have the diagonalization
