There does not exist any holomorphic function $f$ in the open unit disc such that $f\left(\frac{1}{n}\right)=\frac{(-1)^n}{n^2}$

I want to show that

There does not exist any holomorphic function $f$ in the open unit disc such that $$f\left(\frac{1}{n}\right)=\frac{(-1)^n}{n^2}, n=2,3,\ldots$$

My attempt:

Suppose there exists such a holomorphic function. Now $$f\left(\frac{1}{n}\right)=\begin{cases}\frac{1}{n^2}, & \text{if } n\ \text{is even.}\\ -\frac{1}{n^2}, & \text{if } n\ \text{is odd.} \end{cases}$$

Which says that $f(z)=z^2$ and $f(z)=-z^2$, which is not possible. Therefore, there does not exit any such holomorphic function.

Is my argument fine?

EDIT

I used the identity theorem to conclude that. Take $g(z)=z^2$. Since $$f\left(\frac{1}{n}\right)=g\left(\frac{1}{n}\right)=\frac{1}{n^2}$$ As, $\frac{1}{n}\to 0\in \mathbb{D}(0,1)$ so using identity theorem I conclude that $f\equiv g$ on $\mathbb{D}$. Similar argument shows that $f(z)=-z^2$, and hence contradiction.

• Yes, this is right. In order to be totally precise, you should say why determining $f$ on all values $\tfrac{1}{n}$ with either even or odd $n$ already determines $f$ on all complex numbers. The keyword here is the identity theorem. – Luke Sep 20 '17 at 12:15
• In other words, $f$ coincides with $z \mapsto z^2$, on the set $\left\{\frac{1}{n} : n \in\mathbb{N}, n\text{ is even}\right\}$ and coincides with $z \mapsto -z^2$ on the set $\left\{\frac{1}{n} : n \in\mathbb{N}, n\text{ is odd}\right\}$. Both of these sets have a limit point, which is $0$, so we would have $f(z) = z^2$ and $f(z) = -z^2$. Contradiction. – mechanodroid Sep 20 '17 at 12:27

Because (aside from the letter $z$), there's no mention of complex numbers here. In particular, if the solution as written were good, it'd also apply to smooth functions on the reals, but it clearly does not. (There is a smooth function from $\Bbb R$ to $\Bbb R$ that meets those requirements!)