Continuing their work on parametrised safe numerics in Scala, Veronica and Jan now have an implementation of intervals parameterized on the type for the endpoints. This type is required to have numeric operations in 2 versions: for rounding up and for rounding down. These operations can then be used to define interval extensions of numeric operations that are safe, in the sense that they enclose the result.
Consider the example of addition of intervals [a,b] + [c,d] = [a+c,b+d] when a,b,c and d belong to a type A in which the sum of two values is not necessarily in A. To make the resulting operation safe we need to use a lower bound plusL(a,c) on a+c and an upper bound plusU(b,d) on b+d as the endpoints of the result. Making this a special case of a generic scheme we define plus[Interval[A]]([a,b],[c,d]) as [plusL[A](a,c),plus[A]U(b,d)].
Veronica and Jan have tested the scheme with BigDecimal as an instance of the the type of endpoints. The size of the mantissa can be provided as an argument to the instance. Coming work will focus on a) adding to the set of operations supported by the BigDecimal instance, b) completing the numeric operations for intervals (trigonometric functions) and c) implementing a validated IVP solver using Taylor expansions and intervals of constructive reals.