The reduction formula for integration of $\cos^n x$ is:
$$ \int \cos^n x \: dx=\frac1n \cos^{n-1} x\sin x+\frac{n-1}n \int \cos^{n-2} x \: dx $$
But if $n$ is a negative integer like $-1, -2,-3,\ldots $ then can this reduction formula still be applied?
You may read the relation $$ \int \cos^n x \: dx=\frac1n \cos^{n-1} x\sin x+\frac{n-1}n \int \cos^{n-2} x \: dx \tag1 $$ in the form $$ \int \cos^{n-2} x \: dx=-\frac1{n-1} \cos^{n-1} x\sin x+\frac n{n-1} \int \cos^{n} x \: dx. \tag2 $$ Then, for negative integers like $n=-1, -2,-3,\cdots, $ by a recurrence, you will end up with considering $$ \int \cos^{-2} x \: dx \quad \text{or} \quad \int \cos^{-1} x \: dx. \tag3 $$
Two examples.
We just use $(2)$.
and