# Casio

# Improving Floating Point Precision

Programming Languages and Software Engineering

The University of Washington

Floating-point arithmetic can be surprising. Correct-looking code produce incorrect results due to Round-off error. Numerical methods can fix these problems, but they’re complex and require specialized knowledge. Floating-point code is written by scientists, engineers, and analysts who are not numerical analysis experts. They need better tools.

*Casio automatically fixes numerical precision problems.* Casio uses a heuristic search to find program transformations that improve numerical precision. It automatically discovers and applies classic numerical analysis techniques, leading to numerically precise programs without requiring any specialized knowledge from the user. Casio’s output is guaranteed to compute the same mathematical function as the original; it just computes that function more accurately.

## Status

The implementation is currently under heavy development. It succeeds on many textbook examples, and on some examples drawn from numerical libraries, scientific publications, and mathematics. Results on 28 test cases drawn from Richard Hamming’s *Numerical Methods for Scientists and Engineers* are below. In the plot, each rectangle measures the average number of correct bits for random single-precision inputs, with the left end measuring the original program, and the right end measuring Casio’s output. Wider rectangles are better. Casio improves all results, many to almost-perfect precision.

Casio will become free software once the project is published. For now, if you’d like access, please email Pavel Panchekha.

## Blog posts

- Taylor Expansions of Taylor Expansions explains how Casio takes Taylor expansions of exponential and trigonometric functions.
- Arbitrary Precision, not Arbitrary Accuracy explains why arbitrary-precision libraries aren’t a simple answer to rounding error: to use arbitrary precision, you have to choose
*how much*precision to use, and this is often difficult to determine. - Complex Square Roots in math.js describes how Casio automatically fixed an accuracy bug in math.js, an open source mathematics library.
- Floating Point Guarantees describes how rounding and primitive operators work in IEEE-754 floating point.

## Presentations

- Casio: automatically improving floating-point code
At OPLSS on 17 June 2014

- What the Float‽ And what are we planning to do about it?
Lightning talk at UW on 15 May 2014

- Casio: automatically improving floating-point code
At Dropbox on 31 March 2014