1.12: Roundoff Error Example
( \newcommand{\kernel}{\mathrm{null}\,}\)
Consider solving the quadratic equation
x2+2bx−1=0
where b is a parameter. The quadratic formula yields the two solutions
x±=−b±√b2+1
Consider the solution with b>0 and x>0 (the x+solution) given by
x=−b+√b2+1
As b→∞
x=−b+√b2+1=−b+b√1+1/b2=b(√1+1/b2−1)≈b(1+12b2−1)=12b.
Now in double precision, realmin ≈2.2×10−308 and we would like x to be accurate to this value before it goes to 0 via denormal numbers. Therefore, x should be computed accurately to b≈1/(2× realmin )≈2×10307. What happens if we compute (1.1) directly? Then x=0 when b2+1=b2, or 1+1/b2=1. That is 1/b2=ϵmach /2, or b=√2/√ϵmach ≈108. For a subroutine written to compute the solution of a quadratic for a general user, this is not good enough. The way for a software designer to solve this problem is to compute the solution for x as
x=1b(1+√1+1/b2)
In this form, if 1+1/b2=1, then x=1/2b which is the correct asymptotic form.