I have been given this example 2.0013−2.0005=0.0008. The destructive cancellation is the large common value, here the 2, that disappears.
2 Answers
$$ \begin{align} 2.314890251 - 2.314890254 & = -0.000000003 \\[8pt] 2.314890251 - 2.314890253 & = -0.000000002 \end{align} $$ One of these is $3\times\text{something}$ and the other is $2\times\text{something}$, where "something" is the same in both cases. For some purposes the ratio of $3$ to $2$ might be the information you're looking for. It might be important that it's not $3$ to $1$.
So round the numbers above: $$ \begin{align} 2.315 - 2.315 & = 0 \\[8pt] 2.315 - 2.315 & = 0 \end{align} $$ All of the information you're looking for has been lost.
A book called Numerical Methods that Work has an example of a geometric problem in an engineering application in which a number is sought that is known to be a solution to a quadratic equation. One of the two is close to $0$, and the other is large. The one close to $0$ is needed. So look at $$ \frac{-b\pm\sqrt{b^2-4ac}}{2a} $$ The solution with "$+$" rather than "$-$" is needed, and that gets lost as seen above. The practical solution is: Start with $0$ as the first approximation. Put the $n$th approximation in place of $x$ in the quadratic term but not the linear term. The solution to the resulting first-degree equation is the $(n+1)$th approximation.
-
What you describe is simple loss of precision due to rounding. Destructive cancellation is equally present in both of your scenarios. – TonyK Aug 10 '14 at 22:02
-
1@TonyK : So it is, and that it what I was trying to exemplify. – Michael Hardy Aug 10 '14 at 22:04
Suppose $x$ and $y$ are known to five significant figures: $x \approx 2.0013$ and $y \approx 2.0005$. This means that $2.00125 \le x \le 2.00135$ and $2.00045 \le y \le 2.00055$ (some of the $\le$ signs can be replaced by $<$ signs, but exactly which ones depends on the rounding mode used).
But then if $z = x - y$, all we can confidently say about $z$ is that $0.0007 \le z \le 0.0009$, so $z$ is not even known to $1$ significant figure.
Destructive cancellation is this catastrophic loss of significant figures that can occur when subtracting two almost equal floating-point numbers.
- 64,559
-
Firstly is there a specific amount of significant figures that has to be lost for a situation to be considered as Destructive cancellation. Also wouldn't $z=0.0008$ which is to 1 significant figure. – Jed Aug 10 '14 at 21:43
-
For $z$ to be known to $1$ significant figure, we would need $0.00075 \le z \le 0.00085$. As for your first sentence $-$ I am not aware of any standard criteria for what constitutes destructive cancellation. – TonyK Aug 10 '14 at 21:58