Affine arithmetic (AA) is a model for self-validated numerical analysis.
In AA, the quantities of interest are represented as affine combinations (affine forms) of certain primitive variables, which stand for sources of uncertainty in the data or approximations made during the computation.
Affine arithmetic is meant to be an improvement on interval arithmetic (IA), and is similar to generalized interval arithmetic, first-order Taylor arithmetic, the center-slope model, and ellipsoid calculus — in the sense that it is an automatic method to derive first-order guaranteed approximations to general formulas.
Affine arithmetic is potentially useful in every numeric problem where one needs guaranteed enclosures to smooth functions, such as solving systems of non-linear equations, analyzing dynamical systems, integrating functions, differential equations, etc.
Applications include ray tracing, plotting curves, intersecting implicit and parametric surfaces, error analysis (mathematics), process control, worst-case analysis of electric circuits, and more.
In affine arithmetic, each input or computed quantity x is represented by a formula
are symbolic variables whose values are only known to lie in the range [-1,+1].
Thus, for example, a quantity X which is known to lie in the range [3,7] can be represented by the affine form
implies that the corresponding quantities X, Y are partially dependent, in the sense that their joint range is smaller than the Cartesian product of their separate ranges.
Affine forms can be combined with the standard arithmetic operations or elementary functions, to obtain guaranteed approximations to formulas.
In that case, one should take a suitable affine function G that approximates F to first order, in the ranges implied by
jointly provide a guaranteed enclosure for the point (X,Y,...,Z), which is often much smaller than the Cartesian product of the ranges of the individual forms.
Systematic use of this method allows arbitrary computations on given quantities to be replaced by equivalent computations on their affine forms, while preserving first-order correlations between the input and output and guaranteeing the complete enclosure of the joint range.
One simply replaces each arithmetic operation or elementary function call in the formula by a call to the corresponding AA library routine.
For smooth functions, the approximation errors made at each step are proportional to the square h2 of the width h of the input intervals.
In order to provide guaranteed enclosure, affine arithmetic operations must account for the roundoff errors in the computation of the resulting coefficients
in a specific direction, because any such rounding would falsify the dependencies between affine forms that share the symbol
The handling of roundoff errors increases the code complexity and execution time of AA operations.
The affine forms for those quantities can be represented by a single coefficient matrix A and a vector b, where element
Each step of AA usually entails adding one more row and one more column to the matrix A.
This operation can be done without destroying the first-order approximation property of the final zonotope.
This approach is reasonably adequate when the set of quantities to be computed is small and known in advance.
In this approach, the programmer must maintain externally the correspondence between the row indices and the quantities of interest.
Global variables hold the number m of affine forms (rows) computed so far, and the number n of symbols (columns) used so far; these are automatically updated at each AA operation.
Alternatively, each affine form can be implemented as a separate vector of coefficients.
This approach is more convenient for programming, especially when there are calls to library procedures that may use AA internally.
The AA code then looks much closer to the original formula.
A global variable holds the number n of symbols used so far.
In this situation, the matrix and vector implementations are too wasteful of time and space.
This representation makes the AA operations somewhat more complicated; however, the cost of each operation becomes proportional to the number of nonzero terms appearing in the operands, instead of the number of total symbols used so far.