TITLE: If $f^2$ is an analytic function then so is $f$
QUESTION [9 upvotes]: I want to show the following:
If $f(z) $ is a continuous  function on a connected open subset of the complex plane and $f(z)^2$ is an analytic function, then $f(z)$ is analytic.
Clearly if $f(z) \neq 0$ then $$\frac{f(z+h)-f(z)}{h}=\frac{f(z+h)^2-f(z)^2}{h}.\frac{1}{f(z+h)+f(z)}$$
which shows $f^\prime(z) $ exists if $f(z)\neq0$.
What do I do when $f(z) =0$?

REPLY [11 votes]: a) Since $f^2$ is holomorphic, the Cauchy-Riemann criterion (expressed in Wirtinger's wonderfully concise notation) $\partial f^2/\partial \bar z=2f\partial f/\partial \bar z=0$, shows that $f$ is holomorphic at all points $z$ where $f(z)\neq 0$, since there $\partial f/\partial \bar z=0$. [This is the part solved by Don Antonio in more classical notation] 
b) Since $f^2$ is holomorphic its zeros are isolated and so are those of $f$ (they are the same!)
But  $f$ is locally bounded at those potential singularities, because $f^2$ is, and so Riemann's theorem on removable singularities permits you to conclude that the singularity is bogus and that actually $f$ is holomorphic also at the zeros of $f$ .  
Conclusion:  $f$ is holomorphic everywhere on its domain.