I want to evaluate the integral $\int_C \text{Re }z\,dz$ from $-4$ to $4$ via the contour being the lower half of the circle of radius $4$ centered at the origin.
So I can take:
$$z=4e^{i\theta},\quad\pi\leq\theta\leq2\pi$$ $$f(z)=4\cos(\theta),z'(\theta)=4ie^{i\theta}$$ $$\int_\pi^{2\pi}4\cos(\theta)4ie^{i\theta} \,d\theta$$
I then take integration by parts $$I=16\left(\left.-e^{i\theta}\cos\theta\right|_\pi^{2\pi} -\int_{\pi}^{2\pi}ie^{i\theta}\sin(\theta)d\theta\right)$$ $$I=16(-e^{i2\pi}-e^{i\theta}+I)\implies I=0$$
I got a different result via different contours (-4 to -4-4i to 4-4i to 4) ($32i$) and was wondering if I had done the above wrong. I know that the contour choice can effect the result, but I doubt $0$ is correct.
You are right that different contour would possibly give you different result in this case, since the function is not holomorphic.
However, the integration by parts wouldn't work in this case.
You should separate the real part and imaginary part:
$$I=16i\int^{2\pi}_{\pi} (\cos\theta+i\sin\theta)\cos\theta d\theta\\ =16i\int^{2\pi}_{\pi}\cos^2\theta d\theta -16 \int^{2\pi}_{\pi}\cos \theta\sin \theta d\theta$$
I believe you can continue from here.