The Square Root of a Square Matrix

We can find the square root of a square matrix
$B$
if the matrix is similar to a matrix
$A^2$
having only diagonal entries ie if we can write
$A^2=P^{-1}BP$
.
Having found the diagonal matrix
$A^2$
,
$PAP^{-1}= \sqrt{B}$
.
Example. Let
$B= \left( \begin{array}{cc} 1 & 2 \\ 2 & 1 \end{array} \right)$

The eigenvalues of
$B$
are the solutions to
$det(B- \lambda I)=0$

\begin{aligned} det( \left( \begin{array}{cc} 1 & 2 \\ 2 & 1 \end{array} \right) -\left( \begin{array}{cc} \lambda & 0 \\ & \lambda \end{array} \right)) &= det (\left( \begin{array}{cc} 1- \lambda & 2 \\ 2 & 1- \lambda \end{array} \right) ) \\ &=(1- \lambda)^2 -4 \\ &= \lambda^2 -2 \lambda -3=(\lambda -3)(\lambda +1) =0 \end{aligned}

Hence
$\lambda = 3, \: -1$
.
If
$\lambda =3, \: (B- \lambda I) \mathbf{v}_1 = \left( \begin{array}{cc} -2 & 2 \\ 2 & -2 \end{array} \right) \begin{pmatrix}x\\y\end{pmatrix} = \begin{pmatrix}-2x+2y\\2x-2y\end{pmatrix} = \begin{pmatrix}0\\0\end{pmatrix}$

Hence
$x=y=1, \: \rightarrow \mathbf{v}_1 = \begin{pmatrix}1\\1\end{pmatrix}$

If
$\lambda =-1, \: (B- \lambda I) \mathbf{v}_2 = \left( \begin{array}{cc} 2 & 2 \\ 2 & 2 \end{array} \right) \begin{pmatrix}x\\y\end{pmatrix} = \begin{pmatrix}2x+2y\\2x+2y\end{pmatrix} = \begin{pmatrix}0\\0\end{pmatrix}$

Hence
$x=1, \: y=-1, \: \rightarrow \mathbf{v}_2 = \begin{pmatrix}1\\-1\end{pmatrix}$

We can take
$P$
as the matrix with columns
$v_1 , v_2$
.
$P= \left( \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right)$

Then
$P^{-1}= - \frac{1}{2} \left( \begin{array}{cc} -1 & -1 \\ -1 & 1 \end{array} \right)$

The matrix
$A^2$
will be a diagonal matrix with entries equal to the eigenvalues of
$B$

$A^2 = \left( \begin{array}{cc} -1 & 0 \\ 0 & 3 \end{array} \right) \rightarrow A = \left( \begin{array}{cc} i & 0 \\ 0 & \sqrt{3} \end{array} \right)$

Then
$\sqrt{B} = \left( \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right) \left( \begin{array}{cc} i & 0 \\ 0 & \sqrt{3} \end{array} \right) \frac{1}{2} \left( \begin{array}{cc} -1 & -1 \\ -1 & 1 \end{array} \right)= \frac{1}{2} \left( \begin{array}{cc} i + \sqrt{3} & i- \sqrt{3} \\ i- \sqrt{3} & i+ \sqrt{3} \end{array} \right)$

Note that the matrix
$A$
is not unique. We can swap over the eigenvectors, hence the eigenvalues, take the negative square root of on or both eigenvalues. Either of these will result in a different square root.