I am trying to solve the following integral: $$\oint \frac{4z^2+\cos(z)}{z-(\frac{1}{2}+\frac{i}{2})}dz$$ around the square $(0,0), (1,0), (1,i), (0,i)$.
I know I can use Cauchy Integral theorem to evaluate it as: $2\pi i[4(\frac{1}{2}+\frac{i}{2})^2+\cos(\frac{1}{2}+\frac{i}{2})]$, but my professor want us to evaluate the integral so as to see that it really is the same, but I am having a very hard time evaluating this integral.
Let us compute first the integral on the boundary $C$ of the square with vertices in $0,1,1+i,i$. We denote of course by $a$ the center of the square, $a=(1+i)/2$, for easy typing. $$ \begin{aligned} \int_C\frac {4z^2}{z-a}\; dz &= 4\int_C\frac {z^2-a^2+a^2}{z-a}\; dz \\ &= 4\int_C(z+a)\; dz+ 4a^2\int_C\frac 1{z-a}\; dz \\[3mm] &= \Big[2(z+a^2)\Big]_0^1 + \Big[2(z+a^2)\Big]_1^{1+i} + \Big[2(z+a^2)\Big]_{1+i}^i + \Big[2(z+a^2)\Big]_i^0 \\ &+ \Big[4a^2\log(z-a)\Big]_0^1 + \Big[4a^2\log(z-a)\Big]_1^{1+i} + \Big[4a^2\log(z-a)\Big]_{1+i}^i + \Big[4a^2\log(z-a)\Big]_i^0 \\[3mm] &=2(1-0)+2((1+i)-1)+2(i-(1+i))+2(0-i) \\ &+ 4a^2\left( -\frac{\pi i}4-\left(-\frac{3\pi i}4\right)\right) + 4a^2\left( \frac{\pi i}4-\left(-\frac{\pi i}4\right)\right) + 4a^2\left( \frac{3\pi i}4-\frac{\pi i}4\right) + 4a^2\left( \frac{5\pi i}4-\frac{3\pi i}4\right) \\[3mm] &= 0+4a^2\cdot 2\pi i\ . \end{aligned} $$ Then we also have to take care of the part with the cosine. I would also start in the same manner with $$ \begin{aligned} \int_C\frac {\cos z}{z-a}\; dz &= \int_C\frac {\cos z-\cos a+\cos a}{z-a}\; dz \\ &= \int_C\frac {\cos z-\cos a}{z-a}\; dz + \int_C\frac {\cos a}{z-a}\; dz \ . \end{aligned} $$ The second integral uses an other constant factor near $\int _C\frac{dz}{z-a}$, and this exercise was already covered in detail.
It remains an integral that has no simple form, and it makes for me no sense to explicitly compute a primitive written in terms of elliptic integrals to see how they cancel "without using" complex analysis, harmonic functions, Stokes, et caetera. The hope to have a point symmetry w.r.t. $a=(1+i)/2$ was soon destroyed. So we are in the position to use the screw driver instead of the hammer to pin and win a problem with a needle. (Just as a speculation, the professor will never do the computation, and not even consider in dream typing it. But even if the typed work would be done, publishing this on an internet page would be too much exposure.)
All i can do here now is to take the expression making problems and split it: $$ \begin{aligned} \cos z-\cos a &= \cos(z-a+a)-\cos a\\ &=(\cos(z-a)-1)\cos a - \sin(z-a)\sin a\ , \end{aligned} $$ and after the substitution $w=z-a$ we have to compute on the translated contour $C-a$ with a dihedral symmetry in zero the two integrals: $$ \int_{C-a}\frac{\cos w-1}w\; dw\ ,\qquad \int_{C-a}\frac{\sin w }w\; dw\ . $$ Using the complex analysis hammer, both are zero. But let us screw the situation, and integrate the two odd, respectively even holomorphic functions, and take the primitives, which are even, respectively odd in the points $(\pm 1\pm i)/2$. With computer aid, sage, the values of the primitives in the corners are
The primitives, computed in the corners, are expressed in terms of the elliptic integral $\operatorname{Ei}(x) = \int_{-\infty}^x \frac{\exp }{t} \; dt$, so the computer rather echoes our request telling us that there is no better way to write the primitives. Our integrals on the sides are the differences of the primitives $F,G$ in the corresponding corners $c_1,c_2,c_3,c_4$, so the integrals on the contour vanish $$(F(c_2)-F(c_1))+(F(c_3)-F(c_2))+(F(c_4)-F(c_3))+(F(c_1)-F(c_4))=0\ ,$$ $$(G(c_2)-G(c_1))+(G(c_3)-G(c_2))+(G(c_4)-G(c_3))+(G(c_1)-G(c_4))=0\ .$$ It is hard to screw up more, and citing, i understand the posted "very hard time evaluating this integral". This answer is only a partial evaluation, but it is all i have, cannot do more.