Linear Algebra involving matrix equations and determinants I'm studying for a linear algebra exam and one of the questions on a practice exam is as follows:
For which positive integers n does there exist a matrix $A\in\mathbb{R}^{n\times n}$ such that $A^2+A+I=0$?
Note: Here I is the identity matrix.
I know how to solve it for $A^2 + I=0$ by rearranging it as $A^2=-I$ then taking the determinant of both sides to get $\det(A)^2=(-1)^n$ and because $\det(A)^2$ must be positive there is no solution for odd values of n.
When I apply this technique to the above question I get:
$A^2+A=-I\implies A(A+I)=-I\implies \det(A)\det(A+I)=(-1)^n$ but I'm stuck there because if $\det(A)<0$ then $\det(A+I)$ can be positive or negative so I can't use the same argument as above.  I've tried manipulating the equation in other ways and applying the determinant and haven't been able to come up with anything.
Any help is appreciated!
 A: If $n = 2k$, then the companion matrix of $(x^2+x+1)$ placed $k$ times along the diagonal is an $n\times n$ matrix that will satisfy the relation that you want.
Generally, if you want an $n\times n$ matrix that satisfies some polynomial of degree $n$, take the companion matrix of the polynomial in question. 
So we can created a $2\times 2$ matrix satisfying $A^2 + A + I$ by taking the companion matrix of $x^2+x+1$. A block diagonal matrix with this down the diagonal will still satisfy the relation.
A: $A^2+A+1=0$ and since the polynomial $x^2+x+1$ is irreducible over $\mathbb{R}$, $x^2+x+1$ is the minimal polynomial of $A$.
The roots of $x^2+x+1$ are $\zeta=e^{2\pi i/3}$ and $\overline{\zeta}=e^{-2\pi i/3}$, so the minimal polynomial is $(x-\zeta)(x-\overline{\zeta})$. So $A$ is diagonalizable over $\mathbb{C}$ with eigenvalues $\zeta, \overline{\zeta}$. Since $A$ is real-valued, $\zeta$ and $\overline{\zeta}$ have the same multiplicity as eigenvalues (else, $A$ has non-real determinant.) Thus, $n$ has to be even.
Edit: Simpler proof that $n$ can't be odd, expanding on the comment above. If $n$ is odd, then A has a real eigenvalue (because the characteristic polynomial has a root). But eigenvalues are roots of x^2+x+1=0.
To construct a $2k$-by-$2k$ matrix with $A^2+A+1=0$, take the block diagonal matrix with $k$ 2-by-2 blocks, each of which is the matrix for a $2\pi/3$-radian rotation of the plane.   
