I'm reading the book "Finite-Dimensional Vector Spaces (2nd Ed)" by PR Halmos. The concept of a 2-variable function (or polynomial) for operators is introduced in Theorem 1 of Section 84 on page 171 in the following setting:
Two self-adjoint operators $A$ and $B$ on an $n$-dimensional inner product space are commutative, and have respective spectral forms $A = \sum_{i=1}^n \alpha_i E_i$ and $B = \sum_{j=1}^n \beta_j F_j$. There exists some real-valued function (or polynomial) $h$ in two variables, given by $h(\alpha_i, \beta_j) = \gamma_{ij}$, where the $\gamma$'s are arbitrary, pairwise-distinct real numbers (i.e., $ij \neq kl \implies \gamma_{ij} \neq \gamma_{kl}$).
Under this setting, the author first argues that $A$ and $B$ commute $\implies E_i$ and $F_j$ commute for all $i, j$. (This part is clear to me.) But then he briskly states that the function (or polynomial) given by $h(A, B)$ equals $\sum_{i=1}^n \sum_{j=1}^n h(\alpha_i, \beta_j)E_iF_j$. (This part puzzles me.)
While I understand why each $E_i$ commutes with each $F_j$ for all $i$ and $j$, I'm struggling to understand why $h(A, B)$ equals what the author has stated. Perhaps because I am unable to comprehend the concept of a 2-variable function (or polynomial) of operators even though I do understand the concept of a 1-variable function (or polynomial) of an operator. Would appreciate some help.
Since the $\{E_i\}$ and $\{F_j\}$ are orthogonal idempotents (meaning $E_iE_j=\delta_{ij}E_j$ and similar for $F_j$), any power of $A$ is given by $A^k=\sum_i \alpha_i^k E_i$. Therefore we have
$$ h(A,B)=\sum_{k,\ell} h_{k\ell} A^kB^{\ell}=\sum_{k,\ell} h_{k\ell}\left(\sum_i \alpha_i^kE_i\right)\left(\sum_j \beta_j^{\ell} F_j\right) $$
$$ = \sum_{i,j} \left(\sum_{k,\ell} h_{k\ell}\alpha_i^k\beta_j^\ell\right)E_iF_j=\sum_{i,j} h(\alpha_i,\beta_j)E_iF_j. $$