# How to construct a $4 \times 4$ symmetric, positive definite matrix with integer eigenvalues

As part of my master thesis I'm trying to construct (or find) some $4 \times 4$ symmetric, positive (semi-)definite matrices with integer components, and integer eigenvalues. The reason for the integer conditions is purely aesthetical, since typesetting the matrix and many analytical calculations look nicer with integer scalars.

I'm aware of answers such as https://math.stackexchange.com/a/1377275/245055, but the problem is that this does not produce a symmetric matrix.

Any guidance will be greatly appreciated, as I would very much prefer not having to search for this by brute force or via code (which might potentially produce false positives due to numerical precision issues).

• The false positives aren't a problem -- if the diagonalisation yields integer eigenvalues, you can check in integer arithmetic whether they're actually eigenvalues. – joriki Apr 12 '16 at 14:02
• @joriki OK, thanks. If nobody manages to come up with an analytical approach, I'll resort to solving this numerically and share the implementation as an "answer". – thomasjo Apr 12 '16 at 14:09
• This seems like it might be relevant, though I'm not sure exactly how: math.stackexchange.com/questions/607540/… – bubba Apr 12 '16 at 14:19

You can use the trick from this paper to find orthogonal matrices with rational entries: $(S-I)^{-1}(S+I)$, where $S$ is skew-symmetric with integer entries. Then you can use these for similarity transforms of diagonal matrices $D$ with integer entries, and multiply by the determinants to get back to integers; all together:

$$\det(S+I)^2(S+I)^{-1}(S-I)D(S-I)^{-1}(S+I)$$

where $S$ is skew-symmetric, $D$ is diagonal and both have integer entries.

One can modify the approach of the linked solution. Borrowing the notation from there, we want the resulting matrix $A = (\det V) V \Lambda V^{-1}$ to satisfy $A^T = A$, and it is sufficient to choose $V$ such that $V^{-1} = V^T$, that is, such that $V$ is orthogonal. This actually gives only $n!$ solutions over $\Bbb Z$, namely the permutation matrices, and these only yield diagonal matrices, but we can just allow ourselves to work with rational orthogonal matrices $V$ and then clear denominators at the end. For $n \geq 2$ there are infinitely many of these, as any Pythagorean triple $(a, b, c)$ determines such a matrix: $$\begin{pmatrix}\frac{a}{c} & -\frac{b}{c} \\ \frac{b}{c} & \frac{a}{c}\end{pmatrix} \oplus I_{n - 2} .$$ Alternatively, one could take a Householder reflection determined by any rational vector in $\Bbb Q^3$.

Explicitly:

1. Pick any sequence $(d_1, \ldots, d_4)$ of nonnegative integers and form the diagonal matrix $$D := \pmatrix{d_1 & & \\ & \ddots & \\ & & d_4} .$$
2. Pick any rational, orthogonal $4 \times 4$ matrix $Q \in SO(4, \Bbb Q)$.
3. Form the rational matrix $Q D Q^{-1} = Q D Q^T$, and multiply by some positive multiple $m$ of the least common denominator of the entries of that matrix. By construction, the resulting matrix $A := m Q D Q^T$ is symmetric has integer entries and nonnegative eigenvalues $md_a$.

For example, consider the sequence $(2, 1, 1, 1)$ and for $Q$ take the above matrix given by the familiar Pythagorean triple $(a, b, c) = (3, 4, 5)$. Computing gives $Q D Q^{-1} = \pmatrix{\frac{34}{25} & \frac{12}{25} \\ \frac{12}{25} & \frac{41}{25}} \oplus I_2$, and clearing denominators gives a matrix with the desired properties. $$\pmatrix{34 & 12 & 0 & 0 \\ 12 & 41 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1} .$$

• The example in the answer already shows that $Q D Q^{-1}$ need not be an integer matrix. (The error in the comment seems that be the assumption that $P^{-1}$ will be an integer matrix, which it's not.) Of course, one could alternatively pick a $k$ so that $P = k Q$ is an integer matrix, and then $P D P^T$ has the desired property, but this effectively just reorders the steps. – Travis Willse Apr 13 '16 at 10:37
• My bad. You're right. – user1551 Apr 13 '16 at 11:49