We study the worst-case behavior of three iterative algorithms for computing the Jacobi symbol ( v u ) . Each algorithm is similar in format to the Euclidean algorithm for computing gcd( u, v ). Eisenstein's algorithm chooses an even quotient at each step. It is shown that the worst case occurs when u = 2 n + 1, v = 2 n − 1. Lebesgue's algorithm is essentially the least-remainder Euclidean algorithm with powers of 2 removed at each step. Its worst case occurs when u = 2 L n − L n − 1 , v = L n , where L 0 = 1, L 1 = 1, and L n = 2 L n − 1 + L n − 2 for n ≥ 2. The “ordinary” Jacobi symbol algorithm is essentially the ordinary Euclidean algorithm with powers of 2 removed at each step. It is the most interesting mathematically of the three. We prove that if the ordinary algorithm on input ( u , v ) performs n division steps, with u > v >0 and u + v as small as possible, then u = A n and v = A n − 1 , where A 0 = 1, A 1 = 3, A 2 n = A 2 n − 1 + 2 A 2 n − 2 for n ≥ 1, and A 2 n +1 = 2 A 2 n + A 2 n − 1 for n ≥ 1. We also discuss the worst-case inputs to the ordinary algorithm under the lexicographic and reverse lexicographic orderings.
Read full abstract