Solving x 2 Dy 2 = N in integers, where D > 0 is not a perfect square. Keith Matthews

Similar documents
PELL S EQUATION, II KEITH CONRAD

Prime Numbers and Irrational Numbers

Part II. Number Theory. Year

On Representations of integers by the quadratic form x2 Dy2

Notes on Continued Fractions for Math 4400

NORM OR EXCEPTION? KANNAPPAN SAMPATH & B.SURY

Number Theory. Final Exam from Spring Solutions

Solving Pell s equation using the nearest square continued fraction

18-29 mai 2015: Oujda (Maroc) École de recherche CIMPA-Oujda Théorie des Nombres et ses Applications. Continued fractions. Michel Waldschmidt

Quadratic Diophantine Equations x 2 Dy 2 = c n

On a diophantine equation of Andrej Dujella

Pell Equation x 2 Dy 2 = 2, II

CONTINUED FRACTIONS. 1. Finite continued fractions A finite continued fraction is defined by [a 0,..., a n ] = a 0 +

Pell s equation. Michel Waldschmidt

Math Homework 2

USING SHANKS BABY-STEP GIANT-STEP METHOD TO SOLVE THE GENERALIZED PELL EQUATION x 2 Dy 2 = N. Copyright 2009 by John P. Robertson. 1.

x 9 or x > 10 Name: Class: Date: 1 How many natural numbers are between 1.5 and 4.5 on the number line?

SYMMETRY AND SPECIALIZABILITY IN THE CONTINUED FRACTION EXPANSIONS OF SOME INFINITE PRODUCTS

Extending Theorems of Serret and Pavone

Multiplication of Polynomials

Lesson 3: Linear differential equations of the first order Solve each of the following differential equations by two methods.

Primes - Problem Sheet 5 - Solutions

not to be republished NCERT REAL NUMBERS CHAPTER 1 (A) Main Concepts and Results

CONTINUED FRACTIONS, PELL S EQUATION, AND TRANSCENDENTAL NUMBERS

CONTENTS COLLEGE ALGEBRA: DR.YOU

Math 118: Advanced Number Theory. Samit Dasgupta and Gary Kirby

8. Dirichlet s Theorem and Farey Fractions

On the continued fraction expansion of 2 2n+1

Math 0320 Final Exam Review

Answers to Problem Set Number MIT (Fall 2005).

Math 234 Final Exam (with answers) Spring 2017

Proofs. Methods of Proof Divisibility Floor and Ceiling Contradiction & Contrapositive Euclidean Algorithm. Reading (Epp s textbook)

Number Theory and Cryptography

D( 1)-QUADRUPLES AND PRODUCTS OF TWO PRIMES. Anitha Srinivasan Saint Louis University-Madrid campus, Spain

Number Theory and Graph Theory

Math 314 Course Notes: Brief description

ON THE LENGTH OF THE PERIOD OF A REAL QUADRATIC IRRATIONAL. N. Saradha

Chakravala - a modern Indian method. B.Sury

Summary Slides for MATH 342 June 25, 2018

(z 0 ) = lim. = lim. = f. Similarly along a vertical line, we fix x = x 0 and vary y. Setting z = x 0 + iy, we get. = lim. = i f

Part 1. For any A-module, let M[x] denote the set of all polynomials in x with coefficients in M, that is to say expressions of the form

Selected Math 553 Homework Solutions

SOLUTIONS Math 345 Homework 6 10/11/2017. Exercise 23. (a) Solve the following congruences: (i) x (mod 12) Answer. We have

arxiv:math/ v1 [math.nt] 9 Aug 2004

READ T H E DATE ON LABEL A blue m a r k a r o u n d this notice will call y o u r attention to y o u r LOWELL. MICHIGAN, THURSDAY, AUGUST 29.

ON DIRICHLET S CONJECTURE ON RELATIVE CLASS NUMBER ONE

Formal Asymptotic Homogenization

Galois fields/1. (M3) There is an element 1 (not equal to 0) such that a 1 = a for all a.

MATH 310: Homework 7

On the Rank and Integral Points of Elliptic Curves y 2 = x 3 px

On certain biquadratic equations

1MA6 Partial Differentiation and Multiple Integrals: I

Apéry Numbers, Franel Numbers and Binary Quadratic Forms

Introduction to Number Theory

MATH 4400 SOLUTIONS TO SOME EXERCISES. 1. Chapter 1

Faculty of Engineering, Mathematics and Science School of Mathematics

A Generalization of Wilson s Theorem

Number Theory Marathon. Mario Ynocente Castro, National University of Engineering, Peru

Math 10C - Fall Final Exam

Section September 6, If n = 3, 4, 5,..., the polynomial is called a cubic, quartic, quintic, etc.

INDEFINITE QUADRATIC FORMS AND PELL EQUATIONS INVOLVING QUADRATIC IDEALS

Chapter 3. Reading assignment: In this chapter we will cover Sections dx 1 + a 0(x)y(x) = g(x). (1)

Chapter 4: Partial differentiation

On rational numbers associated with arithmetic functions evaluated at factorials

MA257: INTRODUCTION TO NUMBER THEORY LECTURE NOTES

REAL NUMBERS. Any positive integer a can be divided by another positive integer b in such a way that it leaves a remainder r that is smaller than b.

Ramanujan s first letter to Hardy: 5 + = 1 + e 2π 1 + e 4π 1 +

Prerequisites. Copyright Cengage Learning. All rights reserved.

Math 200 University of Connecticut

Mathematics 220 Midterm Practice problems from old exams Page 1 of 8

Number Theory Marathon. Mario Ynocente Castro, National University of Engineering, Peru

First order Partial Differential equations

ABSTRACT INVESTIGATION INTO SOLVABLE QUINTICS. Professor Lawrence C. Washington Department of Mathematics

Math 3320 Problem Set 10 Solutions 1

NOTES ON QUADRATIC INTEGERS AND REAL QUADRATIC NUMBER FIELDS

Mathematics 324 Riemann Zeta Function August 5, 2005

ALGEBRA PH.D. QUALIFYING EXAM September 27, 2008

Lecture 5 - Fundamental Theorem for Line Integrals and Green s Theorem

Exploring Number Theory via Diophantine Equations

1. Given the public RSA encryption key (e, n) = (5, 35), find the corresponding decryption key (d, n).

Mathematics for Cryptography

EXPLICIT EVALUATIONS OF SOME WEIL SUMS. 1. Introduction In this article we will explicitly evaluate exponential sums of the form

1 Predicates and Quantifiers

WARING S PROBLEM FOR n = 2

Chapter 8. Exploring Polynomial Functions. Jennifer Huss

On the number of representations of n by ax 2 + by(y 1)/2, ax 2 + by(3y 1)/2 and ax(x 1)/2 + by(3y 1)/2

CHAPTER 1 REAL NUMBERS KEY POINTS

Attempt QUESTIONS 1 and 2, and THREE other questions. penalised if you attempt additional questions.

Homework 7 solutions M328K by Mark Lindberg/Marie-Amelie Lawn

A field F is a set of numbers that includes the two numbers 0 and 1 and satisfies the properties:

Finite Fields. Saravanan Vijayakumaran Department of Electrical Engineering Indian Institute of Technology Bombay

A Note on Jacobi Symbols and Continued Fractions

First and Second Order ODEs

MATH 152 Problem set 6 solutions

PODSYPANIN S PAPER ON THE LENGTH OF THE PERIOD OF A QUADRATIC IRRATIONAL. Copyright 2007

ON UNIVERSAL SUMS OF POLYGONAL NUMBERS

Projects on elliptic curves and modular forms

COUNTING MOD l SOLUTIONS VIA MODULAR FORMS

1. multiplication is commutative and associative;

Transcription:

Solving x 2 Dy 2 = N in integers, where D > 0 is not a perfect square. Keith Matthews Abstract We describe a neglected algorithm, based on simple continued fractions, due to Lagrange, for deciding the solubility of x 2 Dy 2 = N, with gcd(x, y) = 1, where D > 0 and is not a perfect square. In the case of solubility, the fundamental solutions are also constructed. 1

Lagrange s well-known algorithm In 1768, Lagrange showed that if x 2 Dy 2 = N, x > 0, y > 0, gcd(x, y) = 1 and N < D, then x/y is a convergent A n /B n of the simple continued fraction of D. For we have Hence and (x + Dy)(x Dy) = N x Dy = N x + Dy < D x + Dy. x y > D x y < D x y D < 1 2y 2 y x 1 < 1 D 2x 2. 2

If D = [a 0, a 1,..., a l ], due to periodicity of ( 1) n+1 A 2 n DB 2 n, for solubility, we need only check the values for the range 0 n l/2 1. To find all solutions, we check the range 0 n l 1. Example: x 2 13y 2 = 3. 13 = [3, 1, 1, 1, 1, 6]. n A n /B n A 2 n 13Bn 2 0 3/1 4 1 4/1 3 2 7/2 3 3 11/3 4 4 18/5 1 The positive solutions (x, y) are given by x + y 13 = { η 2n (4 + 13), n 0, η 2n+1 (7 + 2 13), n 0, where η = 18 + 5 13. Note: 7 + 2 13 = η( 4 + 13). 3

Example: x 2 221y 2 = 4. 221 = [14, 1, 6, 2, 6, 1, 28]. n A n /B n A 2 n 221Bn 2 0 14/1 25 1 15/1 4 2 104/7 13 3 223/15 4 4 1442/97 25 5 1665/112 1 The positive solutions (x, y), gcd(x, y) = 1, are given by x + y 221 = { η n (15 + 221), n 0, η n (223 + 15 221), n 0, where η = 1665 + 112 221. Note: (i) x 2 221y 2 = 4 has no solution in positive (x, y) with gcd(x, y) = 1. (ii) 223 + 15 221 = η( 15 + 221). 4

In 1770, Lagrange gave a neglected algorithm for solving x 2 Dy 2 = N for arbitrary N 0, using the continued fraction expansions of (P ± D)/ N, where P 2 D (mod N ), N /2 < P N /2. The difficulty is to show that all solutions arise from the continued fractions and Lagrange s discussion of this was hard to follow. My contribution was to give a short proof using a unimodular matrix lemma (Theorem 172 of Hardy and Wright) which gives a sufficient test for a rational to be a convergent of a simple continued fraction. 5

Pell s equation The special case N = 1 is known as Pell s equation. If η 0 = x 0 + y 0 D denotes the fundamental solution of x 2 Dy 2 = 1, ie, the solution with least positive x and y, then the general solution is given by x + y D = ±η n 0, n Z. We can calculate (x 0, y 0 ) by expanding D as a periodic continued fraction: D = [a0, a 1,..., a l ]. Then x 0 /y 0 = A l 1 B, l 1 A 2l 1 B, 2l 1 if l is even if l is odd, 6

Equivalence classes of primitive solutions of x 2 Dy 2 = N. The identity (x 2 Dy 2 )(u 2 Dv 2 ) = (xu+yvd) 2 D(uy+vx) 2 shows that primitive solutions (x, y) of x 2 Dy 2 = N and (u, v) of Pell s equation u 2 Dv 2 = 1, produce a primitive solution (x, y ) = (xu + yvd, uy + vx) of x 2 Dy 2 = N. Note that x + y D = (x + y D)(u + v D). (1) Equation (1) defines an equivalence relation on the set of all primitive solutions of x 2 Dy 2 = N. 7

Associating a congruence class mod N to each equivalence class. If x 2 Dy 2 = N with gcd(x, y) = 1, then gcd(y, N) = 1. We define P by x yp (mod N ). Then x 2 Dy 2 0 (mod N ) y 2 P 2 Dy 2 0 (mod N ) P 2 D 0 (mod N ) P 2 D (mod N ). 8

Primitive solutions (x, y) and (x, y ) are equivalent if and only if xx yy D 0 (mod N ) yx xy 0 (mod N ). Then (x, y) and (x, y ) are equivalent if and only if P P (mod N ). Hence the number of equivalence classes is finite. 9

If (x, y) is a solution for a class C, then ( x, y) is a solution for the conjugate class C. It can happen that C = C, in which case C is called an ambiguous class. A class is ambiguous if and only if P 0 or N /2 (mod N ). The solution (x, y) in a class with least y > 0 is called a fundamental solution. For an ambiguous class, there are either two (x, y) and ( x, y) with least y > 0 if x > 0 and one if x = 0, namely (0, 1) and we choose the one with x 0. 10

Continued fractions of quadratic irrationalities. Let ω = P 0+ D Q 0 Q 0 (P0 2 D). = [a 0, a 1,..., ], where Then the n th complete quotient x n = [a n, a n+1,..., ] = (P n + D)/Q n. There is a simple algorithm for calculating a n, P n and Q n : P a n = n + D Q n, (2) P n+1 = a n Q n P n, Q n+1 = D P 2 n+1 Q n. We also note the following important identity G 2 n 1 DB2 n 1 = ( 1)n Q 0 Q n, where G n 1 = Q 0 A n 1 P 0 B n 1. In (2) we can replace D by D or 1 + D according as Q n > 0 or Q n < 0. 11

Necessary conditions for solubility of x 2 Dy 2 = N. Suppose x 2 Dy 2 = N, gcd(x, y) = 1, y > 0. Let x yp (mod N ). Then by dealing with the conjugate class instead, if necessary, we can assume 0 P N /2. Also P 2 D (mod N ). Let x = P y + N X. Lagrange substituted for x = P y + N X in the equation x 2 Dy 2 = N to get N X 2 + 2P Xy + (P 2 D) y N 2 = N N. He then appealed to a result on a general homogeneous equation f(x, y) = 1 and deduced that X/y is a convergent to a root of equation f(x, y) = 0. 12

We prove (i) If x 0, then X/y is a convergent A n 1 /B n 1 to ω = P + D and N Q n = ( 1) n N N. (ii) If x < 0, then X/y is a convergent A m 1 /B m 1 to ω = P D and N Q m = ( 1) m+1 N N. 13

We prove part (i) by using the following extension of Theorem 172 in Hardy and Wright s book: Lemma. If ω = Uζ+R V ζ+s, where ζ > 1 and U, V, R, S are integers such that V > 0, S > 0 and US V R = ±1, or S = 0 and V = R = 1, then U/V is a convergent to ω. 14

We apply the Lemma to the matrix [ U R V S ] = X y P x+dy N The matrix has integer entries. For x. x yp (mod N ) and P 2 D (mod N ). Hence P x + Dy P 2 y + Dy (mod N ) (D P 2 )y 0 (mod N ). 15

The matrix X y P x+dy N x has determinant y( P x + Dy) = Xx N (x P y)x y( P x + Dy) = N = x2 Dy 2 = N N N = ±1. Also if ζ = D and ω = ( P + D)/ N, it is easy to verify that ω = Uζ+R V ζ+s. The lemma now implies that U/V = X/y is a convergent A n 1 /B n 1 to ω. Also G n 1 = Q 0 A n 1 P 0 B n 1 = N X + P y = x. Hence N = x 2 Dy 2 = G 2 n 1 DB2 n 1 = ( 1)n N Q n, so Q n = ( 1) n N/ N. 16

Refining the necessary condition for solubility Lemma. An equivalence class of solutions contains an (x, y) with x 0 and y > 0. Proof. Let (x 0, y 0 ) be fundamental solution of a class C. Then if x 0 0 we are finished. So suppose x 0 < 0 and let u + v D, u > 0, v > 0, be a solution of Pell s equation. Define X and Y by X + Y D = (x 0 + y 0 D)(u + v D). Then it can be shown that (a) X < 0 and Y < 0 if N > 0, (b) X > 0 and Y > 0 if N < 0. Hence C contains a solution (X, Y ) with X > 0 and Y > 0. Hence a necessary condition for solubility of x 2 Dy 2 = N is that Q n = ( 1) n N/ N holds for some n in the continued fraction for ω = P + D. N 17

Limiting the search range when testing for necessity Let ω = [a 0,..., a t, a t+1,..., a t+l ]. Then by periodicity of the Q i, we can assume that Q n = ( 1) n N/ N holds for some n t + l if l is even, or n t + 2l if l is odd. In the latter case all we can say is that Q n = ±1 holds for some n t + l. This gives us our final form of the necessary condition. 18

Sufficiency. Suppose P 2 D (mod N ), 0 P N /2 and let ω = P + D N = [a 0,..., a t, a t+1,..., a t+l ]. Suppose we have Q n = ( 1) n N/ N for some n in 1 n t + l if l is even, or Q n = ɛ = ±1 for some n in 1 n t + l if l is odd. Then with G n 1 = N A n 1 + P B n 1, we have (i) if l is even, the equation x 2 Dy 2 = N has a primitive solution (G n 1, B n 1 ); (ii) if l is odd, then (G n 1, B n 1 ) is a primitive solution of x 2 Dy 2 = ( 1) n N ɛ, while (G n+l 1, B n+l 1 ) will be a primitive solution of x 2 Dy 2 = ( 1) n+1 N ɛ; (iii) one of the (G k 1, B k 1 ) with least B k 1 satisfying G 2 k 1 DB2 k 1 = N and arising from the continued fraction expansions of ( P + D)/ N and ( P D)/ N, will be a fundamental solution of x 2 Dy 2 = N. 19

Primitivity of solutions (Peter Hackman) Assume x 2 Dy 2 = N, P 2 D (mod Q) and x P y (mod Q), where Q = N. Then gcd(x, y) = 1. Proof. P x Dy (P 2 D)y 0 (mod Q) so P x Dy = aq. (1) Also P y + x = bq. (2) Then adding y times (1) and x times (2) gives: (ay + bx)q = Dy 2 + x 2 = N. Hence ay + bx = N/Q = ±1. 20

An example: x 2 221y 2 = 217 and 217. We find the solutions of P 2 221 (mod 217) satisfying 0 P 103 are P = 2 and P = 33. (a) 2+ 221 217 = [0, 16, 1, 6, 2, 6, 1, 28]. i 0 1 2 3 4 5 6 7 P i 2 2 14 11 13 13 11 14 Q i 217 1 25 4 13 4 25 1 A i 0 1 1 7 15 97 112 3233 B i 1 16 17 118 253 1636 1889 54528 The period length is 6 and Q 1 = 1 = ( 1) 1 ( 217)/ 217. Hence (G 0, B 0 ) = (2, 1) is a solution of x 2 221y 2 = 217 and this is clearly a fundamental one, so there is no need to examine the continued fraction expansion of 2 221 217. 21

(b) 33+ 221 217 = [ 1, 1, 10, 1, 28, 1, 6, 2, 6]. i 0 1 2 3 4 5 6 7 8 P i 33 184 29 11 14 14 11 13 13 Q i 217 155 4 25 1 25 4 13 4 A i 1 0 1 1 29 30 209 448 2897 B i 1 1 11 12 347 359 2501 5361 34667 We observe that Q 4 = 1 = ( 1) 4 217/ 217 and the period length is 6. Hence (G 3, B 3 ) = (179, 12) is a solution of x 2 221y 2 = 217. 22

c) 33 221 217 = [ 1, 1, 3, 1, 1, 6, 1, 28, 1, 6, 2]. i 0 1 2 3 4 5 6 7 8 9 10 P i 33 184 29 17 0 13 11 14 14 11 13 Q i 217 155 4 17 13 4 25 1 25 4 13 A i 1 0 1 1 2 13 15 433 448 3121 6690 B i 1 1 4 5 9 59 68 1963 2031 14149 30329 We observe that Q 7 = 1 = ( 1) 8 217/ 217. Hence (G 6, B 6 ) = ( 1011, 68) is a solution of x 2 221y 2 = 217. It follows from (b) and (c) that (179, 12) is a fundamental solution. Here η 0 = 1665 + 112 221 is the fundamental solution of Pell s equation. Then the complete solution of x 2 221y 2 = 217 is given by x + y 221 = ±(±2 + 221)η n 0, n Z. The complete solution of x 2 221y 2 = 217 is given by x + y 221 = ±(±179 + 12 221)η n 0, n Z. 23

Example: Solving x 2 py 2 = ( 2 p ) p 1 2, p = 4n + 3. Let p be a prime of the form 4n + 3. Then it is classical that the equation x 2 py 2 = 2 ( 2 p ) has a solution in integers. So with ω 1 = (1 + p)/2 = [λ, a 1,..., a L 1, 2λ + 1], there is exactly one n, 1 n L satisfying Q n ( 1) n = ( 2 p ). (Qn = 1 and L is even and n = L/2.) Now in solving the given equation, notice that P = 1 is a solution of P 2 p (mod (p 1)/2). So with ω 2 = ( 1 + p)/((p 1)/2), the first complete quotient is in fact ω 1. It follows that the corresponding Q n+1 is the old Q n and so now Q n ( 1) n+1 = ( 2 p ). hence there is a solution of x 2 py 2 = ( 2 p ) p 1 2. 24

John Robertson (September 2004) has produced the following short proof of the previous result. Assume X 2 py 2 = 2 ( 2 p ), p = 4n + 3. Make the integer transformation x = (py X)/2, y = (X Y )/2. Then x 2 py 2 = ( 2 p ) (p 1)/2. 25