Puzzling Definite Integrals So I looked at the MIT 2015 integration bee and got almost all of them right however there are 2 that are puzzling me $$\int_{0}^{2\pi}\frac{1}{\sin^4 x+\cos^ 4 x}\text{d}x$$ $$\int_{0}^{4}\frac{|x-1|}{|x-2|+|x-3|}\text{d}x$$ For that first one through intense trig simplification I got it down to $\int_{0}^{2\pi}\frac{4}{3+\cos 4x}$ and then using a variation of Weierstrauss $t=\tan 2x$ I get that the bounds go from $\tan 0$ to $\tan 4\pi$ so an integral from 0 to 0 is zero, however the answer is $2\pi\sqrt 2$. Could this have something to do with tangent being undefined along the interval? As for the second one I thought since the bottoms was never $0$ we could just evaluate $$\left |\int_{0}^{1}\frac{x-1}{x-2+x-3}\text{d}x\right |+\left |\int_{1}^{4}\frac{x-1}{x-2+x-3}\text{d}x\right |$$ and the absolute value signs around the integrals is just so I don't have to worry about negatives. The answer to this question is $2+\frac{3}{4}\ln \left(\frac{27}{5}\right )$. This approach is also incorrect so how am I wrong on both of these and how would I evaluate each of them correctly?
 A: $$I=\int_{0}^{2\pi}\frac{dx}{\sin(x)^4+\cos(x)^4}=\int_{0}^{2\pi}\frac{dx}{1-2\sin^2(x)\cos^2(x)}=\int_{0}^{2\pi}\frac{dx}{1-\frac{1}{2}\sin^2(2x)} $$
leads to:
$$ I = \frac{1}{2}\int_{0}^{4\pi}\frac{dz}{1-\frac{1}{2}\sin^2(z)} = 4\int_{0}^{\pi/2}\frac{dz}{1-\frac{1}{2}\sin^2(z)}=4\int_{0}^{\pi/2}\frac{dz}{1-\frac{1}{2}\cos^2(z)} $$
where in the last steps we exploited the symmetry and periodicity of $\sin^2$. Since $\tan x$ is injective on $(0,\pi/2)$, we may now substitute $z=\arctan t$ and get:
$$ I = 4 \int_{0}^{+\infty}\frac{dt}{1+t^2-\frac{1}{2}} = \color{red}{2\pi\sqrt{2}}.$$
Remember: a substitution in a integral is allowed iff it is provided by a diffeomorphism, i.e. a regular and invertible map. If you have to deal with $\int_{0}^{2\pi}g(u)\,du$, you cannot use the substitution $v=\tan(u)$.
A: The easiest way to evaluate an integral like the one you got after 'intense' trigonometric substitutions is to use complex-analytic tools. Namely, substitute $\theta = 4x$, then use periodicity to get an integral from $0$ to $2\pi$, then write $\cos \theta$ in terms of $e^{i\theta}$, substitute $z = e^{i\theta}$, and you get an integral over the unit circle. Now use Cauchy's integral formula.
For the second one, decompose the integral as follows: $\int_0^1 + \int_1^2 + \int_2^3 + \int_3^4$.
