# Check if the problem is well condtioned

I'm trying to check if the problem of calculating the sum of two numbers a and b is well conditioned, provided that |a| > 2|b|. In my solution i split it into cases:

1: a>0 and b>0,then
f(a,b)=a+b>3b
C(a,b)=Ca(a,b)+Cb(a,b)
where Ca(a,b)=|a(1)/(a+b)| and Cb(a,b)=|a(1)/(a+b)| then
C=|(a+b)/(a+b)|=1 so in this case problem is well conditioned

2: a>0 and b<0,then
f(a,b)=a+b<b
C(a,b)=Ca(a,b)+Cb(a,b)
where Ca(a,b)=|a(1)/(a+b)| and Cb(a,b)=|a(1)/(a+b)| then
C=|(a+b)/(a+b)|=1 so in this case problem is well conditioned


so it turns out that for each case it will be the same, but i have doubts that this is correct solution

• What do you mean by "if the problem of calculating the sum of two numbers $a, b$ is well conditioned"? – jordan_glen Jan 20 at 23:31
• @jordan_glen The question is whether or not the sum is sensitive to small changes in the operands. This is a serious issue when we are dealing with approximations rather than the exact values of $a$ and $b$. – Carl Christian Jan 22 at 9:31

The condition number of adding two real numbers $$a$$ and $$b$$ is $$\kappa(a,b) = \frac{|a|+|b|}{|a+b|}.$$ It follows that the problem is ill-conditioned when $$a+b \approx 0$$. Now if $$|a| \ge 2|b|$$ or if $$|b| \ge 2|a|$$, then $$\kappa(a,b) \leq 3.$$ It follows that the problem is well conditioned when the absolute value of one number is as least twice as large as the absolute value of the other. The proof is an exercise in applying the triangle inequality. Now, suppose $$|a| \ge 2|b|$$. Then $$|a+b| = |a-(-b)| \ge ||a|-|b|| \ge |a|-|b| \ge |a| - \frac{1}{2}|a| = \frac{1}{2}|a|.$$ Moreover, $$|a| + |b| \leq |a| + \frac{1}{2}|a| = \frac{3}{2}|a|.$$ It follows that $$\kappa(a,b) \leq \frac{\frac{3}{2}|a|}{\frac{1}{2}|a|} = 3.$$ The case of $$|b| \ge |a|$$ follows immediately from the fact that $$\kappa(a,b) = \kappa(b,a).$$ Deriving this condition number rigorously from first principles is good subject for a follow-up question. One half of the proof is given in this answer which deals with the equivalent case of subtraction. Proving equality requires slightly more work.