Finding a matrix given its characteristic polynomial I am asked to find a $2 \times 2$ matrix with real and whole entries given it's characteristic polynomial:
$$p^2 -5p +1.$$
This is what I have done thus far:
I equated the polynomial to zero, and the roots (eigenvalues) were found to be $2.5 \pm \sqrt{21}/2$
I named the matrix to be solved $C$,
so $\det(C) =$ product of eigenvalues $= 1$
$\text{trace}(C) =$ sum of eigenvalues $=5$
I then tried to find C by solving $T^{-1} \times D \times T$, where $D$ is a matrix whose diagonal entries are the eigenvalues solved above, and $T$ is any matrix who's determinant is non zero.
I used $T$ as a $2 \times 2$ being
$$\begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}.$$
I solved $T^{-1} \times D \times T$, and threw it in a calculator to make sure I made no algebraic mistakes, but the answer I received is wrong.
I appreciate any help, thank you.
 A: Your choice of $T$ would not lead to whole entries. 
Guide:
Let $C=\begin{bmatrix}a & b \\ c & d \end{bmatrix}$.
We need $a+d=5$ and $ad-bc=1$
You can let $a=0$, then we end up having $-bc=1$. Can you choose some possible values of $b$ and $c$ to let it satisfy the equation?
A: Let's start off by looking at the characteristic polynomial of the $2 \times 2$ matrix
$A = \begin{bmatrix} 0 & 1 \\ -a & -b \end{bmatrix}: \tag 1$
$\det (A - \lambda I) = \det \left (\begin{bmatrix} -\lambda & 1 \\ -a & -b - \lambda \end{bmatrix} \right ) = \lambda^2 + b\lambda + a; \tag 2$
we see from (2) that we may always present a $2 \times 2$ matrix with given characteristic polynomial $\lambda^2 + b\lambda + a$ in the form $A$; for example, if he quadratic is $\lambda^2 + 5\lambda + 1$, as in the present problem (tho' I have replaced $p$ with $\lambda$), we may take
$P = \begin{bmatrix} 0 & 1 \\ -1 & -5 \end{bmatrix}, \tag 3$
which may be easily checked:
$\det(P - \lambda I) = -\lambda(-5 - \lambda) - 1 ( -1) = \lambda^2 + 5\lambda + 1. \tag 4$
The matrices $A$ and $P$ above are part of a general paradigm for constructing matrices with a given characteristic polynomial, and it extends to higher dimensions.  Now, there are a very many matrices possessed of a given characteristic polynomial, since it is a similarity invariant; that is, the characteristic polynomials of $X$ and $S^{-1}XS$ are always the same; thus it behooves us to find a matrix of particularly simple, general form for a given polynomial.  If
$q(\lambda) = \displaystyle \sum_1^n q_i \lambda^i, \; q_n = 1, \tag5$
we define $C(q(\lambda))$ to be the $n \times n$ matrix
$C(q(\lambda)) = \begin{bmatrix} 0 & 1 & 0 & \ldots & 0 \\ 0 & 0 & 1 & \ldots & 0 \\
\vdots & \vdots & \ldots & \vdots & \vdots \\ -q_0 & -q_1 & -q_2 & \ldots & -q_{n - 1} \end{bmatrix}; \tag 6$
that is, $C(q(\lambda))$ has all $1$s on the superdiagonal, the negatives of the coefficients of $q(\lambda)$ on the $n$-th row, and $0$s everywhere else.  We have
$C(q(\lambda) - \lambda I = \begin{bmatrix} -\lambda & 1 & 0 & \ldots & 0 \\ 0 & -\lambda & 1 & \ldots & 0 \\
\vdots & \vdots & \ldots & \vdots & \vdots \\ -q_0 & -q_1 & -q_2 & \ldots & -q_{n - 1} - \lambda \end{bmatrix}; \tag 7$
it is easy to see, by expanding in minors along the $n$-th row, that
$\det(C(q(\lambda)) - \lambda I) = q(\lambda); \tag 8$
also, since a matrix and its transpose have equal determinants, the transposed form $C(q(\lambda))$, $C^T(q(\lambda))$, also gives rise to the same characteristic polynomial.  The matrices $C(q(\lambda))$ and $C^T(q(\lambda))$ are known as companion matrices for the polynomial $q(\lambda)$; the linked article has more of the story.
