Symmetric matrix operator Let $A\in\mathbb{R}^{n\times n}$ be a symmetric matrix with eigen values $\lambda_1\geq \lambda_2\geq\cdots\geq\lambda_n$ and spectral decomposition given by
$$
A = PDP^{\top},
$$
where $D = \text{diag}(\lambda_1,...,\lambda_n)$ and $P$ is orthogonal.
Let $\mathcal{S}\subset\mathbb{R}$ be a set such that $\lambda_i\in\mathcal{S}$ for all $i$, and define some function $f:\mathcal{S}\to\mathbb{R}$.
We define the matrix $f(A)$ as
$$
f(A) = Pf(D)P^{\top},
$$
where
$$
f(D) = \text{diag}(f(\lambda_1),...,f(\lambda_n)).
$$
Is $f(A)$ well defined?
I mean, the spectral decomposition $A = PDP^{\top}$ is not unique since there could be $i,j$ s.t. $\lambda_i=\lambda_j$, which provokes that $P$ is not unique.
Any insight will be apreciated!
 A: It is well defined. The reason is that $f(D)$ can be expressed as a polynomial in $D$ (whose degree and coefficients depend on $f$ and $D$), which makes $f(A)$ expressible as a polynomial in $A$. In fact, if $\mu_1,\mu_2,\ldots,\mu_m$ are those distinct eigenvalues of $A$ and $g$ is the Lagrange interpolation polynomial
$$
g(x)=\sum_{i=1}^m\prod_{j\ne i}\frac{x-\mu_j}{\mu_i-\mu_j}f(\mu_i),
$$
then $g(\mu_i)=f(\mu_i)$ for each $i$. (In the corner case where $A=\mu I$, we define $g$ as the constant polynomial $f(\mu)$.) Hence $g(\lambda_i)=f(\lambda_i)$ for each $i$ (because each $\lambda_i$ is some $\mu_k$), $f(D)=g(D)$ and $Pf(D)P^T=Pg(D)P^T=g(PDP^T)=g(A)$. Since $g$ depends only on the unordered multi-set of eigenvalues of $A$ but not on $P$ or on the order of the $\lambda_i$s on the diagonal of $D$, the product $Pf(D)P^T$ always evaluates to the same value, namely $g(A)$, regardless of spectral decomposition performed.
A: Because $P^\perp P=I$,
$$
              A^2 = (PDP^\perp)^2=PDP^{\perp}PDP^{\perp}=PD^2P^\perp \\
              A^n = PD^nP,\;\;\; n=1,2,3,\cdots.
$$
Define $P^0=I$. Then, if $p$ is a polynomial,
$$
                p(A)=Pp(D)P^\perp.
$$
For the diagonal matrix $D$ with diagonal $d_1,d_2,\cdots,d_N$, this definition of $p(D)$ gives the diagonal matrix with diagonal $p(d_1),p(d_2),\cdots,p(d_N)$.
This is consistent with standard evaluation of a polynomial with the matrix $A$. And you can see that $(pq)(A)=p(A)q(A)$ for example.
