# Constructing a matrix with given eigenvalues and given algebraic and geometric multiplicities

It's easy to construct a matrix with given eigenvalues, where the algebraic and geometric multiplicities agree by just picking random linearly independent vectors as the eigenvectors and then letting the matrix be $P\Lambda P^{-1}$. Assume I want to construct a matrix $A$ s.t. the eigenvalues are $\lambda_1,\ldots,\lambda_k$ with algebraic multiplicities $e_1,\ldots,e_k$ and geometric multiplicities $g_1,\ldots,g_k$, then how can this be done?

Is there a nice method for doing this, so that one could quickly generate examples with a computer algebra system?

-
Use the Jordan canonical form –  Arturo Magidin Jun 3 '12 at 2:54
You are right. Stupid question, should have immediately thought about that. –  tkp Jun 3 '12 at 2:59

You can proceed in a similar way. Suppose the distinct eigenvalues are $\lambda_1,\ldots,\lambda_r$, the desired geometric multiplicitiy of $\lambda_i$ is $g_i$, and the desired algebraic multiplicity is $e_i\geq g_i$.
You want to construct a matrix whose Jordan form has exactly $g_i$ blocks associated with $\lambda_i$, and the total size of the blocks is $e_i$. You can achieve this by taking $g_i-1$ blocks of size $1$ (corresponding to eigenvectors), and then one block of size $e_i-g_i+1$, all associated to $\lambda_i$; other combinations are possible. For example, to get a matrix with a single eigenvalue $\lambda$ with geometric multiplicity $4$ and algebraic multiplicity $6$, you can take three blocks of size $1$ and one of size $6-4+1=3$: $$\left(\begin{array}{cccccc} \lambda & 1 & 0 & 0 & 0 & 0\\ 0 & \lambda & 1 & 0 & 0 & 0\\ 0 & 0& \lambda & 0 & 0 & 0\\ 0 & 0 & 0 & \lambda & 0 & 0\\ 0 & 0 & 0 & 0 & \lambda & 0 \\ 0 & 0 & 0 & 0 & 0 & \lambda \end{array}\right)$$ or take two blocks of size $2$ and two blocks of size $1$: $$\left(\begin{array}{cccccc} \lambda & 1 & 0 & 0 & 0 & 0\\ 0 & \lambda & 0 & 0 & 0 & 0\\ 0 & 0 & \lambda & 1 & 0 & 0\\ 0 & 0 & 0 & \lambda & 0 & 0\\ 0 & 0 & 0 & 0 & \lambda & 0\\ 0 & 0 & 0 & 0 & 0 & \lambda \end{array}\right).$$