We get then
π ≈
Q(0, N )
12P (0, N) + 12AQ(0, N)
C
3/2
2.2 Improvements
2.2.1 Common factor reduction
The result is not modified if common factors are removed from the numerator and
the denominator. The recursion becomes:
D ← gcd(G
1
(a, c), Q
1
(c, b))
G
D
← G
1
(a, c)/D
Q
D
← Q
1
(c, b)/D
G
1
(a, b) ← G
D
G
1
(c, b)
Q
1
(a, b) ← Q
1
(a, c)Q
D
P
1
(a, b) ← P
1
(a, c)Q
D
+ P
1
(c, b)G
D
The gcd (Greatest Common Divisor) is computed by explicitly storing the
factorization of G and Q in small prime factors at every step. The factorization
is computed by using a sieve [3]. In [3] the sieve takes a memory of O(N log(N ))
which is very large. Our implementation only uses a m em ory of O(N
1/2
log(N)),
which is negligible compared to the other memory use.
As
(6n)!
(n!)
3
(3n)!
=
n
Y
k=1
24(2k − 1)(6k − 5)(6k − 1)
k
3
is an integer, it is useful to note that the final denominator Q(0, N) of the sum
divides C
3N
when all the common factors have been removed.
So the m aximum size of the final P (0, N) can easily be evaluated. Here it is
log(C)/ log(C/12) ≈ 1.22 time s the size of the final result.
2.2.2 Precomputed powers of C
3
It is not efficient to recompute the powers of C
3
/24 at every step of the recursion.
So we precompute them separately.
Another point is that the final value of Q is known to divide C
3N
. So in order
to have a bounded size result, it is interesting to precompute the powers of C
3
instead of C
3
/24. Some space is lost for the storage of G, but the overall memory
usage is s maller.
The recursion bec omes :
g
2
(n) = 24(2n − 1)(6n − 5)(6n − 1)
a
2
(n) = (−1)
n
(U + V n)
q
2
(n) = n
3
3
评论0
最新资源