Linfini
Linfini
Nicolas Brisebarre
LaMUSE, Université J. Monnet
23, rue du Dr P. Michelon, 42023 St-Étienne Cedex 02
and Projet Arénaire, LIP, 46 allée d’Italie, 69364 Lyon Cedex 07, France
[email protected]
Sylvain Chevillard
LIP (CNRS/ENS Lyon/INRIA/Univ. Lyon 1),
Projet Arénaire, 46 allée d’Italie, 69364 Lyon Cedex 07, France
[email protected]
In the sequel, we’ll have to deal with the fol- Remark 2.3 In practice, the result of Babai’s al-
lowing algorithmic problem.
gorithm is of better quality and given faster than
Problem 2.2 Closest vector problem (CVP) Let expected.
|| · || be a norm on R . Given a basis of a lat- For a practical exact CVP, see [12] in which the
tice L ⊂ Q of rank k, k ≤ , and x ∈ R , find given algorithm is super-exponential. This com-
y ∈ L s.t. ||x − y|| = dist(x, L), where dist(x, L) plexity has been recently improved in [10].
denotes min{||x − y||, y ∈ L}.
Associated approximation problem: find y ∈ L
s.t. ||x − y|| ≤ γ dist(x, L) where γ ∈ R is fixed. 3. Our approach
Let us recall some of the complexity results In many applications, scientist and engineers
known about this problem1. In 1981, van Emde desire to find the best (or very good) polynomial
Boas [23] proved that CVP is NP-hard (see also approximation among those that have FP coeffi-
[16]). On the other hand, Goldreich and Gold- cients and this is the problem we address in that
wasser showed (but their proof is nonconstructive) paper. First, let us make the following important
1 A presentation of different algorithms for solving the CVP 2 As it is noted in [18], it seems that the CVP problem when
• ∀i ∈ {0, · · · , n + 1}, |f (yi ) − p(yi )| = f − we may think that the quality of v is quite
p∞ , good: return v.
• ∀i ∈ {0, · · · , n}, f (yi+1 ) − p(yi+1 ) = 3. Else, denote by wopt one w such that
−(f (yi ) − p(yi )).
||w − y||∞ is minimal.
Another possible choice are the Chebyshev points
[7, Chap. 2]. They are known to be good choices in Set v := wopt and goto 1.
some approximation problems (for example, they
are the starting points in Remez’ algorithm). They 4. Examples
proved to be a pretty valuable choice in the experi-
ments we made, especially when the size of the mi
We will now present two examples that illus-
is low.
trate the behavior of our algorithm in real situa-
tions. Our first example shows the possible ben-
3.2. Solving of the CVP∞ efit that may come from the use of our method
in the implementation of a function for the Intel
Kannan’s algorithm [12] makes it possible to Itanium. The second example well illustrates the
solve either CVP2 or CVP∞ but its complexity is gap between an (almost) optimal polynomial and
super-exponential. Since the euclidean and infinity the rounded minimax. This example comes from
norms have the same order of magnitude √ (remem- the implementation of the function arcsin in the
ber that, in R , || · ||∞ ≤ || · ||2 ≤ || · ||∞ ), library CRlibm [21].
we preferred to use Babai’s algorithm that solves To implement our method, we have used Maple
CVP2 with, in theory, an exponential approxima- and GP3 . Maple lets us compute the minimax
tion factor but whose performance, in time, space polynomial R (Remez’ algorithm is available in
and quality of the result, is directly related to LLL’s Maple with the function minimax of the pack-
one, hence very good in practice for n, say, not age numapprox) which is used to determine the
greater than 50. points xi by solving the equation R(x) = f (x).
We may then consider the approximation of Then, we use GP to compute a LLL-reduced basis
CVP2 provided by Babai’s algorithm as the ap- and to solve the approximated CVP2 by Babai’s
proximation of CVP∞ searched. But we can also nearest-plane algorithm. We thus get a polyno-
refine that result in the following way. We can mial P and we finally use Maple to compute ||P −
use the LLL-reduced basis to explore the neighbor- f ||[a,b] (with Maple’s numapprox[infnorm])
hood of the computed approximated CVP2 . Let’s and compare it to ||R − f ||[a,b] .
denote by v the vector given by Babai’s nearest Applying our method to an Itanium imple-
plane algorithm and denote by (ε0 , · · · , εn ) the mentation of a function
LLL-reduced basis. LLL gives pretty short vectors The Intel Itanium processor uses a particular
in the lattice: for small values of n (say up to 50), FP format called extended double: it is a FP
ε0 is often the shortest nonzero vector in the lattice format with a 64 bit mantissa. An extended
(in norm || · ||2 ) and the other vectors of√the basis double allows more accurate computations, but
are also short. Since || · ||∞ ≤ || · ||2 ≤ || · ||∞ this gain in accuracy has a cost: extended
in R , they are also pretty short vectors for || · ||∞ . doubles must be loaded in cache one after the
If v is not the exact CVP∞ , it is maybe not so far 3 GP is an interactive calculator for number theory al-
from it: the exact CVP∞ is probably of the form gorithms. In particular, it implements LLL algorithm.
v + a0 ε0 + · · · + an εn where the ai are rational It is distibuted under GPL at http://pari.math.
integers with small absolute value. We can thus u-bordeaux.fr/
other, whereas two regular doubles may be ficients given a target accuracy. This can be also
loaded at the same time. Moreover, the latency very interesting in hardware applications where
of such an operation is 6 cycles (when a multipli- each single bit may count.
cation costs 4 cycles). Thus the loading time is Another possibility offered by our method is
quite critical in such a processor and it is very in- to improve the accuracy provided by the poly-
teresting to replace an extended double with nomial approximation (compared to the rounded
a double when the accuracy doesn’t require it. minimax for example) while keeping the same pre-
See [6] and [11] for more information about the cision for the coefficients. Our second example
Itanium architecture. comes from the implementation of the function
Intel developed and included in the glibc a arcsin in CRlibm. CRlibm is a mathematical li-
mathematical library optimized for the Itanium. brary which provides correct rounding: the value
Let us consider an example inspired by the imple- returned by CRlibm when evaluating a function is
mentation of the function erf in this library.
x The the exact mathematical value rounded to the near-
2 2 est double. To achieve this goal, the develop-
function erf is defined by erf(x) = √ e−t dt
π 0 ers of CRlibm must use a bigger precision than
for all x ∈ R. The domain is cut into several the standard double precision provided by the pro-
intervals where the function can be approximated cessor. They use some special formats such as
by polynomials with reasonable degree (say less double-double and triple-double which are un-
than 30). This example deals with erf on the in- evaluated sums of two or three regular doubles.
terval [1; 2]. The goal is to provide a polynomial, In particular, they approximate functions by poly-
with extended and/or regular double co- nomials with double-double and triple-double
efficients, which approximates the function with a coefficients (and also regular doubles).
relative error bounded by 2−64 . The domain is Basically, a double-double gives the same
first translated to the interval [0, 1]. The problem precision as a FP number with 106 bits man-
is thus reduced to the following: find a polyno- tissa. However, a number of the form
mial p(x) = a0 + a1 x + · · · + an xn such that 1.x1 x2 . . . x52 000000001y1y2 . . . y52 · 2e is repre-
||p(x) − erf(x + 1)||rel,[0,1] < 2−64 . sentable by the double-double (1.x1 x2 . . . x52 ·
The minimax of degree 18 gives an error of 2e + 1.y1 y2 . . . y52 · 2e−8−53 ) and is not repre-
2−61.19 . A fortiori, a polynomial of degree 18 sentable in a 106 bits format. This limitation is not
with FP coefficients can’t provide the required ac- a problem in general: we can often prove a priori
curacy. The minimax of degree 19 gives an error that to achieve a given precision, the coefficients
of 2−66.92 . Can we find a satisfying polynomial of of a polynomial are so constrained that the 53 first
degree 19 ? bits are fixed. Thus, one of the two doubles of
A common strategy consists, when 0 belongs the double-double is known and we are back to
to the definition interval, in using a bigger preci- the problem of searching a regular double (that
sion for the first coefficients and a smaller preci- is a FP number with at most 53 bits). At worst, we
sion for the last ones. Setting the first 8 coeffi- can’t prove that the first 53 bits are fixed and we
cients to be extended doubles and the other just search for numbers with 106 bits: the resulting
to be doubles, and rounding each coefficient of number is representable with a double-double (it
the minimax to the nearest in the corresponding may just be nonoptimal).
format, we obtain an error of 2−61.13 : it is not suf- We focus here on the approximation of arcsin
ficient. However, using 9 extended doubles on the interval [0.79; 1]. It is a real-life example
and using the same classical procedure, we obtain we worked on with C. Lauter (who is one of the
an error of 2−64.74 which is enough. developers of CRlibm). After an argument reduc-
When we use our method, we obtain a poly- tion we obtain the problem to approximate
nomial with an error of 2−64.74 and only two
extended doubles. We saved 7 extended arcsin(1 − (z + m)) − π
2
g(z) =
doubles thanks to our method. The computing 2 · (z + m)
time is the time necessary to Maple for computing
minimax approximation since the other steps are where −0.110 z 0.110 and m 0.110.
instantaneously performed. The developers know from previous computations
Second example: an example from CRlibm that they need an accuracy of more than 119 bits
The first example showed that our method to achieve correct rounding. The minimax of
makes it possible to reduce the size of the coef- degree 21 provides this accuracy (see Figure 1).
Figure 1. binary logarithm of the ab-
solute error of several approximants
Target -119
Minimax -119.83 Figure 2. Absolute error between g
Rounded minimax -103.31 and our polynomial
Our polynomial -119.77
1e-36
8e-37
p0 + p1 x + p2 x2 +
· · · + p9 x9
-6e-37
This loss can be seen very well if the absolute er- 4e-32
rors are plotted: Theorem 3.2 indicates that a poly-
3e-32
nomial is optimal if and only if the absolute error
oscillates n + 2 times between its extrema. Our 2e-32
5. Conclusion