# Why doesn't Mathematica return the identity matrix for the 0-th power of a singular square matrix?

My understanding is that by definition, the 0-th power of any square matrix is the identity matrix. This is what the mathworld entry for matrix powers and answers to a math.SE question assert.

Yet when I ask Mathematica to compute the 0-th power of a singular matrix,

MatrixPower[{{1, 1}, {1, 1}}, 0]


I get the following error message and the unevaluated input back out.

MatrixPower::sing: Matrix {{1,1},{1,1}} is singular.


Obviously I can fix this by unprotecting MatrixPower and defining:

Unprotect[MatrixPower]
MatrixPower[m_?SquareMatrixQ, 0] := IdentityMatrix[Length[m]]
Protect[MatrixPower]


But I'd like to understand this properly. Is there some reason that a non-singular matrix might be thought not to have a 0-th power? Can someone explain what is going on?

• Well, that depends on the definition... what would you say $0^0$ is? Sep 23, 2016 at 20:21
• Recommend that you use MatrixPower[m_?SquareMatrixQ, 0]:= ... Sep 23, 2016 at 22:11
• @BobHanlon Good point. Thank you, and fixed. Sep 23, 2016 at 22:37

Consider a general $2\times 2$ matrix, and its general power $n$:

f[a_, b_, c_, d_, n_] := FullSimplify @ MatrixPower[{{a, b}, {c, d}}, n]

MatrixForm @ f[a, b, c, d, n] The denominator is $\sqrt{4bc+(a-d)^2}$, so it looks like there's no problem with it for a matrix like {{1,1},{1,1}}. Let's simplify things:

MatrixForm @ f[1, 1, 1, 1, n] There's the culprit: for n=0 an indeterminate form $0^0$ occurs, hence the error.

There's no problem with non-singular matrices, e.g.

f[1, 1, 1, 0, 0]


{{1,0},{0,1}}

Finally,

Limit[f[a, b, c, d, n], n -> 0]


and

Limit[f[1, 1, 1, 0, n], n -> 0]


both give

{{1, 0}, {0, 1}}

but

Limit[f[1, 1, 1, 1, n], n -> 0]


{{1/2, 1/2}, {1/2, 1/2}}

• Thank you! This makes sense in terms of what Mathematica is trying to do, I guess. But is it correct in doing so? I thought that by definition the 0-th power of any square matrix, including a singular matrix, is the identity matrix of the same size. E.g. from mathworld: mathworld.wolfram.com/MatrixPower.html Or from SE: math.stackexchange.com/questions/699740/… Sep 23, 2016 at 20:33
• Oddly, Limit[MatrixPower[{{1, 1}, {1, 1}}, n], n -> 0] evaluates to {{1/2, 1/2}, {1/2, 1/2}} Sep 23, 2016 at 21:56
• @BobHanlon Makes some sense from the point of view of syntax: Limit[0^n + 2^n, n -> 0] seems to take $0^n=0$ and then proceed with the rest of the limit. Can the fact that MatrixPower[{{1, 1}, {1, 1}}, 0] does not return an identity matrix be considered a bug? Sep 23, 2016 at 22:03
• It's not a bug. Sep 25, 2016 at 21:03