Here is my solution
$\begin{align} &\int\frac1{\cos^2x(1-\tan x)^2}dx\\ &=\int\frac{\sec^2x}{(1-\tan x)^2}dx=\int\frac{du}{(1-u)^2}=\int\frac{dv}{(v)^2}\\ &=-\frac1{v}+C\\ &=-\frac1{1-u}+C\quad{(**)}\\ &=-\frac1{1-\tan x}+C\\ &=\frac1{\tan x-1}+C \end{align}$
My textbook says the answer is $\;\displaystyle\frac1{1-\tan x}+C\;.$
I get the fact that the negative sign can be omitted because of the arbitrary constant C, but how are these two answers the same? They're two different functions with different ranges.
If $1-u=v$ then $-du=dv$. You missed the minus sign.