Which integration formula for $\frac{1}{a^2-x^2}$ is correct? In my book integration formula for $\frac{1}{x^2-a^2}$ is given as $\frac{1}{2a}\ln(\frac{x-a}{x+a})$.
From the above formula we can write the formula for integration of $\frac{1}{a^2-x^2}$ as   $-\frac{1}{2a}\ln(\frac{x-a}{x+a}) = \frac{1}{2a}\ln(\frac{x+a}{x-a}) $ [as we know $\ln(\frac{1}{x})=-\ln(x)$]
But, in my book the integration of  $\frac{1}{a^2-x^2}$ is written as $\frac{1}{2a}\ln(\frac{x+a}{{a-x}}) $.
We know that the integration in the second case cannot be $\frac{1}{2a}\ln(\frac{x+a}{x-a}) $ and $\frac{1}{2a}\ln(\frac{x+a}{{a-x}}) $ at the same time. Which formula is the correct one and why?

Let $f(x)=\frac{1}{x^2-a^2}$.
$f$ is continuous at $(-\infty,-|a|),(-|a|,|a|)$ and $(|a|,+\infty)$.
in each interval
$$2af(x)=\frac{1}{x-a}-\frac{1}{x+a}$$
and $$\int f(x)dx=\frac{1}{2a}\ln(\frac{|x-a|}{|x+a|}).$$
the final expression depends on which interval $J$  we want the antiderivative.
for example, if $a>0$ and $J=(-a,a)$, we have
$$\int f(x)dx=\frac{1}{2a}\ln( \frac{a-x}{x+a} )+C$$
