<s>[INST] Prove that $\tan^{-1}\frac{\sqrt{1+x^2}+\sqrt{1-x^2}}{\sqrt{1+x^2}-\sqrt{1-x^2}}=\frac{\pi}{4}+\frac 12 \cos^{-1}x^2$ Let the above expression be equal to $\phi$
$$\frac{\tan \phi +1}{\tan \phi-1}=\sqrt{\frac{1+x^2}{1-x^2}}$$
$$\frac{1+\tan^2\phi +2\tan \phi}{1+\tan^2 \phi-2\tan \phi}=\frac{1+x^2}{1-x^2}$$
$$\frac{1+\tan^2\phi}{2\tan \phi }=\frac{1}{x^2}$$
$$\sin 2\phi=x^2$$
$$\phi=\frac{\pi}{4}-\frac 12 \cos^{-1}x^2$$
Where am I going wrong?
 [/INST] Domain of $\tan^{-1}\frac{\sqrt{1+x^2}+\sqrt{1-x^2}}{\sqrt{1+x^2}-\sqrt{1-x^2}}$ is $x \in (-1,1]$, nothing wrong with that.
But range of the above term(argument of $\arctan$) is $(1,\infty)$  so this means, when you assume it be $\phi$, it is restricted to the interval $\left[ \frac{\pi}{4},\frac{\pi}{2}\right]$
This creates a problem  in the last line, because $\sin^{-1}(x^2)$ should be in its principal range and  $\frac{\pi}{2}\le 2\phi \le \pi$
Edit: to find the domain of the argument, the easiest way, divide both sides by $\sqrt{1+x^2}$ and then substitute $x^2=\cos(2\theta)$, $\theta \in \left(0,\frac{\pi}{4}\right)$, to get
$$\frac{1+\sqrt{\frac{1-\cos 2 \theta}{1+\cos 2 \theta}}}{1-\sqrt{\frac{1-\cos 2 \theta}{1+\cos 2 \theta}}}$$
and then use the identity, $\tan \theta=\sqrt{\frac{1-\cos 2 \theta}{1+\cos 2 \theta}}$
$$\frac{1+\tan \theta}{1-\tan \theta}=\tan \left(\frac{\pi}{4}+ \theta\right)$$
Now, $\theta \in \left(0,\frac{\pi}{4}\right)$ so, $\tan \left(\frac{\pi}{4}+\theta\right) \in [1, \infty)$
Which is ironically your question...
</s>