I been trying to integrate $\sec^4$ , without much luck. But I don't entirely understand why my result is invalid and would like some feedback if possible.
I'm attacking the issue in the following way
$$ \int (\sec^2{x})^2dx = \int (\tan^2+1)^2dx $$
then, I put $u=\tan^2+1$ which means $x = \arctan(\sqrt{u-1})$, which allows me to do the following backwards substitution
$$ \int (\sec^2{x})^2dx = \int (\tan^2+1)^2dx = \int u^2 \frac{1}{2u\sqrt{u-1}} dx = \frac{1}{2}\int u (u-1)^{\frac{-1}{2}} dx $$
Now using integration by parts I get
$$\begin{align*} \int u (u-1)^{\frac{-1}{2}} dx &= \frac{1}{2}(2u(u-1)^{\frac{1}{2}} - \int 2(u-1)^{\frac{1}{2}})\\\\ &= \frac{1}{2}(2u(u-1)^{\frac{1}{2}}-\frac{4}{3}(u-1)^{3/2}) \\\\ &= \frac{1}{2}(2(\tan^2{x}+1)(\tan^2{x})^{\frac{1}{2}}-\frac{4}{3}(\tan^2{x})^{3/2}) \end{align*}$$
This however, seems to be incorrect. How come?
You have to be careful with solving the equations; solving the equation
$$ 1 + \tan^2 x = u $$
for $x$ in terms of $u$ actually has many possible values: they are the values
$$ \pi n \pm \arctan \sqrt{u-1} $$
where $n$ ranges over all integers.
Ultimately, we can ignore the $\pi n$ part when rewriting the integral, because $\tan(z + n \pi) = \tan(z)$ and $d(z + n \pi) = dz$, and these are the only sorts places $\pi n $ would appear in the equation. However, we mustn't forget the sign.
Rather than donig two problems separately, it is convenient to define a new varaible $s$ to be $1$ or $-1$ as appropriate, and
$$ x = \pi n + s \arctan \sqrt{u-1} $$
and $s$ can be treated as a constant (depending on what you imagine for the fine details either $s$ really is a constant or $s$ is "locally constant", but either way, $ds = 0$). In the final simplifications, observe that
$$ \tan x = s \sqrt{u - 1} $$
which lets you convert back into trig functions while still keeping the signs right. Ultimately, all the $s$'s will cancel out (because $s^2 = 1$), so we don't have to worry about it in writing the final answer.
Incidentally, in my opinion it's easier not to actually solve for $x$: we can manage the substitution just from the knowledge that
$$ \tan x = s \sqrt{u-1} $$
from which we can derive
$$ \sec^2 x \, dx = s \frac{1}{2} (u-1)^{-1/2} du $$
and, of course, the original equation you set up lets us substitute $\sec^2 x = u$.