Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

10

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


Practical implementation of lattice
rules
10.1 Introduction
In previous chapters we have been mainly concerned with the theoretical
properties of lattice rules. Now in this chapter we turn to practical matters.
We recall that Chapter 6 gave theoretical grounds for believing that it
would be advantageous to use lattice rules of maximal rank. Chapter 7
showed that there might also be some merit in using certain lattice rules
of intermediate rank, with the relative advantage increasing progressively
with rank. To benefit from these results in a practical way, this chapter
will look at a sequence of embedded lattice rules, with the successive rules
having all ranks from 1 to s inclusive. Each rule contains all of the points
of the preceding rule, and (in the preferred situation) an equal number of
new ones. The final rule in this sequence, the one with the most lattice
points, is a maximal rank rule. The details of the explicit construction and
properties of such embedded sequences may be found in the next section.
Embedded sequences of quadrature rules open up the possibility of ob­
taining an error estimate with little extra cost. The hope is that such an
error estimate, along with the full set of approximate integrals obtained
from the sequence of embedded rules, can give valuable information about
the reliability of the final (and hopefully best) approximation in the se­
quence. This topic is taken up in Section 10.3, and a practical scheme is
put forward which makes use of the fact that the final lattice rule contains
many different embedded rules with significant numbers of points.
An alternative error estimation technique discussed here is a general­
ization of the randomization procedure described earlier in Section 4.6 for
number-theoretic rules. However, the cost of that technique is inevitably
high, as the total number of function evaluations is increased by a signifi­
cant factor.
Section 10.4 gives an algorithm allowing the calculation of all the ap­
proximations in the embedded sequence to be carried out simultaneously.
This algorithm incorporates the error estimation procedure already de­
scribed in Section 10.3.
The embedded sequences considered here require the choice of an s-
dimensional integer vector z. In Section 10.5 we shall discuss some of
the practical details of the computer searches that are required to find

Lattice Methods for Multiple Integration, I. H. Sloan and S.Joe, Oxford University Press (1994),
© I. H. Sloan and S. Joe, 1994, DOI:10.1093/oso/9780198534723.003.0010
Embedded lattice rules 165

such vectors. We have seen in Chapter 6 that each test of a particular z


vector can be carried out with many fewer function evaluations than will
be used in the final rule. Even so, as has already been indicated in Chapter
4, it is not usually feasible to search through all integer vectors. Thus

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


it is common to limit the search to vectors z of a restricted form. One
form that we have seen before (in Chapters 4 and 5) is the one-parameter
form used by Korobov (1960). In Section 10.6 we give a result showing
how searches using this form may be speeded up by omitting lattice rules
that are geometrically equivalent. The proof of this result uses elementary
number theory.

10.2 Embedded lattice rules


The embedded sequences of lattice rules that we shall consider are given
by

(fci,...,fcr,0, ...,0)
Qrf = (10.1)
n

for 0 r < s, where n and m are relatively prime, and z is an integer


vector having no nontrivial factor in common with m. It is clear that this
sequence of lattice rules is an embedded sequence, since the points of Qr
are also points of Qr+i for 0 r s — 1. It follows from Theorem 7.1
that Qr is a lattice rule having nrm points. Moreover, Qo is a rank-1 rule,
while for 1 < r < s, Qr has rank r.

Example 10.1. In Figures 10.1-10.3 we show the quadrature points for


the two-dimensional embedded sequence with parameters

s = 2, n = 2, m = 5, z = (l,2).

The points of Qi are those of Qo plus an equal number of new ones. Sim­
ilarly, the points of Q2 are those of Qi plus an equal number of new ones.
Both Qo a,nd Qi are of rank 1; they are generated by (|, |) and (^,
respectively. The rule Q2 is of rank-2, since it is the 22 copy of the rule in
the small square: it is the 22 copy of Qq! The reader might like to check
that the behaviour is quite different if the value of m is changed to 4, which
violates the condition that n and m be relatively prime.

We now show generally that, provided n and m are relatively prime, Qs


is the ns copy of the rank-1 rule Qo- Thus the embedded sequence given
in (10.1) may be viewed as a particular approach to the evaluation of the
ns copy of Qo-
Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024
Practical implementation of lattice rules

Fig. 10.2 Qi.


Fig. 10.1 Qo.

0
0
166
Embedded lattice rules 167

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


Fig. 10.3 Q2.

Proposition 10.2. If n and m are relatively prime, the lattice rule Qs


may be written as

—z -I-------------- (10-2)
nm n
k3=0 fci=0 j=0

that is, Qs is the ns copy of the rule Qq.


Proof We need to show that (10.1) (with r = s) and (10.2) are equivalent.
The right-hand side of (10.2) is, by definition, the ns copy of the rule Qq
applied to f. It is nonrepetitive by construction, and is a lattice rule of
rank s by Theorem 6.4. Now the two lattice rules given by (10.1) (with
r — s) and the right-hand side of (10.2) each have the same order nsm.
Moreover, the lattice corresponding to Qs, namely,

L = Uz + ''' ’: j, ki £ Z,
s
I m n

is clearly a subset of the lattice which corresponds to the right-hand side


of (10.2), namely,

L’ = (—z 4- ; j k. G Z i <s
I nm n
168 Practical implementation of lattice rules

Since L is a subset of L' and each lattice has the same number of points
per unit volume (namely nsm), they must coincide, from which it follows
that Qs may be expressed equivalently in the form (10.2). ■
As each successive lattice rule in the embedded sequence (10.1) has n

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


times as many points as the preceding one, we might expect the lattice
rules to get better as r increases. In terms of the quantity Pa defined in
(5.1) and (5.2) this is certainly the case.
Proposition 10.3. Let a > 1. Then the lattice rules Qr defined by (10.1)
satisfy
Pa(Qo) > Pa^Ql) > > Pa(QsY
Proof The result follows from Theorem 5.1 and the obvious inclusions

L(Qo) C L(Qi) C • • • C L(QS). (10.3)

(The inequalities are strict as the inclusions in (10.3) are strict.) ■


A key question to be decided before the embedded sequence can be used
in practice is the choice of a value of n. A strong case can be made, on
the grounds of both theory and practice, that the best value is n = 2. On
the side of theory, Theorem 6.9 establishes that there exist very good rules
that are 2s copies of rank-1 rules. In the present context this means that
if we set n = 2 then there exist very good candidates to serve as the rule
Qs that lies at the end of the sequence. On the side of practice, embedded
sequences are very attractive when the order merely doubles at each step,
instead of increasing by some higher multiple. With this choice there is
always available a comparison rule with half the number of points, which
is a large enough fraction to be useful. And in fact in the present context
the choice n = 2 makes available to us (as we shall see in the next section)
s different rules each having half the order of Qs.
Once n has been determined, the question of choosing m (aside from
the constraint that it be relatively prime with n—which means that it must
be odd if n = 2) is essentially a question of deciding how many function
evaluations one is prepared to allow. Finally, the choice of z should be such
as to make Qs as effective a rule as possible. We shall return with precise
guidance on how to choose z in Section 10.5.

10.3 Error estimation


In one-dimensional numerical integration, a common way of obtaining an
error estimate is to use two rules, say Q and Q, and to estimate the error
by the difference \Qf — Qf\, perhaps multiplied by some constant. (For a
more sophisticated development of the same idea using the concept of ‘null
rules’, see Berntsen and Espelid 1991.) Since the sequence in (10.1) is an
embedded sequence and the members Qs-i and Qs use the most points, a
Error estimation 169

natural first idea, proposed in Joe and Sloan (1992 a), is to use as an error
estimate the quantity
c\Qsf -Qs-if\, (10.4)

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


where c is some scaling constant. As will be seen in the next section, all
the members Qr, 0 r 5, of the embedded sequence may be calcu­
lated simultaneously, so that calculation of the error estimate (10.4) would
require negligible extra computation. However, numerical tests based on
the testing package of Genz (1984, 1987) indicate that the error estimate
(10.4) (with c = 2), though reasonably reliable in low dimensions, tends
to underestimate the true error as the dimension s gets larger. The prob­
lem, of course, is that it can happen only too easily that Qs-if and Qsf
have similar values, even when neither result is particularly close to the
true value. And we certainly do not have any theorem to tell us that the
convergence of the sequence Qof,..., Qsf to If is monotone, or regular in
any way.
The improved error estimate proposed here is based on the recogni­
tion that the nsm-point rule Qs contains not just one embedded rule with
ns-1m points, but s such rules, which differ from Qs-i only in the choice
of the coordinate that ‘misses out’ on being summed over. In (10.1) with
r = s — 1, the distinguished coordinate is the sth, but it may as well be any
other. We would expect a more robust error estimate to be obtained by
taking the root mean square of the error estimates from each such choice.
This estimate is like (10.1) in lacking a theoretical basis, but it is undeni­
ably safer, with the safety net improving as the dimension s increases.
In more detail, we first define for 1 i s the lattice rules

where = (Aq,..., fci-i,0, fe+i,..., ks). Thus is a lattice rule of


order n5-1m, and = Qs-i. It is apparent that the points of are
also points of Qs, so that is embedded in Qs for 1 i s.
Since Qsf is our final approximation, we can obtain s error estimates
by calculating

To combine these s error estimates into one, following Joe and Sloan (1993)
we propose the error estimate given by
s \ V2

£( qJ-Qw/)2/s) ,
( i=l ' /
(10.5)

with c a ‘fudge factor’ allowing a safety margin. In the calculations in the


next chapter, we take c = 1. Since the approximations ..., Q^f
170 Practical implementation of lattice rules

can be calculated at the same time as we calculate the embedded sequence


Qof)---)Qsf> the extra computation time required to obtain E is negligi­
ble. (Note that the 5 differences Qs — are ‘null rules’ in the sense of
Berntsen and Espelid 1991, in that they all yield zero when applied to the

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


constant function.)
The error estimate E just considered is relevant only for our special
class of lattice rules. For general lattice rules an alternative error estima­
tion strategy is to use a randomization procedure. This procedure is an
extension of the one described in Section 4.6 for number-theoretic rules.
Since the generalization is quite obvious, we shall be content to give only
an outline.
Given the lattice rule

1 N~r

j=a

in which the points xo,..., x^-i are all the points of an integration lattice
L that lie in the unit cube 17s, in the randomization procedure one uses
the shifted lattice rule

qj= iv 52 f
j=0

with c a random vector. We see from (2.22) that the error for this shifted
lattice rule is z
Qcf-If = E e2’r,hc/(h).
heL-1-

Analogous to Theorem 4.11 and its corollary, we then have the following.
Theorem 10.4. Suppose c has a multivariate uniform distribution on Cs.
Then
E(Qcf) = If,
where E(-) is the expectation operator.
Corollary For any positive integer q, let ci,... ,cq be independent ran­
dom vectors with a multivariate uniform distribution on Cs. Then the
estimate

q P=1
is an unbiased estimate of If.
Hence we can obtain an unbiased approximation to If by taking the
mean of q shifted lattice rules. As in Section 4.6, we can be (100 — 100/v2)%
Calculation of the embedded sequence simultaneously 171

‘confident’ that va is an upper bound on the true error, where in practice


a is approximated by
q
YSQcj-Qf)2

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


P=1____________
«(9 - 1)
Further details about this randomization procedure may be found in Joe
(1990a). The problem with this procedure is its high cost, in that it rests
on using the basic lattice rule q times.

10.4 Calculation of the embedded sequence simulta­


neously
Here we give an algorithm which implements the embedded sequence (10.1)
and the error estimate (10.5) (with c = 1). This algorithm is the same as
one appearing in Joe and Sloan (1993) except that a small error (affecting
only the calculation of Qof) has been corrected. The nested loops which
would normally arise from the multiple sums in (10.1) have been unravelled
in a manner similar to that used in the function SUM found in Davis
and Rabinowitz (1984, pp.488-489). The resulting looping procedure is
analogous to the operation of an odometer.
The variable cj in the algorithm labels the outermost sum in (10.1) for
which, up to the present stage, any summation index has been changed
from zero. The remaining summation indices are zero, that is, at every
stage
ku, 7^ 0, = • • • = ks = 0.
Thus we know that the current function value contributes to /,..., Qs/,
but (because k^ / 0) not to Qof,...,
comment: Variables used are:
ki, 1 <i < s : Summation variables in (10.1).
Xi, 1 i s : x = (a?i,... ,xs).
Zi, 1 i s : The vector z = (zi,... ,zs) in (10.1).
n : The parameter of this name in (10.1).
Qi, : Eventually contains Qif.
val
n
: Loop counters.
CJ : Described above, 0 < cj < s.
Q^\ 1 < i < s : Eventually contains Q^f.
E : Eventually contains the error estimate given by (10.5).
Firstly, we initialize some variables.
endcomment
172 Practical implementation of lattice rules

Qo = 0.0
for i = 1 to s step 1 do:
ki = 0
Qi = 0.0

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


QO) = o.O
endfor
fci = -1
t= 1
cu = 0
comment:
Main body of algorithm follows,
endcomment
while t s do:
if kt < n — 1 then do:
kt = kt + 1
1=1
val — 0.0
for j‘ = 0 to m — 1 step 1 do:
for i = 1 to s step 1 do:
(j i A j i
Xi = —Zi 4---- mod 1
\m n)
endfor
val = val 4- /(x)
endfor
for i = a> to s step 1 do:
Qi = Qi 4- val
endfor
for i = 1 to s step 1 do:
if ki = 0 then do:
Q(0 = Q(‘) + val
endif
endfor
if l<j = 0 then do:
(V = 1
endif
else do:
kt = 0
£=£+1
if w < t then do:

endif
endif
endwhile
Searches for a good embedded sequence 173

for i = 0 to s step 1 do:


Qi = Qi/^m)
endfor
E = 0.0

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


for i = 1 to s step 1 do:
Q(i) = Q(O/(n«-lTO)

E = E + (QS -Q«)2
endfor
E^y/Ejs

10.5 Searches for a good embedded sequence


Once we have chosen n (in practice usually 2 as indicated earlier) and m
(which must be relatively prime to n, and so must be odd if n = 2), all
that remains is to make a choice of the integer vector z.
Now recall that our criterion for measuring the ‘goodness’ of a lattice
rule is the quantity Pa, a > 1. If the lattice rule Q has the corresponding
lattice L, then we recall from (5.1) that
P“(Q) = h^x (hih2---hs)a'

it is an upper bound on the quadrature error for functions whose Fourier


coefficients f satisfy

|/(h)| , h G Z 4.

In practice, Pa(Q) is calculated by using (see (5.2))


s
Pa(Q) = Ql[FaM-i,
fc=l

where
p27ri/ia;

For convenience, we give from (4.14) to (4.16) the expressions for F2Ce),
F^x), and F$(x) when x 6 [0,1]:
Fz(x) = 1 4-2tt2(x2 - x 4-1/6),

F4(x) = 1 4- (1 - 30x2(l - x)2) ,


2tt6
F6(x) = 1 + —(1 - 21x2 4- 105x4 - 126x5 4- 42x6).
945
Since our approximation to If will be given by Qsf, we naturally want
Qs to be as accurate as possible. We saw from the results of Disney and
174 Practical implementation of lattice rules

Sloan (1992) in Chapter 6 that there exists a z which is good in the sense
that it produces a small value of Pa(Qs) when used in a 2s copy rule. How­
ever, the proof was nonconstructive. Thus in practice computer searches
are required to find a suitable z.

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


A great advantage of using Pa(Qs) as the criterion in a computer search
is that although the rule Qs is of order nsm, Lemma 6.5 shows that

Pa(QS) = Qofa^ ~ 1,

where
^n)W = f[FW(a;fc), (10.6)
k=l
with
1 p2irihx -j
=i+—y — = i + —(Fa(x) -1).
/i/0 1 1
Thus Pa(Qs) may be calculated by using Qo, a rule with only m lattice
points.
We remark that since

F^(x) = F^(l-x), (10.7)

the number of terms in the sum for Pa(Qs) can approximately be halved
by writing

where the asterisk indicates that the term with j = [m/2j is to be halved
in the event that m is even.
Practical considerations lead us to limit practical computer searches to
vectors z of a restricted form. Here we recommend the Korobov form given
in (4.32), namely,

z(^) = (1, £, mod m,..., F-1 mod m), 1 I |m/2j • (10.8)

Thus there are now only |_m/2j choices of z to search through.


Once we have an integer vector z that minimizes Pa(Qs), we may wish
to permute the components of z in the manner suggested by Joe and Sloan
(1992a). Such a permutation will not affect Pa(Qs) or the error estimate
E given in (10.5). However, a permutation might be desirable in the hope
of making the later estimates in the sequence Qof,..., Qs-if (which use
the most function evaluations) as accurate as possible.
The permutation procedure is as follows. Suppose we have done a
computer search and found an integer vector z that minimizes Pa(Qs). We
Reducing the number of vectors z searched 175

now note that some permutations of the components of z affect Pa(Qr)‘


from (7.6) to (7.9) and (10.1) we see that Pa(Qr) for 1 r s — 1 is
unaffected by a permutation that affects only the first r components or the
last s — r components, but generally is affected by permutations that mix

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


these two sets.
For this reason, instead of using z, we may choose to use

Z = (Zii

where (zi,...,is) is a permutation of (1,..., s) determined as follows: first,


choose is out of the s possible choices so that Fa(Qs_i) is minimized;
then choose is-i out of the remaining s — 1 choices so that Pa(Qs-2)
is minimized; and so on until we come to 22 which is chosen from the two
remaining possibilities by minimizing Fa(Qi). This permutation procedure
requires a total of ($($ + 1) - 2)/2 calculations of Pa(Qr) for 0 < r < s
and a given z. This is often a small number compared to the number of
calculations of Pa(Qs) required to find the original vector z. We would, of
course, use the result of Theorem 7.3, which allows Pa(Qr), 1 r < s — 1,
to be calculated using a lattice rule with only m points instead of the usual
nrm points. In this case the computation time required for the calculation
of each Pa(Qr) is essentially independent of r.
Tables of such z for s = 2,..., 12 obtained by using the search proce­
dure of this section together with the permutation option may be found in
Appendix A.

10.6 Reducing the number of vectors z searched


We recall from the last section that if we were to restrict our computer
searches to vectors z of the Korobov form (10.8), then there would be
|_m/2j such vectors to search through. In this section, we show that it is
possible to further reduce the number of vectors to be searched, with the
number being approximately halved in the best possible case (that is, when
m is prime). As has already been mentioned, Pa(Qs) is just the quadrature
error obtained by applying the rank-1 rule Qo to the function Now it
is clear from (10.6) and (10.7) that fa ' is unaffected by a permutation of
its variables, or by a reflection in one or more mid-planes, or a combination
of these. Thus two geometrically equivalent rank-1 rules would yield the
same value of Pa(Qs)- •
This leads to the main result of this section, which states that if €i and £2
are integers satisfying €1^2 = ±1 (mod m), then the rank-1 rules generated
from the Korobov vectors z(4) and z(^) are geometrically equivalent.
Theorem 10.5. Let £1 and £2, 1 £1^2 |_m/2j, m 2, be integers
satisfying
£±£2 = ±1 (modm), (10.9)
176 Practical implementation of lattice rules

and let f be a function defined on Rs which is one-periodic in each of its s


variables. Then the rank-1 lattice rules

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


and
rg/({><}) i-n)

are geometrically equivalent.


Before giving the proof of Theorem 10.5, we need some elementary re­
sults from number theory. The simple proofs are included for completeness.
For any two integers u and v, we denote the greatest common divisor of u
and v by gcd(u,u).
Lemma 10.6. Suppose £1^2 = ±1 (modm) with 2. Then
(i) gcd(^i,m) = 1, that is, and m are relatively prime.
(ii) gcd(£j,m) = 1 for any integer k 1.

Proof The assumption in the lemma implies that there is an integer k


such that ^1^2 — km = ±1. Since any common divisor of and m must
therefore divide ±1, we see immediately that the greatest common divisor
of £1 and m must be 1. Part (ii) is a consequence of the first result, since
any prime number that divides and m must also divide £1 (by the unique
factorization theorem), and so must divide gcd(^i,m) = 1. ■

Lemma 10.7. Let and £2, 1 -^1,^2 [m/2j, m 2, be integers


satisfying £1^2 = ±1 (modm). Also, let := {j E Z : 0 Q' m - 1}.
Then for j G the mapping r] Zm, given by

7?(j) = m0d m>

is a one-to-one mapping.

Proof Suppose the contrary. Then there exist Ji, J2 € Zm, ji / 72, such
that 7/(ji) = 77(72), that is, (modm). It then follows that

(7
*1 - 7*2) ^r1 = 0 (mod (10.12)

Since 1 |ji — 721 m — 1, and ^-1 / 0, it follows that for (10.12) to be


satisfied, we must have gcd(^-1,m) > 1, contradicting part (ii) of Lemma
10.6. Thus the result holds by contradiction. ■
Armed with these results, we can now give the proof of Theorem 10.5.
Reducing the number of vectors z searched 177

Proof of Theorem 10.5 Recall that = {j € Z : 0 j m - 1}.


Then for j € Zm, the jth quadrature point of the quadrature rule (10.10)
is given by {jz(£i)/m}. This point has fcth component for
1 < k < s, where {z} denotes the fractional part of x. Now the reflection

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


of this component in the mid-plane perpendicular to the fcth axis is given
by
1 - 0^1 11= {~j^i 1/m} if j 0,
while if j = 0 the component is left unchanged. Thus one way to prove
that (10.10) and (10.11) are geometrically equivalent rules is to prove that
for each j e there exists a one-to-one mapping rj: Zm —> such that,
for 1 fc s, there is a component of {^(J)z(^2)/^} which is equal to
either or {-j^-1/7n}.
We now show that this can be done by taking

= mod m,
which, we recall from Lemma 10.7, is a one-to-one mapping. In particular,
we shall prove that the (s — fc + l)th component of {^(j)z(£2)/^} satisfies
the required condition, that is, we shall prove that

either {(j^-1 mod m) (10.13)


or {(j^i-1 mod m)£s2~k/m} = /m}. (10.14)

Because ^£2 = ±1 (mod m), it follows that £2 = (um ± l)/£i for some
integer u. We then have, for any j e Zm,

r1 J

Now it follows from the binomial theorem that (um±l)s~k = wn+(±l)s"fc


for some integer v. Thus
m°d ^2~k/m} = {^i-1 (vm + (±l)s-fc) /m}
= {(il)5-^"1 /m},

which yields either (10.13) or (10.14) depending on the parity of s — k. This


completes the proof. ■
In a search through vectors of the Korobov form for the one that mini­
mizes Pa(Qs), Theorem 10.5 shows that we do not normally have to search
through all the possible |_?tl/2J choices. It follows from Niven and Zucker­
man (1980, Theorem 2.13) that the equation £v = 1 (modm) has a solu­
tion if and only if gcd(^, m) = 1. Moreover, if this condition is satisfied then
178 Practical implementation of lattice rules

there exists one and only one solution v* belonging to Zm. Further, under
the same condition gcd(£,m) = 1 the equation £v = — 1 (modm) also has
a unique solution, modulo m, given by m — v*. Since exactly one of v* and
m — v* is in the interval from 1 to |_m/2j (unless they are both equal to

Downloaded from https://academic.oup.com/book/54960/chapter/422771366 by OUP-USA Mirror user on 01 May 2024


[m/2_|), we conclude that if £i, 1 |_m/2j, is relatively prime to m,
then there exists a unique £2, 1 £2 Lm/2j, such that (10.9) holds, with
one or other sign.
We are interested in the cases when £1 / £2. So for a given value
of m, let be the number of such pairs and £2, £1 / £2, such that
£i£2 = ±l(modm) and 1 £1, £2 [m/2_|. Then there are only =
[m/2j — Um choices of z(£) to search through rather than the original
[m/2j. In general, for given m, the value of is not known a priori.
However, if m is a prime number, then gcd(£, m) = 1 for all £ satisfying
1 ^ £ ^ \m/2\. Hence, in this case (10.9) always has a solution £2 satisfying
1 £2 |_m/2], and since £2 = £1 occurs not more than twice (see Niven
and Zuckerman 1980, Corollary 2.28), the number of possible choices of
z(£) is approximately halved.
We now describe a simple algorithm which allows us to make use of
Theorem 10.5 and the ensuing discussion. The idea is that before the
actual computer search is started, we find and store (in an array) the
values of £ for which a calculation of Pa(Qs) using z(£) is required. Let
this array be A, with array elements Aj. To compute the array, set A± = 1,
A2 = 2, and initialize the integer j to be 3. Suppose at the current value
of j, the array A already contains elements (with £2 = 2). Then for
2 k tj-i, we test whether Akj = ±1 (modm). If we find any such k,
we set tj = tj-\. Otherwise, we set tj = tj_i 4-1 and Atj = j. The integer
j is then incremented by 1. This process is then continued until j reaches
|_m/2j + 1, at which stage we have — A-
Timing tests for this simple-minded algorithm given in Joe (19906) in­
dicate that it is quite effective. Suggestions for some other algorithms that
are more efficient (but also more complicated) may also be found in Joe
(19906).

You might also like