In $\frac{1}{a^2-x^2}$, how can $a\sin(\theta)$ be substituted for $x$ when finding the anti-derivative? $$\int{\frac{1}{a^2-x^2}}dx\tag{1}$$
When finding the above anti-derivative, $x$ is substituted with $a\sin(\theta)$. However, the range of $x$ is $\mathbb{R}-\{-a,a\}$ while the range of $a\sin(\theta)$ is $[-a,a]$.
Graph of $\frac{1}{a^2-x^2}[a=0.5]$
Needless to say,
$$\mathbb{R}-\{-a,a\}\ne[-a,a]$$
So, how can $a\sin\theta$ be substituted for $x$ in $(1)$ when the range of $x$ and $a\sin\theta$ are not the same?

Related
 A: 
$$\int{\frac{1}{a^2-x^2}}dx\tag{1}$$
the range of $x$ is $\mathbb{R}-\{-a,a\}$ while the range of
$a\sin(\theta)$ is $[-a,a]$
how can $a\sin\theta$ be substituted for $x$ in $(1)$ when the range
of $x$ and $a\sin\theta$ are not the same?

On the integration domain $(-a,a)$ (let's call this interval $A$), the substitution $x=a\sin\theta$ with range $[-a,a]$ (let's call this interval $B$) is valid because $A\subseteq B.$
On the separate integration domains $(-\infty,-a)$ and $(a, \infty)$ (let's call these intervals $C$ and $D,$ respectively), the substitution $x=a\sec\theta$ with range $[-\infty,-a]\cup[a,\infty]$ (let's call this set $E$) is valid because $C\subseteq E$ and $D\subseteq E.$
(Alternatively, use the hyperbolic substitutions $x=-a\cosh\theta$ and $x=a\cosh\theta$ for integration domains $C$ and $D,$ respectively.)
But this integral is easiest found using partial fractions, without any substitution.
A: When $x\in (a, +\infty)$, you can substitute $x = a \cosh \theta$, thus
\begin{equation}
\int \frac{d x}{a^2 - x^2} = \int\frac{1}{a^2}\frac{a\sinh \theta d\theta}{1 -\cosh^2 \theta}
= -\frac{1}{a}\int\frac{d\theta}{\sinh\theta}
\end{equation}
You can then use $u = e^\theta$ or $t = \tanh\frac{\theta}{2}$.
Of course, you could decompose directly from the beginning
\begin{equation}
\frac{1}{a^2-x^2} = \frac{1}{2a}\left(\frac{1}{a-x} + \frac{1}{a+x}\right)
\end{equation}
