1. Introduction The problem of error free computations has been investigated by many authors in the recent past. A natural well-known approach to this problem is based on the use of infinite precision integer and rational arithmetics [ll]. However, this kind of arithmetics is always very space- and time-consuming. A significant alternative that lies between this infinite precision approach and the floating point arithmetic, is the approximate rational arithmetic that assures low complexity operations together with powerful capabilities. In the papers by Horn [lo] and Matula and Kornerup [14] in fact the method used to approximate a real number is based on the algorithm for finding successive convergents (i.e., rational numbers) of the continued fraction expansion of the given number. This method is very well known the antiquity [7], and, since an approximate value of the rational p/q is accurate to within l/q’, it gives similar accuracy as from a double precision arithmetic. Another very interesting approximate rational arithmetic is based on the use of the so-called p-adic arithmetic, first introduced by Hensel [9]. This approach has been followed by Krishnamurthy, Rao and Subramanian [13] and by Hehner and Horspool [S]. The first three authors defined a particular kind of p-adic representation with fixed 0020-0190/84/$3.00
0 1984, Elsevier Science Publishers
length numbers, that they call Hensel-codes. Subsequently Gregory [3,4,5] studied this finite segment p-adic arithmetic and proposed two algorithms for direct and inverse transformations of rational numbers into their corresponding Hensel-codes. However, these algorithms are not very general (i.e., the value of the number p, in the p-adic system, is fixed once and for all in every computation) and rather inefficient (i.e., a table look-up method is used). The main goal of this paper is to present new algorithms for the direct and inverse mappings. We shall recognize the relationship between this p-adic approach and the approximation method based on continued fraction expansion of rational numbers. The study of this relationship will then provide us with a natural and efficient method for computing the homomorphic images of Henselcodes. Then the two new algorithms for direct and inverse transformations will strengthen the p-adic approach for a computationally significant approximate rational arithmetic. In fact, it will now be possible to define efficient algorithms for all the p-adic arithmetic operations, also allowing to change easily the value of p from one computation to another. The new algorithms solve some of the open problems in p-adic approximate arithmetics and therefore they will encourage further research to also succeed the overflow problem. We now can say that the overflow appears at
B.V. (North-Holland)
167
Volume
18, Number
3
INFORMATION
PROCESSING
the end of the computation when the inverse mapping can generate an answer which is not the true one. However, the obtained value and the true one belong to the same residue class. At the same time the basic algebraic background, common to all the approaches that we have mentioned here, will be evident together with the natural similarity between numbers and polynomials. Moreover, this similarity suggests also to investigate the relationship of this approximation method for numbers with the polynomial approximation of functions (described in [2,6,15.16]).
2. p-adic arithmetic The p-adic number arithmetic was first introduced by Hensel [9] and it has been studied by many authors from several points of view (see. for instance, [12]). Let (Y be a rational number, and let p be an integer, that usually is assumed to be prime. The number 01 can be represented by the sequence of digits