For example, if #f(x)=x^2+3x+5# and #D=diag[2,3]#, then you can check that #f(D)=D^2+3D+5I=diag[4,9]+diag[6,9]+diag[5,5]=diag[15,23]=diag[f(2),f(3)]# (note that "3D" is the scalar 3 times the matrix D and that "5" is interpreted as #5I#, where #I# is the #2 times 2# identity matrix #diag[1,1]#).

If #f# is not a polynomial, then often we can still say that #f(D)=diag[f(d_1),f(d_2),...,f(d_n)]#. For example, if #f(x)=e^(x)#, we can say that #f(D)=diag[e^(d_1),e^(d_2),...,e^(d_n)]#. This can either be thought of as a definition, or we can use the so-called "Taylor series" for #f(x)=e^(x)# centered at #x=0#, which is #f(x)=1+x+x^2/(2!)+x^3/(3!)+cdots#, to define #f(D)# to be #I+D+D^2/(2!)+D^3/(3!)+cdots#. However, in this situation, we would have to address possible "convergence issues" (i.e., what does such an infinite sum mean?).

If #f# happens to be undefined at any of the values #d_1,d_2,...,d_n#, then certainly #f(D)# would be undefined.

You might wonder in all this: why does #D# have to be a diagonal matrix? The answer is that defining #f(D)# to be a matrix obtained by applying #f# to all the entries of #D# is **not** typically consistent with the operations that define #f# along with the corresponding matrix operations. Even with a polynomial example, such as #f(x)=x^2+3x+5# above, we would not typically get the matrix #D^2+3D+5I#, if #D# is not diagonal, by applying #f# to all the entries of #D# individually.

Actually, you could also say that such an approach is even a problem when #D# is a diagonal matrix because the value of #f# at the other (zero) entries, #f(0)#, may be nonzero.