# Affine Arithmetic

## by Cassio • 2011/10/03 • Research

In my previous post, I talked about interval arithmetic, a simple and popular formalism for handling interval data. We saw how interval arithmetic’s simplicity has a downside, namely the error explosion that happens as a consequence of ignoring dependencies between variables.

Affine arithmetic was proposed as an alternative, and it explicitly accounts for dependencies between variables, because it represents intervals as *affine forms.* Here’s the generic form for an interval , corresponding to some quantity x:

As we see, the affine form is a linear combination. The first term, , is the central coefficient. The remaining terms are of the form . Each such term represents one source of noise, or uncertainty, that we know about x. In those terms, the are real coefficients, and the $\epsilon_i$ are called *noise symbols*, and can be either 1 or -1. This means the range of an affine form is .

In the simplest case, then, one could represent a interval as an affine form with a single noise symbol: . In fact, this is how one converts between affine forms and intervals.

Things become more interesting, however, when we note that all the noise symbols can be shared by multiple affine forms. In other words, a symbol such as, say, is *the same * in all affine forms that contain it, and has the same value when they are evaluated. All those forms have some source of uncertainty in common, and the shared noise symbol is the way affine arithmetic represents that relation. Those forms are no longer independent, and their dependencies are explicitly handled through the sharing of noise symbols.

For an example of how this is useful, consider two affine forms, and . Using the formula for ranges above, we know that the value of x is in the interval [13, 27], and the range of y is the interval [2, 14]. So if we were to plot the point (x, y) on a plane, it could be anywhere in the rectangle delimited by the above values (light gray in the picture below). But we know that x and y have two sources of uncertainty each, and that some of their uncertainty is explained by the same source (corresponding to ). The shared noise symbol allows us to estimate their joint range, or the area in which the point (x, y) can lie, more precisely, as the darker polygon in the figure below.

Affine arithmetic provides operations on affine forms as well. These can be of two kinds: affine operations, which are linear combinations of its inputs, and non-affine operations. The first kind includes addition, subtraction, negation, multiplication by scalars and combinations of those. The generic formula for linear combinations of two affine forms is:

where are real numbers. Obviously, setting appropriate values for one or more of those gives us the elementary operations of addition (), subtraction () and so forth.

All affine operations are computed by specializations of the above formula, so they introduce no error during their computation. Also, elementary arithmetic axioms are respected, so the results look natural. For instance, it’s easy to see how x-x will be zero. Affine operations are also commutative, transitive, etc.

Unfortunately, not all useful operations are affine ones. Non-affine operations such as multiplication, division, logarithms and others are less straightforward, and will be presented in the next article in this series.