I was wondering about this problem for a while out of curiosity: is there a non-constant analytic function with real values on $\mathbb{R}$ and purely imaginary values $i\mathbb{R}$?
I think the answer is a no by using Cauchy-Riemann equations but somehow I can't formulate it right. Your help is appreciated.
So sorry I made a mistake in writing the question.
If you want $f(z)$ to be analytic on $\mathbb C$ such that $f(z) \in \mathbb R$ when $z \in \mathbb R$ and $f(z) \in i \mathbb R$ when $z \in i \mathbb R$, $f(z)$ can be any given by any series with infinite radius of convergence that has the form $\sum_{j=0}^\infty c_j z^{2j+1}$ where $c_j$ are real.