Loading [MathJax]/jax/output/HTML-CSS/jax.js
Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Mathematics LibreTexts

1.12: Roundoff Error Example

( \newcommand{\kernel}{\mathrm{null}\,}\)

Consider solving the quadratic equation

x2+2bx1=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+b1+1/b2=b(1+1/b21)b(1+12b21)=12b.

Now in double precision, realmin 2.2×10308 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 b1/(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.


This page titled 1.12: Roundoff Error Example is shared under a CC BY 3.0 license and was authored, remixed, and/or curated by Jeffrey R. Chasnov via source content that was edited to the style and standards of the LibreTexts platform.

  • Was this article helpful?

Support Center

How can we help?