I am looking for an easy way to generate non-trivial (i.e., not just diagonal) examples of $3 \times 3$ matrices whose entries are integers and whose eigenvalues are also integers.

I know how to do this for $2 \times 2$ matrices: you just choose integers so that the discriminant of the characteristic equation is a perfect square. But short of trial and error, with the help of Wolfram Alpha, I don't know a way with larger matrices.

Does anyone know how to do this?

  • $\begingroup$ How many non-diagonal zero entries would you happy with? $\endgroup$
    – Archaick
    May 10, 2015 at 10:14
  • 1
    $\begingroup$ write an integer diagonal matrix then construct arbitrary unitary matrices to generate a non-trivial matrix. i.e. diagonalization in reverse. $\endgroup$
    – user121049
    May 10, 2015 at 10:25
  • 1
    $\begingroup$ @user121049: the problem will be preserving integer entries. $\endgroup$ May 10, 2015 at 10:57
  • $\begingroup$ Is it an easy matter to generate a unitary matrix for this purpose? Isn't a unitary matrix with real entries also an orthogonal matrix, in which case, by reversing the diagonalization process, all my matrix examples will end up being symmetric, which isn't quite what I was looking for. $\endgroup$ May 10, 2015 at 11:06
  • 1
    $\begingroup$ See the very interesting text. $\endgroup$
    – Jean Marie
    Jun 1, 2019 at 21:00

3 Answers 3


How about the following:

  1. Pick a diagonal matrix $\Lambda$ with integer diagonal entries. The eigenvalues will be multiples of these.
  2. Pick a matrix $V$ with integer entries so that $V$ is invertible, $\det(V)\neq 0$.
  3. Form $A=\det(V)V\Lambda V^{-1}$.

$A$ is guaranteed to have integer entries. One formula for the inverse of $V$ is $V^{-1}=\frac{1}{\det(V)}\mathrm{adj}(V)$ where $\mathrm{adj}(V)$ is the adjugate of $V$. The adjugate has integer entries since the entries are determinants of minors of $V$.

The eigenvalues of $A$ are the diagonal entries of $\Lambda$ scaled by $\det(V)$. Note that you can always pick $V$ to have a unit determinant. For example, choose $V$ as upper Hessenberg with 1's on the first subdiagonal. Then the upper right corner entry can be used to control the determinant and ensure it is $\pm 1$ (or any other desired value).

As an example, take $\Lambda=\left[\begin{array}{ccc}17&0&0\\0&-2&0\\0&0&3\end{array}\right]$ and $V=\left[\begin{array}{ccc}2&3&x\\1&-1&5\\0&1&1\end{array}\right]$. Then $\det(V)=-15+x$ so we can choose $x=16$ to get $\det(V)=1$. The result is $A=\left[\begin{array}{ccc}-150&334&778\\-89&195&464\\5&-10&-27\end{array}\right]$.


Here's an example. Say you want the eigenvector to be $v=(1,2,3)$ and the eigenvalue to be $\lambda=5$. First, calculate the norm squared of the eigenvector. In this example, $\|v\|^2=14$. Now multiply the eigenvalue divided by the norm squared times the column {1,2,3} times the row {1,2,3}. The result is $$\frac{5}{14}\left( \matrix{1 & 2 & 3 \\ 2& 4& 6\\3& 6& 9} \right)$$

Of course, this matrix doesn't have integer entries, because of the 14 in the denominator. For this choice of eigenvector, we would have to choose an eigenvalue that is a multiple of 14 to get a matrix with all integer entries.

As another example, say we have two orthogonal vectors $u=(1,1,1)$ and $v=(-1,0,1)$. The first norm squared is 3 and the second norm squared is 2. So let's choose eigenvalue 6 for the first vector and eigenvalue -2 for the second. For each eigenvalue/eigenvector pair, we form the matrix like we did above, and then add the two matrices. $$ \frac{6}{3}\left( \matrix{ 1& 1& 1\\ 1& 1& 1\\ 1& 1& 1}\right)+ \frac{-2}{2}\left( \matrix{ 1& 0& -1\\ 0& 0& 0\\ -1& 0& 1}\right)= \left( \matrix{ 1& 2& 3\\ 2& 2& 2\\ 3& 2& 1}\right)$$ If you have a third orthogonal vector, then you could form a third matrix and add that one. For example, $w=(1,-2,1)$ is orthogonal to $u$ and to $v$, and it has a norm squared of 6, so we could use it to form a matrix with integer entries and an integer eigenvalue that is any multiple of 6.

For me the only tricky part is in multiplying column vector on left by the row vector on the right to get a matrix. Here's the formula for that:$$ \left( \matrix{x\\ y\\ z}\right) \left( \matrix{a& b& c}\right) = \left( \matrix{ ax& bx& cx\\ ay& by& cy\\ az& bz& cz}\right) $$

You can use this method for larger (4x4, etc) or smaller (2x2) matrices.

  • $\begingroup$ That is very nice! So you are in fact producing matrices that are symmetric too. $\endgroup$
    – orangeskid
    Nov 19, 2021 at 21:57

Compute the product of two $2\times2$ unitary matrices: $$ \begin{bmatrix}\color{#C00000}{3}&\color{#C00000}{7}&0\\\color{#C00000}{2}&\color{#C00000}{5}&0\\0&0&1\end{bmatrix} \begin{bmatrix}1&0&0\\0&\color{#C00000}{2}&\color{#C00000}{3}\\0&\color{#C00000}{1}&\color{#C00000}{2}\end{bmatrix} =\begin{bmatrix}3&14&21\\2&10&15\\0&1&2\end{bmatrix} $$ and their inverses: $$ \begin{bmatrix}1&0&0\\0&\color{#C00000}{2}&\color{#C00000}{-3}\\0&\color{#C00000}{-1}&\color{#C00000}{2}\end{bmatrix} \begin{bmatrix}\color{#C00000}{5}&\color{#C00000}{-7}&0\\\color{#C00000}{-2}&\color{#C00000}{3}&0\\0&0&1\end{bmatrix} =\begin{bmatrix}5&-7&0\\-4&6&-3\\2&-3&2\end{bmatrix} $$ then compute a matrix similar to a diagonal using these: $$ \begin{bmatrix}3&14&21\\2&10&15\\0&1&2\end{bmatrix} \begin{bmatrix}1&0&0\\0&2&0\\0&0&3\end{bmatrix} \begin{bmatrix}5&-7&0\\-4&6&-3\\2&-3&2\end{bmatrix} =\begin{bmatrix}29&-42&42\\20&-29&30\\4&-6&6\end{bmatrix} $$

  • $\begingroup$ Notice that the matrices are $2\times2$ unitary matrices in the corners. Those are easy to generate. I have colored the $2\times2$ matrices. $\endgroup$
    – robjohn
    Sep 18, 2016 at 15:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .