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?
Neither is correct.

It's not restrictive to assume $a&gt;0$ (for $a=0$ the antiderivative has a different form; for $a&lt;0$ change the intervals below accordingly).

The function $\frac{1}{x^2-a^2}$ is defined for $x\ne\pm a$ and is negative over $(-a,a)$, positive over $(-\infty,-a)$ and $(a,\infty)$.

The sign of $\frac{x-a}{x+a}$ is the same as the sign of $x^2-a^2$ (for $x\ne\pm a$, of course), so it's clear that
$$
\frac{1}{2a}\ln\frac{x-a}{x+a}
$$
cannot be an antiderivative over $(-a,a)$, because it is undefined there.

There's a simple way out. An antiderivative of $1/x$ is $\ln|x|$ (up to an arbitrary constant over $(-\infty,0)$ and an arbitrary constant on $(0,\infty)$, with no connection between each other).

The partial fraction decomposition is
$$
\frac{1}{x^2-a^2}=\frac{1}{2a}\frac{1}{x-a}-\frac{1}{2a}\frac{1}{x+a}
$$
so we can write
$$
\int\frac{1}{x^2-a^2}\,dx=
\frac{1}{2a}(\ln|x-a|-\ln|x+a|)=
\frac{1}{2a}\ln\left|\frac{x-a}{x+a}\right|
$$
up to arbitrary constants in the intervals $(-\infty,-a)$, $(-a,a)$ and $(a,\infty)$.

Since $1/(a^2-x^2)=-1/(x^2-a^2)$, we have
$$
\int\frac{1}{a^2-x^2}\,dx=
-\frac{1}{2a}\ln\left|\frac{x-a}{x+a}\right|=
\frac{1}{2a}\ln\left|\frac{x-a}{x+a}\right|^{-1}=
\frac{1}{2a}\ln\left|\frac{x+a}{x-a}\right|
$$
again up to constants as before.
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&gt;0$ and $J=(-a,a)$, we have

$$\int f(x)dx=\frac{1}{2a}\ln( \frac{a-x}{x+a} )+C$$