Rewrite ${1 \over {1 + 2x}} - {{1 - x} \over {1+x}}$ to avoid loss of significance I would like to rewrite the term
$${1 \over {1 + 2x}} - {{1 - x} \over {1+x}}$$
in order to avoid a loss of significance for $x \approx 0$, meaning I would like to minimize the numerical error made when computing the fraction.
I think it might be wise to expand the left and the right term in order to write them as a single term. I receive:
$$2x^2 \over {1 + 3x + 2x^2}.$$
This doesn't look very good either, because $2x^2$ pushes $x \approx 0$ even further to $0$. I tried a polynomial division and received:
$$1 - {{3x + 1} \over {2x^2 + 3x + 1}}.$$
Now, there is at least the left term that is independent from $x$, but the right term might still cause problems. Is this already enough to avoid a loss of significance or do I need to try another step here?
 A: We have:
$$\frac{1}{1+2x} - \frac{1-x}{1+x} = \frac{(1+x)}{(1+x)(1+2x)} - \frac{(1-x)(1+2x)}{(1+x)(1+2x)} = \frac{2x^2}{1 + 3x + 2x^2}$$
which indeed is the result you arrived at. This fraction is $0$ for $x = 0$ and close to zero we can say:
$$\frac{2x^2}{1 + 3x + 2x^2} \approx \mathcal{O}(x^2)$$
as $1 + 3x + 2x^2 \approx 1$ for $x \approx 0$.
Is this what you are looking for?
Edit:
Seems to me this is the best way of approaching this problem. Let's say you want to compute the value at $x = 0.001$ and due to numerics you compute the value at $x = 0.001 + \epsilon$. Then the error will go like $\mathcal{O}(\epsilon^2)$ while we have
$\frac{1}{1+2x} = \mathcal{O}(x)$ and $\frac{1-x}{1+x} = \mathcal{O}(x)$ so you would make an error which is linear in $\epsilon$. Since $\epsilon << 1$ we have $\epsilon^2 < \epsilon$. Ofcourse this changes a bit if $\epsilon \approx x$ ie, when you want to compute values VERY close to zero. Then linear scaling in $\epsilon$ might actually be beneficial. 
A: If you want to calculate $f(x)$ for really small values close to $0$, you can use derivatives. You can calculate the derivative of $f(x)$ and multiply it by your $x$. It is a pretty good approximation.
$\dfrac{df(0)}{dx}=\dfrac{-2}{(1+2x)^2}+\dfrac{2}{(1+x)^2}=0$
So since the first derivative is zero, you can calculate the second derivative and think of it as the acceleration in a position-time diagram:
$\dfrac{d^2 f(0)}{dx^2}=\dfrac{8}{(1+2x)^3}-\dfrac{4}{(1+x)^3}=4$
So we can approximate:($a$ is the acceleration or the second derivative of the diagram)
$f(x)\approx \dfrac{1}{2}ax^2\approx \dfrac{1}{2}*4*x^2\approx 2*x^2$
A: I also think that Taylor expansion is a good idea. In fact, we can write 
$${1 \over {1 + 2x}} - {{1 - x} \over {1+x}}=\frac{2x^2}{1 + 3x + 2x^2}=2x^2 \sum_{i=1}^\infty (-1)^{n-1} \left(2^n-1\right) x^{n-1}$$ and since this an alternating series, you will stop summing terms up to $p$ as soon as $$\left(2^{p+1}-1\right) x^p \leq \epsilon$$
