Exponentiation of a diagonal matrix By the definition of matrix exponentiation,

$$A^k = \begin{cases}
I_n, &amp; \text{if } k=0  \\[1ex]
A^{k-1}A, &amp; \text{if } k\in \mathbb {N}_0  \\
\end{cases}$$

In my book, there's an exercise to do $D^k$, where $D$ is a diagonal matrix.
In the solutions, though, they wrote

$$D^k=\operatorname{diag}(d_1^k, \dots , d_n^k)$$

Which one is correct?
Both are correct but they are two different topics.

$$A^k=\left\{ 
\begin{array}{c}
I_n, if\, k=0  \\
A^{k-1}A, if\, k\in {\displaystyle \mathbb {N} }_0  \\
\end{array}
\right.$$
is the definition of the matrix power $A^k$ in general.

On the other hand $$D^k=diag(d_1\,^k, ... , d_n\,^k)$$ is a special case where your matrix is a diagonal matrix.

There is no conflict because the second one is just the application of the first one to the diagonal matrix $$D=diag(d_1,d_2, ... , d_n)$$
Let $$D=\begin{bmatrix} a &amp; 0 &amp; 0 \\ 0 &amp; b &amp; 0 \\ 0 &amp; 0 &amp; c \end{bmatrix}.$$ then by the property of diagonal matrix
$$f(D)=\begin{bmatrix} f(a) &amp; 0 &amp; 0 \\ 0 &amp; f(b) &amp; 0 \\ 0 &amp; 0 &amp; f(c) \end{bmatrix}$$ So  $$D^k= \begin{bmatrix} a^k &amp; 0 &amp; 0 \\ 0 &amp; b^k &amp; 0 \\ 0 &amp; 0 &amp; c^k \end{bmatrix}$$ and $$D^0 =\begin{bmatrix} 1 &amp; 0 &amp; 0 \\ 0 &amp; 1 &amp; 0 \\ 0 &amp; 0 &amp; 1 \end{bmatrix}$$