Let $A$ be a diagonalizable matrix over the field $F$ and $f:F\rightarrow F$. Then we can define the following matrix:
$f(A) = P^{-1}f(D)P$ where $D$ is diagonal and $f(D)$ is the diagonal matrix defined via $f(D)_{ii} = d(D_{ii})$
Alternatively we can define $f(A)$ via its eigenspaces $E_{x}(f(A)) = \sum\limits_{x\in f^{-1}(x)}E_{x}(A)$
Please assume $F$ is whatever we want if there is a special word for it in that context
As mentioned by Qiaochu Yuan in the comments, " This general construction is called “functional calculus,” see for example: https://en.m.wikipedia.org/wiki/Holomorphic_functional_calculus "