Simplify $(1+x^2 )^{1/2}-(1-x^2)^{1/2}$

138 Views Asked by At

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?

2

There are 2 best solutions below

0
On BEST ANSWER

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}$$

5
On

I will give you another possible simplification for this expression. Let $x=\sqrt{\cos 2\theta}.$ There is a such real $\theta$ for all $0\le x\le 1$ and, for other values of $x$ you can use a suitable complex $\theta$ value with some care. Then $$(1+x^2 )^{1/2}-(1-x^2)^{1/2}=\sqrt2 (\cos\theta-\sin\theta)=2\sin\left(\theta-\dfrac{\pi}{4}\right)$$ (with an appropriate branch of square root).