Hallgren s Quantum Algorithm for Pell s Equation Pradeep Sarvepalli pradeep@cs.tamu.edu Department of Computer Science, Texas A&M University Quantum Algorithm for Pell s Equation p. /6
Outline Pell s equation Classical method for solving Pell s equation Reformulating the Pell s equation in number theoretic terms Overview of Hallgren s quantum algorithm Hallgren s algorithm Algebraic background Quantum period finding algorithm Classical post processing Putting all the pieces together Quantum Algorithm for Pell s Equation p. 2/6
Outline - cont d Applications Class group of a quadratic field Principal ideal problem Generalizations Unit group of a finite extension of Q Class group of a finite extension of Q Principal ideal problem References "Notes on Hallgren s efficient quantum algorithm for solving Pell s equation" by Richard Jozsa "Polynomial time quantum algorithms for Pell s equation and principal ideal problem" by Sean Hallgren Quantum Algorithm for Pell s Equation p. 3/6
Pell s Equation Goal is to find finding integral and positive solutions to the following equation x 2 dy 2 = x 2 2y 2 =, Solutions (3, 2); (7, 2);... Has infinite number of solutions Harder than factoring Quantum Algorithm for Pell s Equation p. 4/6
Classical Method for Pell s equation Based on continued fractions Approximations of the continued fraction of d give the solution Example x 2 2y 2 =, 2 = + 2 + 2+ 2+ 2 + 2 = 3 2 = x y Observe that 3 2 2 2 2 = 9 8 = Quantum Algorithm for Pell s Equation p. 5/6
Continued Fraction Method Why does this work? Is every approximation a solution? What is the complexity of the algorithm? Quantum Algorithm for Pell s Equation p. 6/6
Continued Fraction Method - cont d Example - cont d 2 + 2 + = + 2 5 = 7 5 = x y 2 2 + 2 + = + 2 + 2 2+ 5 2 = + 5 2 = 7 2 = x y 7 2 2 5 2 = 49 5 = 7 2 2 2 2 = 289 288 = Quantum Algorithm for Pell s Equation p. 7/6
Continued Fraction Method - cont d Not every approximation gives a solution to the Pell s equation We might have to take many terms in the continued fraction before we get the solution Typically if we use the input size as log d, size of the solution will be O( d) O(e log d ) Quantum Algorithm for Pell s Equation p. 8/6
A Close Look at the Solutions Every solution can be uniquely identified with x + y d, x,y > Smallest solution with x + y d is called the Fundamental solution x + y d Every other solution can be obtained as power of the fundamental solution x + y d = (x + y d) n It suffices to compute the fundamental solution Quantum Algorithm for Pell s Equation p. 9/6
A Closer Look at the Solutions d 9 3 649 29 98 53 66249 6 7663949 9 58767986249 8 2469645423824858 277 5957379898475849 397 8387278645884649 49 25529772739242798649 42 3879474459492687946827676449 x Quantum Algorithm for Pell s Equation p. /6
Regulator O(x + y d) = O(e d ) Just to write down the solution will take exponential amount of write operations We will rather compute a representation of the solution Regulator R d = ln(x + y d), and x + y d is the smallest in magnitude of all solutions R d being irrational is computed to n digit accuracy Even for this reduced problem the best classical algorithm has a running time O(e log d poly(n)) Quantum Algorithm for Pell s Equation p. /6
Overview of Hallgren s Algorithm Reformulate the Pell s equation as a period finding problem Form a function h(x) with period R d Modify the quantum period finding algorithm to find irrational period The quantum part of the algorithm Computes only the integral part of R d Perform classical post processing given the integral part of R d Compute the fractional part of R d making use of the integral part of R d provided by the previous step Quantum Algorithm for Pell s Equation p. 2/6
Some Algebraic Number Theory Let Q( d) = {a + b d a,b Q} The solutions of Pell s equation are elements in Q( d) O is called the ring of algebraic integers O = {a Q( d) f(a) =,f(x) Z[x]} Z[x] consists of polynomials with integral coefficients Units of O are elements in O that they have multiplicative inverses O = { Units of O} = {u O u exists } Quantum Algorithm for Pell s Equation p. 3/6
Algebraic Number Theory - cont d x + y d is a solution of x 2 dy 2 = if and only if x + y d is a unit of O ǫ o smallest unit in O, with ǫ o > O = {±ǫ k o k Z} R d = lnǫ o All the solutions of x 2 dy 2 can be obtained from the fundamental unit ǫ o Quantum Algorithm for Pell s Equation p. 4/6
Algebraic Number Theory - cont d Product of sets A,B Q( d), then A B = { n i= a i b i n >,a i A,b i B} Ideal I Q( d) such that I O = I Integral Ideal I O Fractional Ideal I Q( d) Principal Ideal I = γo If ǫ O, then ǫo = O Equality of ideals αo = βo if and only if α = βǫ, where ǫ is a unit in O Quantum Algorithm for Pell s Equation p. 5/6
Reformulating Pell s equation Let P = {γo γ Q( d)} Consider g : R P g(x) = e x O = I x g(x) is periodic with R d g(x + kr d ) = e x+kr d O, = e x ǫ k oo = e x O = g(x) Quantum Algorithm for Pell s Equation p. 6/6
Using a periodic function to find R d Naive algorithm to compute R d Find g(x) = I x Find y > x such that g(y) = I x y x = kr d Another naive algorithm Assume that the ideals could be ordered somehow Given I x find g (I x ) Find an ideal I y next to I x such that I y = I x g (I y ) g (I x ) = kr d Quantum Algorithm for Pell s Equation p. 7/6
Problems with the Naive Algorithms y > e R d is exponentially large in log d I x is an infinite set, comparing two ideals poses problem There are infinitely many ideals between x,x + δ for which I x = I x+δ, Q( d) and P are both dense We need to somehow order the ideals We need to move from one ideal to another Finite precision arithmetic Quantum Algorithm for Pell s Equation p. 8/6
More Algebraic Number Theory O is a Z-module, so it behaves like a vector space O = m + n D + { D d, d mod 4,D = 2 4d, d 2, 3 mod 4, O = Z + D + D 2 Z For any principal ideal I = γo I = γz + γ D + D 2 Z Quantum Algorithm for Pell s Equation p. 9/6
Comparing Principal Ideals The basis is not unique, we can rewrite I as ( I = k az + b + ) D Z 2 a < b a, a > D D a < b D, a < D Presentation of an ideal is the triplet (a,b,k) which is computable in polynomial time given γ. Addresses the problem of comparing infinite sets. Equality of ideals is equivalent to having the same presentation Quantum Algorithm for Pell s Equation p. 2/6
Discretizing Ideals Reduced principal ideals have the form I = Z + b + D 2 Reduced principal ideals are finite in number Addresses the problem of density of sets Q( d) and P Cycle of Reduced Principal Ideals Z J = {O = J,J,...,J m } Quantum Algorithm for Pell s Equation p. 2/6
Moving Among Ideals I = Z + γz, then define ρ(i) = γ I Gives another principal ideal If I J then ρ(i) J If repeated then finally it gives a reduced principal ideal If I was reduced principal ideal ρ(i)is another reduced principal ideal Since there are a finite number of reduced principal ideals it cycles Quantum Algorithm for Pell s Equation p. 22/6
Moving Among Ideals - cont d σ(i) : d d Inverse operation of moving back is given by ρ = σρσ This addresses the problem of moving between the ideals back and forth Quantum Algorithm for Pell s Equation p. 23/6
Ordering Ideals Let I y = γi x. Then the distance between I y and I x is δ(i x,i y ) = lnγ Distance from O: δ(e x O) = δ(o,e x O) = lne x = x Distance allows us to order the ideals along the number line in the same form as the input x Addresses the problems of invertibility and ordering If I x = I y, then δ(i x,i y ) = y x = kr d δ(i, ρ(i)) can be computed in polynomial time Quantum Algorithm for Pell s Equation p. 24/6
Spacing of Ideals δ(j i,j i+ ) 3 32D δ(j i,j i+2 ) ln 2 δ(j i,j i+ ) 2 ln D If we succesively apply ρ to a non reduced ideal I, until we just get a reduced principal ideal I red, then and I red {J k,j k,j k+ } δ(i,i red ) ln D Quantum Algorithm for Pell s Equation p. 25/6
Jumping Across Ideals We note that the ideals are exponential in number so moving across efficiently requires more than use of reduction operator ρ Use the product of ideals to move faster than ρ I I 2 is much farther from O than either of I,I 2 δ(i I 2 ) = δ(i ) + δ(i 2 ) Product of ideals is not necessarily reduced so we reduce it to bring it back to the principal cycle of reduced ideals We denote this operation by Quantum Algorithm for Pell s Equation p. 26/6
Review We need positive, intgeral solutions for x 2 dy 2 = Each solution can be encoded as x + y d an element in Q( d) All solutions can be obtained from the smallest solution x + y d We introduced the Regulator R d = ln(x + y d) Quantum Algorithm for Pell s Equation p. 27/6
Review - cont d Every solution is an element of Q( d) More specifically every solution is also an element of the ring of algebraic integers in Q( d) A solution of Pell s equation is precisely the set elements in O which have multiplicative inverses Our goal is to compute the generator of this subgroup which is precisely the regulator R d Quantum Algorithm for Pell s Equation p. 28/6
Review - cont d Quadratic Number Field Solutions Pell s Eqn Quantum Algorithm for Pell s Equation p. 29/6
Review - cont d Quadratic Number Field Algebraic Integes, O Solutions Pell s Eqn Quantum Algorithm for Pell s Equation p. 3/6
Review - cont d Quadratic Number Field Algebraic Integes, O Solutions Pell s Eqn Unit group of O Quantum Algorithm for Pell s Equation p. 3/6
Review - cont d Quadratic Number Field Algebraic Integes, O Solutions Pell s Eqn Unit group of O Quantum Algorithm for Pell s Equation p. 32/6
Review - cont d We then defined the ideals as special sets in Q( d) which are loosely speaking closed under addition and multiplication A special type of ideals are the principal ideals which take the form I = γo We defined a periodic function that is periodic with R d from R to the set of principal reduced ideals They can all be ordered with respect to their distance from O We can move among the ideals using ρ and ρ We have a means of moving from one ideal to another exponentially large steps Quantum Algorithm for Pell s Equation p. 33/6
Review - cont d Quadratic Number Field Algebraic Integes, O Principal Ideals Ideals closed under +,x Reduced Principal Ideals Quantum Algorithm for Pell s Equation p. 34/6
Review - cont d Quadratic Number Field Algebraic Integes, O Principal Ideals Ideals closed under +,x Reduced Principal Ideals I ρ(ι) ρ (Ι) Quantum Algorithm for Pell s Equation p. 35/6
Hallgren s Periodic Function q 2 /N NR J J2 O O=J =J J J2 J (O,x) (O,,x2) (O,x) (J,x3) h(x) = (g(x),x δ(g(x))) = (I x,x δ(i x )) I x is the nearest reduced principal ideal to the left of x i.e, δ(i x ) < x h(x) is periodic with R d h(x) is one to one Quantum Algorithm for Pell s Equation p. 36/6
Hallgren s Periodic Function 2 3 NR X J J J2 J Principal Ideals I_x δ(ι) h(x)=(i,,δ(ι)) h(x) = (g(x),x δ(g(x))) = (I x,x δ(i x )) Quantum Algorithm for Pell s Equation p. 37/6
Discretizing h(x) For practical implementation we would like to discretize h(x) Assuming that x is discretized with a step of /N the discretized function h N (k) = h(k/n) N h N (k) is weakly periodic with P = NR d h N (k + lnr d ) = h N (k) or h N (k + lnr d ) = h N (k) Quantum Algorithm for Pell s Equation p. 38/6
Hallgren s Periodic Function 2 3 NR X J J J2 J Principal Ideals I_x δ(ι) h(x)=(i,,δ(ι)) After discretization h(x) is weakly periodic not periodic Quantum Algorithm for Pell s Equation p. 39/6
Quantum Period Finding Algorithms A state in superposition Transformation to a state with a suitable function Partial measurement Fourier transform to get rid of offset Measurement Classical post processing Quantum Algorithm for Pell s Equation p. 4/6
Hallgren s Period Finding Algorithm Form is an uniform superpostion of q states where q = pnr d + r ψ = q q j= j Compute h N ( ψ ) q 2 /N NR J J2 O O=J =J J J2 J Quantum Algorithm for Pell s Equation p. 4/6
Superposition h N ψ = q q j= j h N (j) q 2 /N NR J J2 O O=J =J J J2 J (O,x) (O,,x2) (O,x) (J,x3) Quantum Algorithm for Pell s Equation p. 42/6
Partial Measurement h() h() h(2) h(3) h() h() h(2) h(3) h() h() h(2) h(3) h() h() h(2) h(3) h() h() h N ψ = NR d q j= ( p l= j + [lnr d ] ) h N (j) Measure the second register, say we measure h N (k) h() h() h(2) h(3) h() h() h(2) h(3) h() h() h(2) h(3) h() h() h(2) h(3) h() h() h(2) h(2) h(2) h(2) Quantum Algorithm for Pell s Equation p. 43/6
Partial Measurement - cont d After Measurement First Register (2) Second Register (2+NR) (2+2NR) (2+3NR) h(2) h(2) h(2) h(2) On measurement the state will collapse to ψ = p p n= k + [nnr d ] h N (k) Quantum Algorithm for Pell s Equation p. 44/6
QFT to Remove Offset Take the Quantum Fourier transform F ψ = = p pq q j= n= a j j q j= e 2πi(k+[nNR d]) j, Register after Quantum Fourier Transform Assumes q=pnr Probability /p=nr/q q/nr 2q/NR 3q/NR 4q/NR 5q/NR Quantum Algorithm for Pell s Equation p. 45/6
QFT - cont d Register after Quantum Fourier Transform Assumes q=nr Probability /p=nr/q q/nr 2q/NR 3q/NR 4q/NR 5q/NR Assumes q=nr+r Probability Prob(lq/NR) < /p q/nr 2q/NR 3q/NR 4q/NR 5q/NR Quantum Algorithm for Pell s Equation p. 46/6
Identifying Periodicity Register after Quantum Fourier Transform Assumes q=nr+r Probability Prob(lq/NR) < /p q/nr 2q/NR 3q/NR 4q/NR 5q/NR We are interested in j = lq/nr j is small, more precisely, j < Prob(j) must be large q log NR d Quantum Algorithm for Pell s Equation p. 47/6
Identifying Periodicity - cont d For sufficiently large q 3(NR d ) 2, many j such that j is a multiple of q/nr d j < q log NR d Probability of such j is highly likely, α a constant Prob(j) > α log NR d, Quantum Algorithm for Pell s Equation p. 48/6
Extracting Periodicity But how do we extract the periodicity from the state? Measure and repeat to get another measurement such that c = [kq/nr d ] d = [lq/nr d ] We do not know k,l,r d Compute the convergents of c d c d a b < 2b 2 Quantum Algorithm for Pell s Equation p. 49/6
Extracting Periodicity - cont d Compute the convergents of c/d then for some n c = [ kq NR d ] = kq NR d Estimate the period as k l = c n d n and k = c n, NR d = [ kq c ] Check if NR d = c n q/c satisfies lr d NR d < Quantum Algorithm for Pell s Equation p. 5/6
Extracting Periodicity - cont d NR 2 NR NR NR+ NR+2 4 ρ (Ο) 3 ρ (Ο) 2 ρ (Ο) ρ (Ο) Ο ρ(ο) 2 ρ (Ο) 3 ρ (Ο) 4 ρ (Ο) If NR d jr d <, then h(nr d ) is an ideal among {ρ 4 (O),ρ 3 (O),...,O,...,ρ 3 (O),ρ 4 (O)} Because δ(i,ρ 2 (I)) > ln 2 >.693 Quantum Algorithm for Pell s Equation p. 5/6
Integral Part of R d Integral part of R d R d = NRd N We know R d to a precision /N With probability / poly(log NR d ) this algorithm will return NR d such that NR d NR d < Quantum Algorithm for Pell s Equation p. 52/6
Computing the Fractional part of R d Given R d Compute h( R d ) = (I x,x δ(i x )) NR 2 NR NR 4 ρ (Ο) 3 ρ (Ο) 2 ρ (Ο) ρ (Ο) Ο >.693 >.693 We know that δ(i,ρ 2 (I)) > ln 2 =.693 Quantum Algorithm for Pell s Equation p. 53/6
Computing the Fractional part of R d - c NR 2 NR NR 4 ρ (Ο) 3 ρ (Ο) 2 ρ (Ο) ρ (Ο) Ο >.693 >.693 Therefore δ(i,ρ 4 (I)) > 2 ln 2 > R d This implies that O must be one of the ideals {ρ 3 (O),ρ 2 (O),ρ (O), O} δ(i, O)) can be computed in polynomial and this gives the fractional part of R d Quantum Algorithm for Pell s Equation p. 54/6
Summary of the Algorithm Start with a superpostion of inputs Compute Hallgren s periodic fucntion for all these inputs Perform partial measurement Perform QFT to get rid of offset Perform a measurement to get c Repeat to get another value d Extract the Integral part of R d Compute the fractional part of R d Quantum Algorithm for Pell s Equation p. 55/6
Applications Principal Ideal Problem Given an ideal determine if it is a principal ideal Class Group structure Determine the structure of the group I inv /P Quantum Algorithm for Pell s Equation p. 56/6
Principal Ideal Problem Recall an ideal I Q( d) such that I O = I Principal ideal I = γo All ideals of the form I = αz + βz Given an ideal, decide if there exists a γ such that I = γo Quantum Algorithm for Pell s Equation p. 57/6
Computing the Class Group Invertible ideals An ideal I is called invertible if there exists another ideal J such that I J = O Let I = {I I exists } P = {I I = γo} Let C = I/P C is a finite abelian group and called the class group Class group problem is to determine the structure of C Quantum Algorithm for Pell s Equation p. 58/6
Generalizations A general problem is to compute the unit group of a O Q(θ) where [Q(θ) : Q] = n For Pell s equation n = 2 Similarly the class group and the principal ideal problem also can be generalized Two algorithms for the same have appeared recently by Hallgren and Vollmer, Schmidt independetly this year Quantum Algorithm for Pell s Equation p. 59/6
Questions? Quantum Algorithm for Pell s Equation p. 6/6
Questions? Thank You Quantum Algorithm for Pell s Equation p. 6/6