Exercise 2: Locating the Exact Cancellation Step in the Quadratic Formula — Possible Solution ==================================================================== THE SPECIFIC ARITHMETIC STEP THAT CAUSES THE PROBLEM ------------------------------ For a=1, b=-100000, c=1: -b = 100000, and sqrt(b^2 - 4ac) = sqrt(10,000,000,000 - 4) which is approximately 99999.99998 - a value extremely close to -b itself. The small root is computed as (-b - sqrt(disc)) / (2a), which means subtracting two numbers, 100000 and approximately 99999.99998, that agree in essentially all of their leading digits. This is exactly the cancellation pattern verified earlier in this chapter with (1+x)-1: the leading digits that match cancel out exactly, and what remains is built almost entirely from whatever rounding error already existed in the two operands, not from genuine new information. WHY THE LARGE ROOT NEVER HITS THIS PROBLEM ------------------------------ The large root is computed as (-b + sqrt(disc)) / (2a) - here, -b (100000) and sqrt(disc) (approximately 99999.99998) are ADDED, not subtracted. Adding two positive numbers of similar magnitude doesn't cancel any leading digits at all - the result (approximately 199999.99998) is simply larger than either operand, with no loss of significant digits. This is why the large root's verified relative error (about 3.4 x 10^-17) stays right at the natural precision limit of a double, while the small root's (about 3.4 x 10^-7) is nine to ten orders of magnitude worse - despite both roots coming from the identical inputs and the identical formula, just the opposite sign in the numerator. THE GENERAL PATTERN ------------------------------ Whether a given step in a computation is dangerous or safe depends specifically on whether it subtracts two same-signed, similarly-sized quantities (dangerous - digits cancel) or adds them (safe - no cancellation, only genuine growth). The quadratic formula's two branches happen to fall on opposite sides of that line for this particular set of coefficients, which is exactly why one root is essentially perfect and the other is badly degraded from the same formula. WHY THIS WORKS AS AN ANSWER ------------------------------ The explanation names the exact operands being subtracted (-b and the square root term) and the exact operands being added in the other branch, ties the outcome directly to this chapter's own cancellation-vs-addition distinction, and generalizes the pattern rather than treating the two roots' different accuracy as an unexplained coincidence.