My textbook (Calculus by James Stewart 8th edition) uses partial fraction decomposition to derive the anti-derivative
$$\int \frac{1}{x^2 -a^2}dx = \frac{1}{2a}\ln|\frac{x-a}{x+a}| + C$$
But I'm wondering if it's possible to use trigonometric substitution as well.
I tried the following trig. substitution by letting $$x = a\sec(\theta)$$ $$dx = a\sec(\theta)\tan(\theta)d\theta$$
$$\int \frac{1}{x^2 -a^2}dx = \int \frac{1}{a^2\sec^2(\theta)-a^2} a\sec(\theta)\tan(\theta)d\theta$$
$$= \int \frac{1}{a^2\tan^2(\theta)} a\sec(\theta)\tan(\theta)d\theta$$
$$= \frac{1}{a}\int \frac{1}{\tan(\theta)} \sec(\theta)d\theta$$
$$= \frac{1}{a}\int \frac{1}{\frac{\sin(\theta)}{\cos(\theta)}} \frac{1}{\cos(\theta)}d\theta$$
$$= \frac{1}{a}\int \frac{1}{\sin(\theta)}d\theta $$
$$= \frac{1}{a}\int \csc(\theta) $$
$$= \frac{1}{a} \ln |\csc(\theta)-\cot(\theta)|+ C$$
Then using the relation established by the trig. substitution cosecant and cotangent can be written in terms of $x$.
$$\csc(\theta) = \frac{x}{\sqrt{x^2-a^2}}$$
$$\cot(\theta) = \frac{a}{\sqrt{x^2-a^2}}$$
Now plugging these in results in
$$= \frac{1}{a} \ln|\frac{x-a}{\sqrt{x^2-a^2}}| + C$$
I'm not sure how to proceed from here to get the same results as the book, or if I did something wrong along the way. Any help would be appreciated.
Use $\frac{x-a}{x+a}=\frac{1-\cos\theta}{1+\cos\theta}=\frac{(1-\cos\theta)^2}{\sin^2\theta}=(\csc\theta-\cot\theta)^2$ or $\left|\frac{x-a}{\sqrt{x^2-a^2}}\right|=\sqrt{\frac{x-a}{x+a}}$.