The integral in question is as follows:
$$ \int \frac{dx}{(x^2 - 1)^2} $$
This question is in a chapter about integration by partial fractions, but I wanted to try using trigonometric substitution $$ \left\{\begin{align} x &= \sec\theta \\ dx &= \sec\theta\tan\theta \,d\theta \end{align}\right. $$ to solve it. What I did: \begin{align} \int \frac{dx}{(x^2 - 1)^2} &= \int \frac{\sec\theta\tan\theta \,d\theta}{\tan^4\theta} \\ &= \int \sec \theta \cot^3 \theta \,d\theta \\ &= \int \csc\theta \cot^2 \theta \,d\theta \\ &= \int \csc^3\theta \,d\theta - \int \csc \theta \,d\theta \\ &= -\frac{1}{2}\csc \theta \cot \theta + \frac{1}{2}\ln|\csc \theta - \cot \theta| - \ln|\csc \theta - \cot \theta| + C \\ &= -\frac{1}{2}(\csc \theta \cot \theta + \ln|\csc \theta - \cot \theta|) + C \end{align}
I drew a triangle with $ x = \sec\theta $, with a hypotenuse of length $ x $ and adjacent of length $ 1 $, so I obtained $ \csc \theta = \frac{t}{\sqrt{t^2 - 1}} $ and $ \cot \theta = \frac{1}{\sqrt{t^2 - 1}} $. After I substituted these back in, I got
$$ = -\frac{1}{2}\left(\frac{t}{\sqrt{t^2 - 1}} \frac{1}{\sqrt{t^2 - 1}} + \ln\left|\frac{t}{\sqrt{t^2 - 1}} - \frac{1}{\sqrt{t^2 - 1}}\right|\right) + C $$
$$ = -\frac{1}{2}\left(\frac{t}{t^2 - 1} + \ln\left|\frac{t-1}{\sqrt{t^2 - 1}}\right|\right) + C $$
Now, the correct answer the book gave is
$$ \frac{1}{4}\left(\ln|t + 1| - \frac{1}{t+1} - \ln|t - 1| - \frac{1}{t - 1}\right) + C $$
I was able to use partial fraction decomposition on the $ \frac{t}{t^2 - 1} $ and properties of logarithms to get the same answer as given, however, I had to add an absolute value sign under the square root in order to get the correct absolute values inside the logarithms, i.e.
$$ \ln\left|\frac{t-1}{\sqrt{t^2 - 1}}\right| $$ had to be changed to $$ \ln\left|\frac{t-1}{\sqrt{|t^2 - 1|}}\right| $$
I'm not sure why I missed this absolute value. Why did using trigonometric substitution produce an almost-correct answer, off by an absolute value sign in this case?
Integration by parts
To avoid being troubled by the convention between trigonometric functions, we can try to integrate by parts. $$ \begin{aligned} \int \frac{d x}{\left(x^2-1\right)^2}&=-\frac{1}{2} \int \frac{1}{x} d\left(1+\frac{1}{x^2-1}\right) \\ & =-\frac{1}{2}\left[\frac{x}{x^2-1}+\int \frac{1}{x^2-1} d x\right] \\ & =-\frac{1}{2}\left[\frac{x}{x^2-1}+\frac{1}{2} \ln \left|\frac{x-1}{x+1}\right|\right]+C \\ & =-\frac{x}{2\left(x^2-1\right)}+\frac{1}{4} \ln \left|\frac{x+1}{x-1}\right|+C \end{aligned} $$ Wish it helps!