This is an old revision of the document!
SmartFloat: Numerical Error Estimator
SmartFloat is a numerical data type library for sound floating-point computations in Scala. The library can perform sound computations with ranges of floating-point numbers and estimate the roundoff errors commited.
For example:
def cubeRoot = { val a: AffineFloat = 10 var xn = AffineFloat(1.6) for(i <- 1 until 5) { xn = xn * ((xn*xn*xn + 2.0*a)/(2.0*xn*xn*xn + a)) } println(xn.toStringWithAbsErrors) println(xn.interval) }
will compute the cube root of 10 by Halley's method and provide an upper bound on the absolute floating-point roundoff error committed on the final result:
2.1544 (1.3346e-15) [2.1544346900318816,2.154434690031885]
You can download the source code and try it out. The only dependency is a small native library that you need to compile for your own platform, but for Linux and Mac this works without issues.
There is also a poster and a presentation available.
Publications
The library is mainly described in the following paper:
E. Darulova, V. Kuncak. Trustworthy Numerical Computation in Scala. OOPSLA 2011. PDF
The SmartFloat library is maintained by Eva Darulova.