$\int_{\Gamma} \frac{dz}{z}$, $\Gamma = \gamma([0,2\pi])$, $\gamma(t) = a\cos(t) + i b \sin(t)$ I am solving an exercise:

Evaluate by two methods: $$\int_{\Gamma} \frac{dz}{z}; \ \text{where:} \  \Gamma = \gamma([0,2\pi]), \text{and:}$$
$$\gamma: [0,2\pi] \longrightarrow \mathbb C \\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  \ \ \ \ \ \  \ \ \  \ \ \  \ \ \  \ \ \  \ \ \ \ \ \  \ \ \ \ \ \  \ t \ \ \  \ \ \  \longrightarrow \gamma(t) = a\cos(t) + i b \sin(t)$$
Where $a$ and $b$ are fixed positive reals.

One method would be using Cauchy's integral formula:
$$\int_{\Gamma} \frac{dz}{z} = 2 \pi i $$
The second method would be by using the definition:
$$\int_{\Gamma} \frac{dz}{z} = \int_0^{2\pi} \frac{1}{\gamma(t)} \dot {\gamma(t)} dt$$
Which results in, after multiplying the numerator and denominator by the complex conjugate:
$$\int_{\Gamma} \frac{dz}{z} = \int_0^{2 \pi} \frac{(b^2 - a^2)\cos(t) \sin(t)}{a^2 \cos^2(t) + b^2 \sin^2(t)}dt + iab \int_0^{2\pi}\frac1{a^2 \cos^2(t) + b^2 \sin^2(t)}dt$$
Clearly, the first one should evaluate to $0$ because there is no real part in the above answer. So, this leaves us to just calculate the second one.
However, the question asks (in the second part) to deduce the value of:
$$\int_0^{2\pi}\frac1{a^2 \cos^2(t) + b^2 \sin^2(t)}dt$$
So, I shouldn't calculate that beforehand (supposing that it is possible to actually calculate it).
So, there must be some trick to be done to both of the above integrals in order to extract a result. Maybe a suitable change of variable or something.
What I tried:

*

*Reduction of boundaries using periodicity and parity, then a change of variable $\theta = \tan(t/2)$. It wasn't useful.


*Adding and subtracting random things. But no nice expressions emerged.


*Double angle formulas, random changes of variables, etc.
Any help?
Thank you.

The first thing to do is use the double-angle formulae,
$$ \cos{2\theta} = 2\cos^2{\theta}-1 = 1-2\sin^2{\theta}, $$
which turns the denominator into
$$ \frac{1}{2} \left( (a^2+b^2) + (a^2-b^2)\cos{2\theta} \right) $$
Then we are dealing with something that has period $\pi$, so the transformation of the integral to the interval $[-\pi/2,\pi/2]$ is reasonable. Now setting $t=\tan{\theta}$, we have
$$ \cos{2\theta} = \frac{1-t^2}{1+t^2}, \quad d\theta = \frac{dt}{1+t^2}, $$
so the integral transforms to
$$ \int_0^{2\pi} \frac{d\theta}{a^2\cos^2{\theta}+b^2\sin^2{\theta}} = 2\int_{-\pi/2}^{\pi/2} \frac{d\theta}{a^2\cos^2{\theta}+b^2\sin^2{\theta}} \\
= 4\int_{-\pi/2}^{\pi/2} \frac{d\theta}{(a^2+b^2) + (a^2-b^2)\cos{2\theta}} \\
= 4\int_{-\infty}^{\infty} \frac{d\theta}{(a^2+b^2)(1+t^2)+(a^2-b^2)(1-t^2)} \\
= 2\int_{-\infty}^{\infty} \frac{d\theta}{a^2+b^2 t^2},
$$
which is easy enough to do using $\arctan$, and gives $\pi/(ab)$.

The real part integral is actually quite easy: you can either note that $\frac{d}{d\theta} \sin^2{\theta} = 2\sin{\theta}\cos{\theta} $, or just use the double-angle formulae:
$$ \int_0^{2\pi} \frac{(b^2-a^2)\sin{\theta}\cos{\theta}}{a^2\cos^2{\theta}+b^2\sin^2{\theta}} \, d\theta = \int_0^{2\pi} \frac{(b^2-a^2)\sin{2\theta}}{(a^2+b^2) + (a^2-b^2)\cos{2\theta}} \, d\theta = \left[ \frac{1}{2}\log{\left( (a^2+b^2) + (a^2-b^2)\cos{2\theta} \right)} \right]_0^{2\pi} $$
Now, $a,b$ are real and positive, so $a^2+b^2>\lvert a^2-b^2 \rvert$, so the logarithm is a legitimate continuous antiderivative, and the integral is therefore equal to zero.

Entirely possibly, the question is actually asking that you just get down to
$$ 2\pi i = \int_{\gamma} \frac{dz}{z} = iab\int_0^{2\pi} \frac{d\theta}{a^2\cos^2{\theta}+b^2\sin^2{\theta}}, $$
from which you then get the value of the latter integral by transitivity of equality (to get fancy with our deductive terminology).

Perhaps a sillier suggestion: substitute $e^{i\theta}=w$, so $d\theta = dw/(iw)$. Then you have
$$ \int_{0}^{2\pi} \frac{-a\sin{\theta}+ib\cos{\theta}}{a\cos{\theta}+b\sin{\theta}} d\theta = \int_{|w|=1} \frac{-ia(w-1/w)+b(w+1/w)}{a(w+1/w)-ib(w-1/w)}\frac{dw}{iw} \\
= \dotsb = \int_{|w|=1} \left( \frac{2(a+b)w}{a-b+(a+b)w^2}-\frac{1}{w} \right) dw$$
Right, now we have the fun of doing residues. The residue at $w=0$ is obviously $-1$. The problematic ones are $w=\pm \sqrt{(b-a)/(a+b)}$. First question: are they even inside $|w|=1$? Answer: $|b-a|<a+b$, so yes, both are. And it turns out the residues are actually reasonable to compute, because
$$ \frac{2w}{w^2-c^2} = \frac{1}{w-c}+\frac{1}{w+c}, $$
and hence both residues are $1$. Hence the sum of the residues is $1+1-1=1$, and the integral is
$$ \int_{0}^{2\pi} \frac{-a\sin{\theta}+ib\cos{\theta}}{a\cos{\theta}+b\sin{\theta}} d\theta = 2\pi i. $$
