# Matrices with special spectral property

```

```
M = MatrixSpace(ZZ,4,4)
for A in M:
if A.determinant()!=0:
p=A.eigenvalues()
o=list(p)
for e in o:
X = Set([1,2,3,4])
for i,j in X:
if e[i]*e[j]==1:
print(A)
```

I am trying to find those 4 by 4 nonsingular integer matrices which satisfy the following property: Suppose that if $\lambda$ is an eigenvalue of $A$ iff $\frac{1}{\lambda}$ is also an eigenvalue of $A$ with the same multiplicity as that of $\lambda$. How to obtain that class of matrices?

First, you cannot do

`for A in M`

since`M`

is infinite and the loop will never end. Second, the property you describe can be restated as the characteristic polynomial being palindromic or antipalindromic, which can be tested as follows:Third, it's unclear what you mean under "to obtain that class of matrices" since such a class is an infinite object.