Let $Tx=\sum_{n=1}^\infty \lambda_n \langle x,e_n\rangle e_n$ be bounded where $\{\lambda_n\}_n$ are the complex eigenvalues and $\{e_n\}_n$ are an orthonormal basis of the separable space $H$. For any continuous function $f : \mathbb C \to \mathbb C$ define $f(T)(x) = \sum_{n=1}^\infty f(\lambda_n) \langle x,e_n\rangle e_n$.
Give necessary and sufficient conditions on a continuous $f : \mathbb C \to \mathbb C$ such that the following holds: Whenever $T$ is compact and self adjoint, then $f(T)$ is compact and self adjoint. Note that I want to prove that the conditions are sufficient (no need to prove they are necessary).