HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Program transformations for numeric stability

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
transformationsnumericstabilityprogramfor

Problem

There's tons of research on program transformations for optimization. Is there any research on transformations that improve numeric stability? Examples of such transformations might include:

  • Transform $\log(\exp(a)+\exp(b))$ into $\max(a,b)+\log(\exp(a-\max(a,b))+\exp(b-\max(a,b)))$



  • Convert multiplication of an inverse matrix times a vector into the solution to a linear system solver.



  • Automatically perform multiplications of small numbers in the log domain.



All the tricks I'm aware of for better numeric stability like this are pretty standard and something that every "good" numeric programmer always does. Since the tricks are so standard and always applied, it makes sense that the compiler might be able to do them for us.

Solution

There actually is some research on improving the numerical stability of floating point expressions, the Herbie project. Herbie is a tool to automatically improve the accuracy of floating point expressions. It's not quite comprehensive, but it will find a lot of accuracy improving transformations automatically.

Cheers,

Alex Sanchez-Stern

Context

StackExchange Computer Science Q#44263, answer score: 8

Revisions (0)

No revisions yet.