Rewriting of division

99 Views Asked by At

I've got a division of the sort

$$\frac{a}{a+b}$$

which is for some reason rewritten as $$\frac{1}{1+\frac{b}{a}}$$ for numerical stability. But why would this be more stable and how do they rewrite the first formula into the second one?

2

There are 2 best solutions below

0
On

$$\frac a{a+b}=\frac a{a+b}\cdot \dfrac {\frac 1a}{\frac 1a}=\frac 1{1+\frac ba}$$ I don't see any reason the two forms should differ in numerical stability. The usual problem is subtraction of two nearly equal quantities, so here if $a \approx -b$ you have a problem. The division of the numerator and denominator by $a$ does not change that because then $\frac ba \approx -1$.

0
On

If this is eventually implemented in computer code, there could be limits to the values of intermediate results which make one more stable than the other, depending on the values of $a$ and $b$.