Let $ f: \mathbb{C} \to \mathbb{C} $ be defined on the complex plane by $$ f(z) = \begin{cases} f(z)=z & \textrm{if}\ \operatorname{Re}(z) \ge 0 \\ f(z)=z^{2} & \textrm{if}\ \operatorname{Re}(z) < 0 \end{cases}$$ Let $C$ denote the circle $|z|=1$ taken in the positive direction. Evaluate $\int_C f(z)\ dz$.
I think the answer is supposed to be $0$ because of Cauchy-Goursat theorem, but am not sure.
My attempt: $$\int_{-i}^{i}z\ dz + \int_{i}^{-i}z^2\ dz$$ $$= \left(\frac{-1}{2}-\frac{-1}{2}\right) + \left(\frac{i}{3}-\frac{-i}{3}\right)$$ $$= 0+\frac{2i}{3}$$
Your assumption is not correct. $f(z)$ is not continuous on the imaginary line and therefore is not holomorphic on the domain defined by $|z|<1$. This mean the integral is not necessarily $0$.
We can integrate the "regular" way (with parametrization). Let $z = e^{it}$ then
$$ \int_C f(z)\ dz = \int_{-\pi/2}^{\pi/2} e^{it}\ ie^{it}\ dt + \int_{\pi/2}^{3\pi/2} e^{2it}\ ie^{it}\ dt \\ = \left.\frac{e^{2it}}{2}\right|_{-\pi/2}^{\pi/2} + \left.\frac{e^{3it}}{3}\right|_{\pi/2}^{3\pi/2} = \frac{2i}{3} $$
This is in fact consistent with your attempt, because $f(z)$ is still piecewise continuous, so the contour can be broken up into two pieces, both of which are path-independent.