<s>[INST] Simplify $(1+x^2 )^{1/2}-(1-x^2)^{1/2}$ I need to simplify the following expression in a way that introduces minimal floating point cancellation errors.
$$(1+x^2 )^{\frac{1}{2}}-(1-x^2 )^{\frac{1}{2}}$$
The errors accumulate when numbers close together are subtracted from each other. I get
$$\sqrt{2}\left[1-\left(1-x^4 \right)^{1/2} \right]^{1/2}$$
But don't see how this helps, perhaps there is a better formula?
 [/INST] I would try this:
$$\begin{align}(1+x^2 )^{\frac{1}{2}}-(1-x^2 )^{\frac{1}{2}}&=[(1+x^2 )^{\frac{1}{2}}-(1-x^2 )^{\frac{1}{2}}]\frac{(1+x^2 )^{\frac{1}{2}}+(1-x^2 )^{\frac{1}{2}}}{(1+x^2 )^{\frac{1}{2}}+(1-x^2 )^{\frac{1}{2}}}\\&=\frac{(1+x^2 )-(1-x^2 )}{(1+x^2 )^{\frac{1}{2}}+(1-x^2 )^{\frac{1}{2}}}\\&=\frac{2x^2}{(1+x^2 )^{\frac{1}{2}}+(1-x^2 )^{\frac{1}{2}}}\end{align}$$
</s>