Contradiction between integration by partial fractions and substitution Integration by substitution:
$$\int \frac {dx}{x^2-1}$$
Let $x=\sec\theta$ and $dx=\sec\theta\tan\theta \,d\theta$
$$\int \frac {dx}{x^2-1} = \int \frac{\sec\theta\tan\theta \,d\theta}{\sec^2\theta-1} = \int \frac {\sec\theta\tan\theta\, d\theta}{\tan^2\theta} = \int \frac {\sec\theta \,d\theta}{\tan\theta} $$
$$\int \frac {\sec\theta \,d\theta}{\tan\theta} = \int \frac {\cos \theta \,d\theta}{\cos\theta \sin \theta} = \int \csc\theta\, d\theta$$
$$=\ln|\csc\theta-\cot\theta|+C$$
$$=\ln| \frac{x}{\sqrt{x^2-1}}-\frac{1}{\sqrt{x^2-1}}|+C=\ln| \frac{x-1}{\sqrt{x^2-1}}|+C$$
Which is $Undefined$ for $|x|<1$

Integration by partial fractions:
$$\int \frac {dx}{x^2-1}$$
$$\int \frac {dx}{x^2-1}= \frac 12\int\frac{dx}{x-1}- \frac12\int \frac{dx}{x+1} =  \frac12 \ln | x-1| - \frac12 \ln|x+1| +C$$
$$ =  \frac12 \ln | \frac{x-1}{x+1}|+C$$
Which is $Defined$ for $|x|<1$ and this is right because the integrand is defined for $|x|<1$
What is the problem in the substitution method ? 
 A: Let's try to clear out some of the confusion on what is going on here.
First of all, $x\mapsto \frac 1 {x^2 - 1}$ is continuous function everywhere except for $x=\pm 1$, so it is Riemann integrable on any segment not containing $\pm 1$. That said, we would very much like to find primitive function defined on $\mathbb R^2\setminus\{\pm 1\}$. Solution by partial fractions does just that, $$F_1(x) = \frac 12 \ln\left|\frac{x-1}{x+1}\right| + C$$ is defined everywhere except at $x=\pm 1$. So, if we wanted to calculate either $$I_1 = \int_{\frac 12}^{\frac 34} \frac {dx} {x^2 - 1}$$ or $$I_2 = \int_{2}^{3} \frac {dx} {x^2 - 1}$$ we can use $F_1$ with no worries.
Now, if we try to use substitution such as $x = \sec\theta$, as OP notices, we might run into some problems in the long run. The primitive function derived this way is $$ F_2(x) = \ln\left| \frac {x - 1}{\sqrt{x^2 -1}} \right| + C$$ which is defined only for $|x|>1$. Is this shocking? Well, no. As lulu points out in the comments, $|\sec\theta|\geq 1$ for any $\theta$, which is a simple consequence of the definition $\sec\theta = \frac 1 {\cos\theta}$. Thus, by substituting $x=\sec\theta$, we already gave up on $x\in\langle -1,1\rangle$, which is actually fine as long as we are trying to calculate $I_2$, but won't work for $I_1$.
So, the question is: are $F_1$ and $F_2$ both "good" solutions? More precisely, if we wanted to calculate $I_2$, can we use either of those two $F$'s?
Well, let's assume that $|x| > 1$. Then we have:
$$ \ln\left| \frac {x - 1}{\sqrt{x^2 -1}} \right| = \ln \frac {\left|x - 1\right|}{\sqrt{x^2 -1}} = \ln \frac {\sqrt{(x-1)^2}}{\sqrt{x^2 -1}} = \ln \sqrt{\frac {{(x-1)^2}}{{x^2 -1}}} = \frac 12 \ln\frac{x-1}{x+1}=\frac 12 \ln\left|\frac{x-1}{x+1}\right| $$ where the last equality holds because $x-1$ and $x+1$ have the same signs on $|x|>1$. Thus, we have shown that $F_2 = \left.F_1 \right|_{\mathbb R^2\setminus [-1,1]}$. I hope that clarifies the problem.
A: On simplifying
\begin{align}
& \ln \frac{x-1}{\sqrt{x^2-1}}=\ln\frac{\sqrt{x-1}^2}{\sqrt{(x-1)(x+1)}} \\[6pt]
= {} & \ln\frac{\sqrt{x-1}}{\sqrt{x+1}} \\[6pt]
= {} &  \frac 1 2 \ln \frac{x-1}{x+1} 
\end{align}
A: $$
\ln\frac{|x-1|}{\sqrt{|x^2-1|}} = \ln\frac{\sqrt{|x-1|}\sqrt{|x-1|}}{\sqrt{|x-1|}\sqrt{|x+1|}} = \ln\sqrt{\frac{|x-1|}{|x+1|}} = \frac 1 2 \ln\left|\frac{x-1}{x+1}\right|
$$
In response to comments I've made this more complete than it was.  Notice that


*

*I take no square roots of anything except non-negative numbers; and

*$|AB| = |A||B|$, so $|x^2-1|=|x-1||x+1|$; and

*$\sqrt{AB} =\sqrt A \sqrt B$ if $A\ge0$ and $B\ge0\vphantom{\dfrac 1 1}$, so the separation into two square roots is valid; and

*$\sqrt A/\sqrt B = \sqrt{A/B\,{}}$,  if $A\ge0$ and $B\ge0$, so the second equality is valid; and

*$|A|/|B| = |A/B|$, so the last equality is valid.


PS in response to comments: The problem with the trigonometric substitution is only that it is valid only when $|x|>1$, since $\sec\theta\ge 1$ for all values of $\theta$ and those points where $|x|=1$ are not in the domain.
