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 ? 

$$
\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.
