Taking the $n$-th root of a diagonal matrix I have the following problem: let $C$ be a $3\times 3$ real matrix such that
$$
C^3=
\begin{bmatrix}
-1&0&0\\
0&1&0\\
0&0&2
\end{bmatrix}
$$
What is $C$?
The issue is that I don't know whether this imples that $C$ itself is diagonal so simply taking the cube roots of the diagonal elements might miss out on some possibilities for $C$.  
More generally: let $X, D$ be (possibly complex) square matrices with $D$ diagonal, $n\geq 2$. Find all solutions to
$$
X^n=D
$$
In some cases, there will be many solutions: if $D=0$, some nilpotent matrices work. If any two eigenvalues are identical, the corresponding entries in $X$ can arise from various unitary transformations in the relevant eigenspace.  
So the question is: what is the most general form of $D$ for which we can give a relatively simple description of the possible solutions?
 A: $\textbf{Question 1}$. What are the complex $n\times n$ matrices $M$ s.t. the equation $X^p=M$ admits at least one complex solution? 
See the answer in my post in $(*)$.
sufficient and necessary conditions for matrix to have pth roots
$\textbf{Question 2}$. Give a class $\mathcal{C}$ of matrices s.t., for every $M\in\mathcal{C}$, we can find all the solutions of $X^p=M$.
A solution is the set of non-derogatory (or cyclic) matrices.
$\textbf{Proof}$. We may assume that $M=diag(\lambda_1I_{i_1}+J_1,\cdots,\lambda_kI_{i_k}+J_k)$ where the $(\lambda_i)$ are distinct and $J_j$ is the nilpotent Jordan block of dimension $i_j$. If $X^p=M$, then $X,M$ commute and $X$ is in the form $X=diag(X_1,\cdots,X_k)$ where $X_j^p=\lambda_jI_{i_j}+J_j$ (and $X_j,J_j$ commute).
It remains to solve the equation $X^p=\lambda I+J$ where $X$ is in the form $X=a_0I+\cdots+a_{n-1}J^{n-1}$ and $a_i\in\mathbb{C}$. If $\lambda=0$, then see $(*)$. Otherwise, proceed by identification; one finds $p$ solutions that depend on the choice of $a_0$ s.t. $a_0^p=\lambda$.
$\textbf{Question 3}$. If $M$ is a real matrix, then find, if they exist, the real matrices s.t. $X^p=M$.
Even for $p=2$, the problem of the existence is not obvious. See the answer in my post in 
When does a real matrix have a real square root?
I forgot the OP's question.
$\textbf{Question 4.}$ If $D$ is a complex diagonal $n\times n$ matrix, then we can find all the complex solutions of $X^p=D$.
$\textbf{Proof}$. We may assume that $D=diag(\lambda_1I_{i_1},\cdots,\lambda_kI_{i_k})$ where the $(\lambda_i)$ are distinct. Then $X$ is in the form $X=diag(X_1,\cdots,X_k)$ where $X_j^p=\lambda_jI_{i_j}$. 
EDIT. Thus it remains to solve the equation $X^p=\lambda I$. If $\lambda=0$, then $X$ is nilpotent; if moreover, $n\leq p$, then the set of solutions is the algebraic set of nilpotent matrices that has dimension $n^2-n$; if $p<n$, then it's more complicated. Otherwise, we may assume that $\lambda=1$ and we solve $X^p=I$. Clearly, $X$ is diagonalizable and we obtain 
$X=Pdiag(x_1,\cdots,x_n)P^{-1}$ where $x_i^p=1$ and $P$ is invertible.
-Answer to J_P- 
$\textbf{Proposition}.$ Let $Z=\{X;X^p=I_n\}$; then, when $n\leq p$, $Z$ is an algebraic set of dimension $n^2-n$.
$\textbf{Proof}$. $dim(Z)$ is, by definition, the maximum of its local dimension. The local dimension is given by $n^2-s$, where $s$ is the dimension of the stabilizer $\{P\in GL;Pdiag(x_i)P^{-1}=diag(x_i)\}$, that is, $Pdiag(x_i)=diag(x_i)P$. The minimum of the dimension $s$ of the commutant of $diag(x_i)$ is 
$n$ when $n\leq p$ (take the $(x_i)$ distinct); then  $dim(Z)=n^2-n$.
When $p<n$, we cannot choose the $(x_i)$ distinct. These two examples make it possible to guess the calculation method
$n=4,p=3$. We take $x_1,x_2,x_3,x_3$; then $s=1+1+4$ and   $dim(Z)=10$.
$n=4,p=2$. We take $x_1,x_1,x_2,x_2$; then $s=4+4$ and  $dim(Z)=8$. 
