0

The condition number for the sum of two numbers $a$ and $b$ is $K=\frac{|a|+|b|}{|a+b|}$. But if I have $a=10$ and $b=-10$, I know that their difference is exactly $0$, so I have in practice no error, but the condition number is infinity. Why is is so? I am surely missing something really important here

  • Check out the concept of "catastrophic cancellation". If $a$ and $b$ are floating point numbers, they represent some small interval around their values. The relative error for the sum of points in these intervals can be arbitrarily bad, in that sense $K=\infty$ makes sense. – Lutz Lehmann Mar 14 '22 at 11:37
  • The catch is that you do not know the numbers $a$ and $b$ exactly. This is the point of numerical calculus. – Peter Mar 14 '22 at 12:04
  • I'm sorry but I keep not understanding: in this particular case, if $a$ and $b$ are represented exactly in machine precision, they difference is exactly $0$, and the condition number should not be $\infty$, right? – bobinthebox Mar 14 '22 at 12:31
  • @LutzLehmann I'm still trying to think about this. So basically that expression for $K$ is referring to the only case where $a$ and $b$ are floating point numbers? – bobinthebox Mar 14 '22 at 16:06
  • Yes, it refers to situations where you have approximately a continuum of inputs. Integer arithmetic is discrete and largely exact, excluding overflow. – Lutz Lehmann Mar 14 '22 at 16:57
  • Ok, but then if I have $a=2$ and $b=-2$, and they are exact also in machine precision, as you just said, isn't a contradiction the fact that $K=\infty$? – bobinthebox Mar 14 '22 at 17:27
  • No, because you are assuming $a = 2$ and $b=-2$ exactly. What condition numbers do is estimate how error grows in a calculation. If you have no error, you have no condition number. But if $2$ is only known to be an approximation of the actual number $a$ and $-2$ is only known to be an approximation of the actual number $b$, then suddenly you do have condition numbers and summing $a$ and $b$ can make that error become infinitely large. – Paul Sinclair Mar 15 '22 at 02:33
  • It is possible that this answer https://math.stackexchange.com/a/3181535/307944 will help. – Carl Christian Mar 15 '22 at 14:10

0 Answers0