liveBook · Manning

Numerical error

As explained in Geometry for Programmers

Numerical error is the discrepancy between a computed result and the exact mathematical solution.

Numerical error is the discrepancy between a computed result and the exact mathematical solution. A small stopping step or tolerance does not necessarily mean the result is equally accurate. section 3.3.2 section 8.1.1

An iterative intersection

An algorithm stops when its last step is shorter than 0.3, but the exact solution is (4⅔, 3.2) while the computed result is approximately (4.273, 3.141), giving an actual error closer to 0.4. Nearly parallel lines make the same tolerance less reliable; orthogonal lines can produce a precise answer in two iterations. section 3.3.2

Numerical error becomes especially important when:

  • Floating-point operations accumulate small inaccuracies across successive calculations. section 8.1.1
  • Larger linear systems make the straightforward solution increasingly inaccurate. section 8.1.1
  • Expression optimization is needed to improve accuracy, using tools such as Herbie alongside symbolic computation with SymPy. section 8.1.1
Figure 3.9 The difference between the last step length and the actual error gets larger as the angle gets smaller.
03-09

Shows why the gap between the final step length and actual error grows as intersecting lines become more nearly parallel. section 3.3.2

How Geometry for Programmers covers it

How deep it goes
Explains geometric causes and floating-point accumulation, but defers detailed numerical-expression optimization.
Examples
Uses line intersections, varying angles, polynomial transformation systems, floating-point operations, SymPy, and Herbie.
What you can do after
Diagnose numerical discrepancies by comparing stopping tolerance with actual error and recognizing accumulated floating-point inaccuracy.
How it connects
Connects numerical error with tolerance, iterative algorithms, floating-point operations, linear systems, polynomial transformations, SymPy, and Herbie.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Geometry for Programmers. The section links point to the parts of the book it draws on.