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?
 A: A bit late answer but I thought worth mentioning it.
First note that we can substitute $y=x^2$ and consider $0<y\leq 1$. Furthermore, the argument of $\arctan$ can be simplified as follows:
$$\frac{\sqrt{1+y}+\sqrt{1-y}}{\sqrt{1+y}-\sqrt{1-y}}=\frac{1+\sqrt{1-y^2}}{y}$$
Now, setting $y = \cos t$ for $t \in \left[0,\frac{\pi}2\right)$, to show is only
$$\arctan \frac{1+\sin t}{\cos t} = \frac{\pi}{4}+\frac t2$$
At this point half-angle formulas come into mind:
$$\frac{1+\sin t}{\cos t} = \frac{(\cos \frac t2 + \sin \frac t2)^2}{\cos^2 \frac t2 - \sin^2 \frac t2} = \frac{\cos \frac t2 + \sin \frac t2}{\cos \frac t2 - \sin \frac t2}$$ $$ = \frac{1+\tan \frac t2}{1-\tan \frac t2} = \tan\left(\frac{\pi}{4}+\frac t2\right)$$.
Done.
A: Because for $x\neq0$ and $-1\leq x\leq1$ easy to see that:
$$0<\frac{\pi}{4}+\frac 12 \cos^{-1}x^2<\frac{\pi}{2}$$ and we obtain: $$\tan\left(\frac{\pi}{4}+\frac 12 \cos^{-1}x^2\right)=\frac{1+\tan\frac{1}{2}\arccos{x^2}}{1-\tan\frac{1}{2}\arccos{x^2}}=$$
$$=\frac{\cos\frac{1}{2}\arccos{x^2}+\sin\frac{1}{2}\arccos{x^2}}{\cos\frac{1}{2}\arccos{x^2}-\sin\frac{1}{2}\arccos{x^2}}=\frac{\sqrt{\frac{1+x^2}{2}}+\sqrt{\frac{1-x^2}{2}}}{\sqrt{\frac{1+x^2}{2}}-\sqrt{\frac{1-x^2}{2}}}=\frac{\sqrt{1+x^2}+\sqrt{1-x^2}}{\sqrt{1+x^2}-\sqrt{1-x^2}}.$$
Your mistake in the last line.
Indeed, since $$\frac{\sqrt{1+x^2}+\sqrt{1-x^2}}{\sqrt{1+x^2}-\sqrt{1-x^2}}>1$$
and from here $$\frac{\pi}{4}<\phi<\frac{\pi}{2},$$ we obtain:
$$2\phi=\pi-\arcsin{x^2}=\frac{\pi}{2}+\arccos{x^2}.$$
A: 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...
A: Your mistake
$\sin y=a\stackrel{\text{to}}{\longrightarrow}\sin^{-1}(\sin y)=\begin{cases}2n\pi+y&y\in\text{I, IV quadrant}\\(2n-1)\pi-y&y\in\text{II, III quadrant}\end{cases}=\sin^{-1}a$
