Composition of continious and analytic map 
Let $U,V,W\subset\mathbb{C}$ open and connected, $f:U\to V$ continous and $g:V\to W$ analytic and non-constant. If $g\circ f$ is analytic, does then $f$ have to be analytic as well?

I guess the answer is yes but I don't know how to prove it. 
 A: The answer is Yes.
For convenience let us denote $h=g\circ f$. If $f$ is a constant function, there is nothing to prove. In below we will assume that $f$ is non-constant. Then $f(U)$ is a connected set containing more than one point, and hence it contains some accumulation point. Since $g$ is analytic and non-constant, by identity theorem, $h(U)=g(f(U))$ contains more than one point, so $h$ is non-constant.
To show that $f$ is analytic on $U$, it suffices to show that for any $z_0\in U$, $f$ is analytic on some open neighborhood of $z_0$. There are two cases to discuss.
(i) If $g'(f(z_0))\ne 0$, then by inverse function theorem, there exists an open neighborhood $V_0$ of $f(z_0)$ contained in $V$, such that $g|_{V_0}$ has an analytic inverse. As a result, on $f^{-1}(V_0)$ we have $f=(g|_{V_0})^{-1}\circ h$, so $f$ is analytic on $f^{-1}(V_0)\ni z_0$.
(ii) If $g'(f(z_0))=0$, then we claim that there exists an open neighborhood $U_0$ of $z_0$ contained in $U$, such that $g'(f(z))\ne 0$ for every $z\in U_0\setminus\{z_0\}$. Once the claim is proved, from the discussion in case (i) we know that $f$ is analytic on $U_0\setminus\{z_0\}$. Since $f$ is continuous at $z_0$, by Riemann's removable singularity theorem, $f$ is analytic on $U_0$. 
Now we are only left to prove the claim. Suppose the claim is not true, so there exists a sequence $\{z_n\}\subset U\setminus\{z_0\}$ with $\lim\limits_{n\to \infty}z_n=z_0$, such that $g'(f(z_n))=0$ for every $n$. On the one hand, since $g$ is non-constant, $g'$ is not constantly $0$; on the other hand, $\lim\limits_{n\to \infty}f(z_n)=f(z_0)$. Then by identity theorem, $f(z_n)=f(z_0)$ when $n$ is large. However, it follows that $h(z_n)=h(z_0)$ when $n$ is large, and by identity theorem again, $h$ must be constant.  This contradiction completes the proof.  
