TITLE: Proving that if $f: \mathbb{C} \to \mathbb{C} $ is a continuous function with $f^2, f^3$ analytic, then $f$ is also analytic
QUESTION [12 upvotes]: Let $f: \mathbb{C} \to  \mathbb{C}$ be a continuous function such that $f^2$ and $f^3$ are both analytic. Prove that $f$ is also analytic.

Some ideas: At $z_0$ where $f^2$ is not $0$ , then $f^3$ and $f^2$ are analytic so $f = \frac{f^3}{f^2}$ is analytic at $z_0$ but at $z_0$ where $f^2$ is $0$, I'm not able to show that $f$ is analytic.

REPLY [4 votes]: If $f(z) = 0$ for all $z$, then it's analytic, and there's nothing more to show. Otherwise assume $f$ is not identically zero. At a point $z_0$ where $f(z_0) \ne 0$, $f(z) = \frac{f^3(z)}{f^2(z)}$ is analytic because the quotient of two analytic functions is analytic when the denominator is non-zero. At a point $z_0$ with $f(z_0) = 0$, the Uniqueness Theorem for analytic functions says that there is a neighborhood of $z_0$ where $f(z) = 0$ only at $z = z_0$ (otherwise you get a sequence of points converging to $z_0$ with $f$ zero on points of the sequence, etc...). In this neighborhood you get $\frac{f^3(z)}{f^2(z)} \rightarrow 0$ as $z \rightarrow z_0$, since $\left| {\frac{f^3(z)}{f^2(z)} } \right| = \frac{\left| f^3(z) \right|}{\left| f^2(z) \right|} = \frac{\left| f^2(z) \right|^{\frac{3}{2}}}{\left| f^2(z) \right|} = \left| f^2(z) \right|^{\frac{1}{2}}$, which goes to $0$ as $z \rightarrow z_0$ (because $f^2$ is analytic and hence continuous with $f^2(z_0) = 0$). So $f(z) \rightarrow 0$ as $z \rightarrow z_0$. Now we have that $f(z)$ is analytic in a punctured neighborhood of $z_0$ and continuous at $z_0$, and so is in fact analytic at $z_0$ itself as a corollary of Morera's Theorem.