Is this a bug on the zero power of matrix?

조회 수: 5 (최근 30일)
Yuchen Lu
Yuchen Lu 2015년 5월 6일
편집: James Tursa 2015년 5월 6일
If I set A=[0,0;0,0], and I type A^0, the result would be eye(2), which is wrong. The same fault happens when A=[1,1;1,1]. The result is [0.5,0.5;0.5,0.5], if you approximate A^0 by iterately computing A=A^0.5. But matlab gives result A^0=eye(2) again. I'm quite confused now, is this a bug, or am I making a mistake somewhere?

답변 (2개)

Ingrid
Ingrid 2015년 5월 6일
편집: Ingrid 2015년 5월 6일
I think this answer is correct since If exponentiation means repeated multiplication, then A^0=I is the base case for all A.
if this is not the result that you want maybe you were thinking of elementwise power (.^)

James Tursa
James Tursa 2015년 5월 6일
편집: James Tursa 2015년 5월 6일
There are multiple ways of evaluating the limit of x^y when x and y both go to 0. One of them, the way you used, is to start with 0^y for positive y and then shrink y to 0. The limit in this case is 0, of course. Another way is to start with x^0 for positive x and then shrink x to 0. The limit in this case is 1. Extend these concepts to an NxN matrix and you get zeros(N) and eye(N) as the possible choices. There are arguments on both sides as to which is the "correct" or "more useful" value for computing purposes, and the advantages and disadvantages of each choice. MATLAB has chosen the latter probably for consistency with IEEE lower level functions.
E.g., one consequence of this is that (sparse matrix)^0 is no longer sparse since all of those 0 elements become 1.
Two of the gazillion links on this:

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by