ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 06 Jun 2018 16:12:15 +0200More problems with general power of a matrixhttps://ask.sagemath.org/question/42532/more-problems-with-general-power-of-a-matrix/Even though in version 8.2 the code for the general power of a matrix has been improved (c.f. [question 41622](https://ask.sagemath.org/question/41622/bug-in-general-power-of-a-matrix/)), it still doesn't work in some cases, as i.e. this singular, diagonalizable matrix
A=matrix(QQbar,3,3,[[-2,-8,-12],[1,4,4],[0,0,1]])
k=var('k')
A**k
shows.
Concerning the [remark in trac ticket 25520](https://trac.sagemath.org/ticket/25520): Why not defining $0^x=1$ for $x\in {\bf N}$, which seems reasonable, since the number of functions $\emptyset \to \emptyset$ is 1?Frank ZenterWed, 06 Jun 2018 16:12:15 +0200https://ask.sagemath.org/question/42532/Bug in general power of a matrixhttps://ask.sagemath.org/question/41622/bug-in-general-power-of-a-matrix/The code to [question 35658](http://ask.sagemath.org/question/35658/ge) gives a wrong answer i.e. for the matrix
A=matrix([[4,1,2],[0,2,-4],[0,1,6]])
Where can I find an improvement?
For $k\in {\bf N}$ the $k$-th power of a matrix $A\in {\bf R}^{n\times n}$ satisfies by definition the recursion $A^{k+1}=A*A^k$ and the initial condition $A^0=I$.
Substitution of $k=0$ and $k=1$ should therefore give the identity matrix $I$ resp. the matrix $A$. The following
[live code](http://sagecell.sagemath.org/?z=eJzLVrBVKEss0lDPVtfk5XK0zU0sKcqs0IiONtEx1DGK1Yk20DHS0TUBMwx1zGJjgaoK8ktsHeOyebmKM_LLNYA8oBiCo1dcmlSskW1roKmJKWioqQkA_MQgTQ==&lang=sage) does (currently) not give the expected answer.
Btw: One of the [M-programs](http://www.wolframalpha.com/input/?i=MatrixPower[{{4,1,2},{0,2,-4},{0,1,6}},k])
gives the correct answer.Frank ZenterMon, 19 Mar 2018 13:45:23 +0100https://ask.sagemath.org/question/41622/