Construct a Real Matrix for given Complex Eigenvalues

I need to construct real-valued matrices with specific complex eigenvalues. I have seen the companion matrix, which sort of does my job, but there are some other desirable properties as well, so I'm looking for a more general construction. If anyone could shed some light, that'd be awesome.

The eigenvalues will be distinct. They will lie on the unit circle. Preferably, I could choose the eigenvectors as well (I know some restrictions will apply, but it's fine). It would be amazing, if the matrix had as few zeros as possible.

So, given I am asking for a lot, I will appreciate the most general construction.

I have seen this answer (https://math.stackexchange.com/q/1345699), but I wonder if there is a method that provides greater freedom over the matrix.

• Every matrix with those eigenvalues is obtained by factoring the polynomial $\prod(x-\lambda_i)$, with $\lambda_i$ the eigenvalues together with multiplicity, over the reals (not necessarily in smallest factors, just some choice of factors), building a block diagonal matrix with the companion matrices of each of the factors, and the pre- and post multiplying the resulting matrix with $P^{-1}$ and $P$, for an arbitrary real matrix $P$. – logarithm May 8 at 20:50

Build $$M$$ with $$2 \times 2$$ block matrices along the diagonal as in the linked question. Then for any invertible matrix $$A$$ the matrix $$AMA^{-1}$$ will have the eigenvalues you want. You can design $$A$$ to get the other properties you care about.
The original $$M$$ is likely to be the one with the most zeroes.
A random square matrix $$A$$ will be invertible (the probability that the determinant is $$0$$ is $$0$$) and I'm pretty sure $$AMA^{-1}$$ will have no $$0$$ entries with probability $$1$$.
• You can arrange the eigenvectors for the transformed $M$ (not those of $A$). Let $A$ be the transformation that maps the canonical basis of $\mathbb{R}^n$ to the basis (of eigenvectors) of your choice. But I suspect a problem. The complex eigenvalues occur in complex conjugate pairs. The corresponding eigenvectors span a two dimensional real subspace on which $M$ acts essentially as a rotation. There won't be eigenvectors when you think in terms of action on a vector space over $\mathbb{R}$. How you manage this depends on information about your application that's not in the question. – Ethan Bolker May 9 at 19:22