Complex derivative from definition Working directly from the definition of a derivative, show that $f(z)=3ze^{iz}+|z|^2+4$ is differentiable at the origin an determine $f'(0)$.
I got: $$f'(0)=\lim_{z \to 0}\frac{3ze^{iz}+|z|^2+4-4}{z}=\lim_{z \to 0}\frac{3ze^{iz}+|z|^2}{z}\frac{\bar{z}}{\bar{z}}$$ but at this point I don't know what do do with that $e^{iz}$, is that $e^{-y}(\cos x + i \sin x)$? (If $z = x+iy$)
Also, $|z|$ is not differentiable anywhere, so, how is this even possible!?
 A: Split into two terms:
$$\lim_{z\rightarrow 0}\frac{3ze^{iz}}{z} + \lim_{z\rightarrow 0}\frac{|z|^2}{z}$$
In the first term, the $z$ cancels from top and bottom, so the limit is $3$. In the second term, multiplying top and bottom by $\overline{z}$ gives you,
$$\lim_{z\rightarrow 0}\frac{|z|^2}{z} \cdot \frac{\overline{z}}{\overline{z}} = \lim_{z\rightarrow 0}\frac{|z|^2\overline{z}}{|z|^2} = \lim_{z\rightarrow 0} \overline{z}$$
Note that $|\overline{z} - 0| = |z| \rightarrow 0$ as $z \rightarrow 0$. Hence $\overline{z} \rightarrow 0$. Thus, the derivative is $3$.
It's worth noting that, while it's true that the square of a differentiable function is always differentiable (by the chain rule), it is not true that the square of a non-differentiable function is non-differentiable. So, even though $|z|$ is not differentiable at $0$, it isn't true that $|z|^2$ is not differentiable at $0$. For a real example, take the following example:
$$f(x) = \left\lbrace\begin{array}{ccc}1 & : & x \in \mathbb{Q} \\ -1 & : & x \in \mathbb{R} \setminus \mathbb{Q}\end{array}\right.$$
Note that $f$ is discontinuous everywhere, but $f(x)^2 = 1$ for all $x$, and hence is (infinitely) differentiable everywhere.
