A brute force approach is possible:
A = Array[a, {4, 4}];
rhs = DiagonalMatrix[{1, 1}, 2];
eqns = A . A == rhs // LogicalExpand;
solns = Solve[Reduce[eqns]];
Length[solns]
(* 3 *)
MatrixForm /@ Simplify[A /. solns]

Verify that these do indeed solve the equation
A . A == rhs /. solns // Simplify
(* {True, True, True} *)
The first solution is a function of 4 parameters. Clearly, the second solution is simply the special case of the first with a[4,4]->0
. I wonder if the third is a special limiting case of the first, but I haven't tried too hard to find it.
Some clues are available as to why Mathematica fails with more direct approaches. For example
MatrixFunction[Sqrt, rhs, Method -> "Jordan"]
(* MatrixFunction::fnanc: The function Sqrt[#1]& is not analytic at 0. *)
(* MatrixFunction[Sqrt, {{0, 0, 1, 0}, {0, 0, 0, 1}, {0, 0, 0,
0}, {0, 0, 0, 0}}, Method -> "Jordan"] *)
In fact, MatrixFunction
documentation states
MatrixFunction does not return a result when the scalar function or any of its initial derivatives are not defined at matrix eigenvalues
In this case, we have
Eigenvalues[rhs]
(* {0, 0, 0, 0} *)
{{0,0,0,1/17},{17,0,13,0},{0,0,0,0},{0,0,17,0}}
? $\endgroup$MatrixPower[...,1/2]
uses power series and in the possible issues sections forMatrixFunction
one sees that it will not work if the scalar function is not analytical at the eigenvalues. For a nilpotent matrix all of the eigenvalues are 0 and Sqrt is not analytic at 0. $\endgroup$MatrixPower[...,1/2]
for a diagonal matrix with a 0 eigenvalue. I suppose that applies if the matrix is not diagonalizable and it needs to compute the power series. In any case power series will not work because one would have to apply Sqrt[1+(#-1)]& and for a Nilpotent matrix N, N-1 does not have a matrix norm smaller than 1. $\endgroup$MatrixPower
can computeSign
function on matrices, which is obviously not analytic at zero. $\endgroup$