Block Diagonal Polynomial and Inverse Suppose that you have a block diagonal matrix $B$, which has blocks $B_1 \dots B_r$ along the diagonal. Show how you can express the polynomial function $f(B)$ and the inverse of $B$ in terms of functions on block matrices.
I know because of commutativity of matrix polynomials mentioned earlier in the book that two polynomials will always commute as such: $f(B)g(B) = g(B)f(B)$ and since block diagonal matrices are special cases of triangular matrices, any operations performed with itself preserves its triangular properties. Besides that, I don't quite understand what the question is asking from me and how to approach it and would like some help.
SOURCE: Linear Algebra and Optimization for Machine Learning: A Textbook (Charu C. Aggarwal); Page 14, Problem 1.2.9
 A: A block-diagonal matrix $B$ is one of the form
$$
B = \begin{bmatrix}
B_1 & 0 & \cdots & 0\\
0 & B_2 & \cdots & \vdots \\
\vdots & \vdots & \ddots & 0\\
0 & 0 & \cdots & B_r
\end{bmatrix}.
$$
What this problem boils down to (which I will leave for you to check), is that $B^k$ for integer $k$ is again a block-diagonal matrix, and it has form
$$
B^k = \begin{bmatrix}
B_1^k & 0 & \cdots & 0\\
0 & B_2^k & \cdots & \vdots \\
\vdots & \vdots & \ddots & 0\\
0 & 0 & \cdots & B_r^k
\end{bmatrix}.
$$
In particular, $k=-1$ is the inversion formula, and if $f(x) = a_0+a_1x+\dotsm +a_nx^n$ is a polynomial, it is not hard to see from the above that $f(B)$ is block-diagonal with form
$$
f(B) = \begin{bmatrix}
f(B_1) & 0 & \cdots & 0\\
0 & f(B_2) & \cdots & \vdots \\
\vdots & \vdots & \ddots & 0\\
0 & 0 & \cdots & f(B_r)
\end{bmatrix}.
$$
As for proving the first formula, start off by checking that if $A = {\rm diag}(A_1,\dotsc, A_r)$ and $B = {\rm diag}(A_1,\dotsc, A_r)$ are block-diagonal with equally sized partitions, then
$$AB = \begin{bmatrix}
A_1B_1 & 0 & \cdots & 0\\
0 & A_2B_2 & \cdots & \vdots \\
\vdots & \vdots & \ddots & 0\\
0 & 0 & \cdots & A_rB_r
\end{bmatrix}.$$
Setting $A = B^{-1}$ and using $AB = I$ will tell you what the inverse blocks are. Seeting $A = B$ will tell you what the blocks for $B^2$ are, and you can prove the $B^k$ result from there by induction.
