Cancellation error of $\frac{1}{z-w}$

57 Views Asked by At

I have a problem where I need to calculate $\frac{1}{z-w}$ where $z$ an $w$ are complex numbers that are very close in the euclidean norm sense. However, when I use this formula in my code, it seems to allow cancellation error in a non acceptable way that I cannot permit. Is there a way I can calculate it without loss of significance?

1

There are 1 best solutions below

1
On

Assuming $\left|\frac{w}{z}\right|<1$ (if not then change the following appropriately). $$\frac{1}{z-w}=\frac{1}{z} \, \left(\frac{1}{1-\frac{w}{z}}\right)=\frac{1}{z} \, \sum_{k=0}^{\infty}\left(\frac{w}{z}\right)^k=\frac{1}{z}+\frac{w}{z^2}+\frac{w^2}{z^3}+\dotsb$$ This way you can approximate (by choosing the number of terms in the series) the expression $\frac{1}{z-w}$ without running into the issue of diving by a very small quantity $|z-w|$. Of course, this method can run into issues if $z$ (or $w$) are very close to $0$.