Bach's algorithm
Bach's algorithm[1] is a probabilistic polynomial time algorithm for generating random numbers along with their factorizations, named after its discoverer, Eric Bach. It is of interest because no algorithm is known that efficiently factors numbers, so the straightforward method, namely generating a random number and then factoring it, is impractical.
The algorithm performs, in expectation, O(log n) primality tests.
A simpler, but less efficient algorithm (performing, in expectation, primality tests), is due to Adam Kalai.[2]
Overview
Bach's algorithm produces a number uniformly at random in the range (for a given input ), along with its factorization. It does this by picking a prime number and an exponent such that , according to a certain distribution. The algorithm then recursively generates a number in the range , where , along with the factorization of . It then sets , and appends to the factorization of to produce the factorization of . This gives with logarithmic distribution over the desired range; rejection sampling is then used to get a uniform distribution.
References
- Bach, Eric (1988), "How to generate factored random numbers", SIAM Journal on Computing, 17 (2): 179–193, doi:10.1137/0217012, MR 0935336
- Kalai, Adam (2003), "Generating random factored numbers, easily", Journal of Cryptology, 16 (4): 287–289, doi:10.1007/s00145-003-0051-5, MR 2002046
Further reading
- Bach, Eric. Analytic methods in the Analysis and Design of Number-Theoretic Algorithms, MIT Press, 1984. Chapter 2, "Generation of Random Factorizations", part of which is available online here.