Is M unique given A=M^2 where A and M are real matrices?

Is M unique given $A={M}^{2}$ where A and M are real matrices? My guessing is they are unique as I tried to diagonalize A to $PD{P}^{-1}$ and no matter how I order the eigenvalues in D, it still gives the same $M=P{D}^{\frac{1}{2}}{P}^{-1}$. But I am not sure this is true in general, since the diagonalization is too specific.
You can still ask an expert for help

• Questions are typically answered in as fast as 30 minutes

Solve your problem for the price of one coffee

• Math expert for every subject
• Pay only if we can solve it

No, if M is any $n×n$ matrix satisfying $A={M}^{2}$ (we then say that M is a square root of A) then −M is also a square root of A. For this kind of problem it helps to first think about the case where A and M are scalars then think about whether or not the same argument holds for matrices.
Even if A is diagonalizable (which doesn't always hold), your argument using diagonalization doesn't really work here since there are many choices for ${D}^{1/2}$ (Note that ${D}^{1/2}$ is by definition any matrix satisfying ${D}^{1/2}{D}^{1/2}=D$). For instance, in the special case where A has n distinct nonzero eigenvalues, there are ${2}^{n}$ choices for this matrix. Explicitly, if $D=\mathrm{diag}\left({\lambda }_{1},\dots ,{\lambda }_{n}\right)$ then all square roots are of the form $\mathrm{diag}\left({\mu }_{1},\dots ,{\mu }_{n}\right)$ where μi is any number (real or complex) satisfying ${\mu }_{i}^{2}={\lambda }_{i}$ (there are exactly two of them for each i).