Solving Pell Equations

Similar documents
Polygonal Designs: Existence and Construction

Curious Bounds for Floor Function Sums

a a a a a a a m a b a b

arxiv: v1 [math.nt] 14 Sep 2014

The Weierstrass Approximation Theorem

4 = (0.02) 3 13, = 0.25 because = 25. Simi-

Lecture 21. Interior Point Methods Setup and Algorithm

EXPLICIT CONGRUENCES FOR EULER POLYNOMIALS

A1. Find all ordered pairs (a, b) of positive integers for which 1 a + 1 b = 3

1 Bounding the Margin

Egyptian Mathematics Problem Set

Intelligent Systems: Reasoning and Recognition. Perceptrons and Support Vector Machines

Uniform Approximation and Bernstein Polynomials with Coefficients in the Unit Interval

ORIGAMI CONSTRUCTIONS OF RINGS OF INTEGERS OF IMAGINARY QUADRATIC FIELDS

A Note on Scheduling Tall/Small Multiprocessor Tasks with Unit Processing Time to Minimize Maximum Tardiness

The Methods of Solution for Constrained Nonlinear Programming

Infinitely Many Trees Have Non-Sperner Subtree Poset

Characterization of the Line Complexity of Cellular Automata Generated by Polynomial Transition Rules. Bertrand Stone

On Certain C-Test Words for Free Groups

3.8 Three Types of Convergence

List Scheduling and LPT Oliver Braun (09/05/2017)

The Euler-Maclaurin Formula and Sums of Powers

Analysis of Polynomial & Rational Functions ( summary )

arxiv: v2 [math.nt] 5 Sep 2012

Feature Extraction Techniques

PRELIMINARIES This section lists for later sections the necessary preliminaries, which include definitions, notations and lemmas.

A := A i : {A i } S. is an algebra. The same object is obtained when the union in required to be disjoint.

Quadratic Reciprocity. As in the previous notes, we consider the Legendre Symbol, defined by

Chaotic Coupled Map Lattices

Model Fitting. CURM Background Material, Fall 2014 Dr. Doreen De Leon

Block designs and statistics

Page 1 Lab 1 Elementary Matrix and Linear Algebra Spring 2011

arxiv:math/ v1 [math.nt] 6 Apr 2005

13.2 Fully Polynomial Randomized Approximation Scheme for Permanent of Random 0-1 Matrices

Math 1600A Lecture 3, Section 002

An EGZ generalization for 5 colors

A Bernstein-Markov Theorem for Normed Spaces

An Approach to Conic Sections

ADVANCES ON THE BESSIS- MOUSSA-VILLANI TRACE CONJECTURE

MULTIPLAYER ROCK-PAPER-SCISSORS

Chapter 6 1-D Continuous Groups

PREPRINT 2006:17. Inequalities of the Brunn-Minkowski Type for Gaussian Measures CHRISTER BORELL

Least Squares Fitting of Data

. The univariate situation. It is well-known for a long tie that denoinators of Pade approxiants can be considered as orthogonal polynoials with respe

lecture 36: Linear Multistep Mehods: Zero Stability

Algorithms for parallel processor scheduling with distinct due windows and unit-time jobs

COS 424: Interacting with Data. Written Exercises

Solutions of some selected problems of Homework 4

Lecture 21 Principle of Inclusion and Exclusion

Generalized eigenfunctions and a Borel Theorem on the Sierpinski Gasket.

Midterm 1 Sample Solution

arxiv: v1 [cs.ds] 29 Jan 2012

In this chapter, we consider several graph-theoretic and probabilistic models

Support Vector Machines MIT Course Notes Cynthia Rudin

Chapter II TRIANGULAR NUMBERS

Construction of the Electronic Angular Wave Functions and Probability Distributions of the Hydrogen Atom

Putnam 1997 (Problems and Solutions)

1. INTRODUCTION AND RESULTS

Finite fields. and we ve used it in various examples and homework problems. In these notes I will introduce more finite fields

MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.436J/15.085J Fall 2008 Lecture 11 10/15/2008 ABSTRACT INTEGRATION I

Math Real Analysis The Henstock-Kurzweil Integral

6.2 Grid Search of Chi-Square Space

CSE525: Randomized Algorithms and Probabilistic Analysis May 16, Lecture 13

OBJECTIVES INTRODUCTION

Combinatorial Primality Test

Probability and Stochastic Processes: A Friendly Introduction for Electrical and Computer Engineers Roy D. Yates and David J.

PELL S EQUATION, II KEITH CONRAD

Birthday Paradox Calculations and Approximation

International Mathematical Olympiad. Preliminary Selection Contest 2009 Hong Kong. Outline of Solutions

Stability Ordinates of Adams Predictor-Corrector Methods

Congruences and Modular Arithmetic

A Better Algorithm For an Ancient Scheduling Problem. David R. Karger Steven J. Phillips Eric Torng. Department of Computer Science

Beyond Mere Convergence

arxiv:math/ v1 [math.nt] 15 Jul 2003

Computable Shell Decomposition Bounds

MODULAR HYPERBOLAS AND THE CONGRUENCE ax 1 x 2 x k + bx k+1 x k+2 x 2k c (mod m)

Descent polynomials. Mohamed Omar Department of Mathematics, Harvey Mudd College, 301 Platt Boulevard, Claremont, CA , USA,

Time-frequency plane behavioural studies of harmonic and chirp functions with fractional Fourier transform (FRFT)

Kernel Methods and Support Vector Machines

Bernoulli Numbers. Junior Number Theory Seminar University of Texas at Austin September 6th, 2005 Matilde N. Lalín. m 1 ( ) m + 1 k. B m.

Calculus with the TI-89. Sample Activity: Exploration 6. Brendan Kelly

Physics 2210 Fall smartphysics 20 Conservation of Angular Momentum 21 Simple Harmonic Motion 11/23/2015

1 Rademacher Complexity Bounds

THE SUPER CATALAN NUMBERS S(m, m + s) FOR s 3 AND SOME INTEGER FACTORIAL RATIOS. 1. Introduction. = (2n)!

1 Proof of learning bounds

USEFUL HINTS FOR SOLVING PHYSICS OLYMPIAD PROBLEMS. By: Ian Blokland, Augustana Campus, University of Alberta

E0 370 Statistical Learning Theory Lecture 5 (Aug 25, 2011)

M ath. Res. Lett. 15 (2008), no. 2, c International Press 2008 SUM-PRODUCT ESTIMATES VIA DIRECTED EXPANDERS. Van H. Vu. 1.

A note on the multiplication of sparse matrices

arxiv: v1 [cs.ds] 3 Feb 2014

On Conditions for Linearity of Optimal Estimation

Least squares fitting with elliptic paraboloids

THE ROTATION NUMBER OF PRIMITIVE VE SEQUENCES. Citation Osaka Journal of Mathematics. 52(3)

Force and dynamics with a spring, analytic approach

13 Harmonic oscillator revisited: Dirac s approach and introduction to Second Quantization

On the Use of A Priori Information for Sparse Signal Approximations

Bernoulli numbers and generalized factorial sums

arxiv: v1 [math.co] 19 Apr 2017

PYTHAGOREAN TRIPLES KEITH CONRAD

Fast Montgomery-like Square Root Computation over GF(2 m ) for All Trinomials

Transcription:

Solving Pell Equations Matthew Wright May 2, 2006 Departent of Matheatical Sciences Messiah College Grantha, PA Dr. Laarr Wider, advisor

This paper is subitted in partial fulfillent of the requireents for departental honors in atheatics. Abstract This paper is an investigation of Pell Equations equations of the for x 2 dy 2 = k where d is a nonsquare, positive integer, k is an integer, and we are looking for integer solutions in x and y. We will provide otivation, both algebraic and geoetric, for this definition of Pell Equations. Next, we will exaine the k = 1 case, proving not only that it is solvable, but also that infinitely any solutions can be obtained easily fro the fundaental solution. We will classify soe Pell Equations as solvable or unsolvable when k 1, exaining in detail the k = 4 case. After explaining several patterns that appear when k = 4 and d 5 (od 8), we will prove the existence of a fundaental solution for these cases. Finally, we will briefly exaine how a coputer ay be used to find solutions, especially the fundaental solution, for Pell Equations. 1

Contents 1 Introduction 3 1.1 Why ust d be positive?............................. 3 1.2 Why ust d be nonsquare?........................... 3 1.3 Pell Equation................................... 5 2 The Equation x 2 dy 2 = 1 is Solvable 6 3 The Fundaental Solution 10 3.1 Sequence of Solutions............................... 10 3.2 Ordering the Solutions.............................. 11 3.3 Sallest is Fundaental............................. 12 3.4 Define a and b................................... 13 3.5 Obtain a Contradiction.............................. 14 4 What About k 1? 15 4.1 Identifying Unsolvable Pell Equations...................... 15 4.2 If k is a Square.................................. 16 5 Investigation of x 2 dy 2 = 4 16 5.1 Cases when d 5 (od 8)............................ 17 5.2 Odd-Even Solution Patterns........................... 18 5.3 More Patterns in Solutions............................ 20 6 The Fundaental Solution Revisited 21 6.1 Preliinary Work................................. 22 6.2 An Arbitrary Solution (u, v)........................... 22 6.3 Define a and b................................... 23 6.4 Obtain a Contradiction.............................. 24 7 Prograing 25 8 Table of Solutions 28 References 29 A Listing of PellSolver 30 2

1 Introduction In nuber theory, Pell Equations fall in the category of Diophantine equations. Naed after the Greek atheatician Diophantus, Diophantine equations are equations for which integer solutions are desired. Specifically, Pell Equations have the for x 2 dy 2 = k, where d and k are fixed and we are looking for integers x and y that satisfy the equation. Soe atheaticians specify that k = 1, but we will allow k to be any nonzero integer. We further qualify the integer d to be positive and nonsquare. This qualification is helpful because it leaves open the possibility of infinitely any solutions in positive integers x and y. 1.1 Why ust d be positive? If d were negative, such as d = p, then the equation of interest becoes x 2 + py 2 = k, which has the for of an ellipse. This ellipse has x-intercepts at ± k and y-intercepts at k ±. By plotting the ellipse on the Cartesian plane (see Figure 1), we can easily see that p k the integers on the y-axis between 0 and ± are the only possible positive integers that p ight correspond to points on the ellipse with integer coordinates. Therefore, there can be k no ore than solutions in positive integers to the equation p x2 + py 2 = k. k p y k x Figure 1: Equations of the for x 2 + py 2 = 1 have finitely any positive integer solutions (x, y). 1.2 Why ust d be nonsquare? If d is a square, such as d = q 2, where q is a positive integer, then the equation becoes x 2 q 2 y 2 = k, which factors into (x + qy)(x qy) = k (1) 3

Since x, y, and q are all positive integers, the left-hand side of (1) ust be two integers whose product is k. For each pair of positive integers and n, > n, such that n = k, there ight exist integers x and y that satisfy { x + qy = x qy = n Therefore, the nuber of positive integer solutions that satisfy (1) is bounded by half the nuber of positive integers which divide k. It could also happen that the equation has no solutions, as in the case x 2 y 2 = 10. We can also see that an equation of the for x 2 q 2 y 2 = k has finitely any integer solutions by the following graphical arguent. First, sketch the graph of the hyperbola x 2 q 2 y 2 = k on the Cartesian plane. Except for a sall region near the origin (the region in Figure 2, for exaple), the hyperbola is very close to its asyptotes. The asyptotes are of the for x + qy = 0 and x qy = 0, so they are lines through the origin with slopes of ±1/q. The hyperbola ight pass through points with integer coefficients near the origin, but it soon gets too close to its asyptotes to pass through any such points. y (q, 1) (2q, 2) k k x Figure 2: The graph of a hyperbola, x 2 q 2 y 2 = k and its asyptotes, x + qy = 0 and x qy = 0. Figure 3 shows a portion of the asyptote x qy = 0 on a grid of points with integer coordinates. Circled points are those closest to the asyptote, but not on the asyptote. The agnification in Figure 3 helps deterine the distance fro any such point to the 4

asyptote. Call this distance a. By the Pythagorean Theore, we have (aq) 2 = a 2 + 1 a 2 q 2 a 2 = 1 a 2 (q 2 1) = 1 a 2 = 1 q 2 1 1 a = q 2 1 Therefore, there are no points with integer coefficients whose distance d fro an asyptote is 0 < d < 1 q 2 1 x qy = 0 aq 1 a Figure 3: The asyptote x qy = 0 on a grid of points with integer coordinates. Let f(x) be the branch of the hyperbola in the first quadrant: x f(x) = 2 k, x k. q 2 We know that li x f(x) = x and f(x) x for any x. So for each ɛ > 0 there exists q q x 0 > 0 such that x > x 0 iplies 0 < f(x) x q < ɛ 1 Let ɛ =. Then there exists x q 2 1 0 > 0 such that for all x > x 0, the graph of f(x) is closer than fro its asyptote, but never touches its asyptote. Therefore, f(x) 1 q 2 1 does not pass through any integer coordinates for x > x 0. We see that f(x) ay only pass through integer coordinates when k < x < x 0, so f(x) cannot pass through infinitely any points with integer coordinates. Therefore, x 2 q 2 y 2 = k has finitely any integer solutions. 1.3 Pell Equation Having otivated the choice of d positive and nonsquare, we arrive at the following definition: 5

Definition 1. A Pell Equation is an equation of the for x 2 dy 2 = k, where d is a positive nonsquare integer and k is a nonzero integer, for which we attept to find integer solutions x and y. Pell Equations have been of interest to atheaticians for centuries. Archiedes faous cattle proble leads to a Pell Equation. The Indian atheatican Brahagupta in the sixth century had ethods to find solutions to x 2 dy 2 = 1, and he could generate infinitely any solutions fro an initial solution. In Europe, Pierre de Ferat studied the equation and inspired soe of his conteporaries to do the sae. John Pell was an English atheatician who appears to have had a reputation as an algebraist in the iddle of the 17 th century, but he did hardly any work with the equation that bears his nae [2]. Leonhard Euler credited the equation to Pell in a letter to Goldbach in 1730, and the nae stuck [1]. 2 The Equation x 2 dy 2 = 1 is Solvable Pell Equations where k = 1 are of special interest to atheaticians because they have infinitely any solutions. In fact, soe authors define Pell Equations to be of the for x 2 dy 2 = 1, not considering equations where k 1 as our broader definition perits. In this section, we will prove that the equation x 2 dy 2 = 1 has a solution in positive integers x and y. We will begin with the following lea: Lea 1. For a given integer N, there are positive integers u and v for which u v d < 1 N 1 v (2) and u 2 v 2 2 d + 1 (3) To ake the proof easier, we introduce soe notation. For any nuber α, we will denote by α the fractional part of α. That is, α = α α, where α is the greatest integer that does not exceed α. Proof. Consider the N + 1 nubers, all of which are between 0 and 1: d, 2 d,..., N d, (N + 1) d (4) i Also consider the N intervals {t : < t < i+1 }, where 0 i N 1. Each of these intervals N N has width 1/N. Note that together, this set of intervals spans the nubers fro 0 to 1, except for the the nubers i/n, which are the endpoints of the intervals. These boundaries, i/n, never equal any of the nubers in (4) since all of the nubers are irrational. By the pigeonhole principle, if we place the N + 1 nubers in the N intervals, at least one interval ust contain at least two of the nubers. Call two of these nubers q d and s d, with q > s. Call the interval that contains these nubers ( i, ) i+1 N N. Therefore, we have i N < q d < i + 1 i and N N < s d < i + 1 N 6

Define p and r to be the integer parts of q d and s d, respectively. Therefore, p q d = q d q d and r = s d = s d s d. Since q > s and d > 1, q d > s d and p > r. Since q and s are each between 1 and N +1, their difference cannot exceed N. Therefore, q s N. Since q d and s d both fall in the sae interval of width 1/N, their difference is less than 1/N. Therefore, q d s d < 1 N ( q ) ( d p s ) 1 d r < N (q s) d (p r) < 1 N (p r) (q s) d < 1 N Let u = p r and v = q s. Then q s = v N, so 1 1. Therefore, we have found two v N integers u and v that satsify u v d < 1 1, or ore iportantly N v u v d 1 v which proves the first part of Lea 1. To prove the second part of Lea 1, we begin with the following identity: Multiplying equations (5) and (6), we have u + v d = (u v d) + 2v d (6) (u + v d) u v d 1 v [(u v d) + 2v d] Beginning with inequality (5), we arrive at the following: so u v d v (5) u 2 dv 2 u v d + 2 d (7) v u v d 1 v u v d u v d 1 v 1 u v d v 1 (8) 7

Cobining inequalities (7) and (8), we have u 2 dv 2 u v d + 2 d 1 + 2 d v Therefore, we conclude that u 2 dv 2 2 d + 1 and this proves the second part of Lea 1. In proving Lea 1, we began by choosing the first N + 1 consecutive ultiples of d and exaining their fractional parts: d, 2 d,..., N d, (N + 1) d (9) Now, there are infinitely any non-overlapping sets of N +1 consecutive ultiples of d that we could have chosen, and each set works equally well in proving the lea. For exaple, we could have chosen either of the following: (N + 2) d, (N + 3) d,..., (2N + 2) d (2N + 3) d, (2N + 4) d,..., (3N + 3) d In any such set, we can find two nubers whose fractional parts lie in the sae interval. Therefore, each set produces the nubers u and v that satisfy the equations of Lea 1. Since we can choose non-overlapping sets, u and v will be unique to each set. Therefore, we can find infinitely any pairs (u, v) that satisfy u v d < 1 N 1 v and u 2 v 2 2 d + 1 (10) Note that u 2 dv 2 is an integer. Therefore, there are infinitely any solutions to u 2 dv 2 = j, where j is an integer bounded by j 2 d + 1. Since we have finitely any possibilities for j and infinitely any solutions (u, v), there ust be at least one j with infinitely any solutions (u, v). Let k be this particular value of j. Therefore, there are infinitely any solutions (u, v) to u 2 dv 2 = k. The second lea we will use in our proof is the following: Lea 2. If (x 1, y 1 ) and (x 2, y 2 ) are integer solutions of x 2 dy 2 = k such that x 1 x 2 (od k) and y 1 y 2 (od k) Then the equation x 2 dy 2 = 1 has a solution in positive integers. Proof. We have the following two equations: x 2 1 dy 2 1 = k and x 2 2 dy 2 1 = k (11) 8

Multiplying the equations together, we have (x 2 1 dy1)(x 2 2 2 dy2) 2 = k 2 x 2 1x 2 2 dx 2 1y2 2 dx 2 2y1 2 + d 2 y1y 2 2 2 = k 2 ( ) ( x 2 1 x 2 2 2dx 1 x 2 y 1 y 2 + d 2 y1y 2 2 2 d x 2 1 y2 2 2dx 1 x 2 y 1 y 2 + x 2 2y1) 2 = k 2 (x 1 x 2 dy 1 y 2 ) 2 d (x 1 y 2 x 2 y 1 ) 2 = k 2 ( ) 2 ( ) 2 x1 x 2 dy 1 y 2 x1 y 2 x 2 y 1 d = 1 (12) k k Equation (12) has the desired for, so the lea is proved if we can show that the quantities in parentheses are integers. Since x 1 x 2 (od k) and y 1 y 2 (od k), then x 1 x 2 dy 1 y 2 x 1 x 1 dy 1 y 1 = x 2 1 dy 2 1 But x 2 1 y 2 1 = k and k 0 (od k), so x 2 1 dy 2 1 0 (od k). Therefore, x 1 x 2 dy 1 y 2 x 2 1 dy 2 1 0 (od k) (13) Also, we see that x 1 y 2 x 2 y 1 (od k), which iplies that x 1 y 2 x 2 y 1 0 (od k) (14) Cobining the results of equations (13) and (14), we see that the quantities in parentheses in equation (12) are integers, so ( x1 x 2 dy 1 y 2, x ) 1y 2 x 2 y 1 k k is an integer solution of x 2 dy 2 = 1 and we have proved Lea 2. We are now ready to prove the ain theore of this section: Theore 1. The equation x 2 dy 2 = 1 has a solution in positive integers x and y for all positive, nonsquare integers d. Proof. We have found a value of k for which there exist infinitely any solutions (u, v) of u 2 dv 2 = k. There are only k 2 unique ordered pairs odulo k. Since we have ore than k 2 + 1 solutions (each of which is an ordered pair), at least two of the ust be equivalent odulo k. Call these two pairs (x i, y i ) and (x j, y j ), with x i x j and y i y j (od k). By Lea 2, the equation x 2 dy 2 = 1 has a solution in positive integers. 9

3 The Fundaental Solution In the previous section we proved that there exists a positive integer solution (x, y) to the equation x 2 dy 2 = 1 when d is positive and nonsquare, In this section we will see that there is a solution, known as the fundaental solution, fro which all other positive integer solutions ay be obtained. Specifically, we will prove that the fundaental solution is sallest positive integer solution to x 2 dy 2 = 1. We will also see how all other positive integer solutions can be obtained fro the fundaental solution. 3.1 Sequence of Solutions Fro any solution of x 2 dy 2 = 1, we can obtain infinitely any solutions. Suppose (x 1, y 1 ) is a solution of x 2 dy 2 = 1. We can obtain another solution by the following process: x 2 1 dy 2 1 = 1 (x 1 + y 1 d)(x1 y 1 d) = 1 (x 1 + y 1 d) 2 (x 1 y 1 d) 2 = 1 ) ) (x 21 + 2x 1 y 1 d + dy 21 (x 21 2x 1 y 1 d + dy 21 = 1 ( (x 2 1 + dy1) 2 + (2x 1 y 1 ) ) ( d (x 2 1 + dy1) 2 (2x 1 y 1 ) ) d = 1 ( ) x 2 1 + dy1 2 2 d (2x1 y 1 ) 2 = 1 We have again obtained the for of a Pell Equation, and we can see that (x 2 1 + dy1, 2 2x 1 y 1 ) is a solution. Applying the process again, we can obtain yet another solution, and so on, obtaining as any solutions as we desire. Alternately, suppose we consider integer powers of (x 1 + y 1 d): ( ) n x 1 + y 1 d = x n 1 + C 1 dx n 1 1 y 1 + C 2 dx n 2 1 y1 2 + C 3 d 3/2 x n 3 1 y1 3 + + d n/2 y1 n = ( x n 1 + C 2 dx n 2 1 y1 2 + ) + d ( C 1 x n 1 1 y 1 + C 3 x n 3 1 y1 3 + ) = x n + y n d where C i are the binoial coefficients: C i = ( ) n i = n!. Since each integer power can be (n i)!i! written in a for siilar to the original, we define x n and y n as follows: x n + y n d = (x 1 + y 1 d ) n (15) We will now prove the following theore: ) Theore 2. If x 1 > 1, y 1 1, and (x n + y n d y n+1 > y n for positive n. = ( x 1 + y 1 d ) n, then xn+1 > x n and 10

Proof by Induction. Initial Case: We find that x 2 = x 2 1 + dy1 2 and y 2 = 2x 1 y 1. Since x 1 > 1, y 1 1, and d is a positive integer, it is clear that x 2 > x 1 and y 2 > y 1. Induction: Assue we have a solution (x n, y n ) with x n and y n positive integers greater than 1. We have: ( ) n+1 x n+1 + y n+1 d = x 1 + y 1 d ) ) n = (x 1 + y 1 d (x 1 + y 1 d ) ) = (x 1 + y 1 d (x n + y n d = (x 1 x n + dy 1 y n ) + (x 1 y n + x n y 1 ) d Therefore, x n+1 = x 1 x n +dy 1 y n and y n+1 = x 1 y n +x n y 1. Note that x 1 x n > x n and dy 1 y n > 0. Thus, x n+1 = x 1 x n + dy 1 y n > x n. Also, x 1 y n > y n and x n y 1 > 0, so y n+1 = x 1 y n + x n y 1 > y n. Therefore, we have x n+1 > x n and y n+1 > y n. We have established that the sequences {x n } and {y n } are strictly increasing when defined according to equation (15). This suggests that if we want the integer powers of (x 1 + y 1 d) to generate all positive integer solutions of x 2 dy 2 = 1, then x 1 and y 1 should be as sall as possible. First, however, we ust answer the question: Does the solution with the sallest value of x also contain the sallest value of y? 3.2 Ordering the Solutions To answer the question posed above, we ust exaine the ordering of the solutions. It turns out that the solution with the sallest value of x does contain the sallest value of y. Specifically, we will prove the following theore: Theore 3. If p, q, r, and s are positive integers for which p > r and then q > s and p + q d > r + s d. p 2 dq 2 = r 2 ds 2 = k (16) Proof. Since p > r and r 1, it follows that p 2 > r 2. We can rewrite equation (16) as p 2 r 2 = d(q 2 s 2 ). Since p 2 r 2 > 0 and d > 0, it follows that q 2 s 2 > 0, and q 2 > s 2. Therefore, q > s. Next, we have p > r and q > s. Since d is positive, q d > s d. It follows that p + q d > r + s d. Therefore, we now define x 1 and y 1 so that both are positive integers and x 1 is the sallest positive integer x satisfying the equation x 2 d 2 = 1. We know fro Theore 3 that y 1 is the sallest positive integer y satisfying the equation, so (x 1, y 1 ) is the sallest positive integer solution to x 2 dy 2 = 1. 11

3.3 Sallest is Fundaental In this section, we will show that any arbitrary positive integer solution of x 2 dy 2 = 1 can be obtained fro the sallest positive integer solution. Specifically, suppose that u > 0, v > 0, and u 2 dv 2 = 1. We will show that there exists a positive integer such that u + v d = (x 1 + y 1 d). Since x 1 is the sallest positive integer satisfying x 2 dy 2 = 1, it ust be true that u x 1. If u > x 1, then by Theore 3, u + v d > x 1 + y 1 d. If u = x1, then clearly v = y 1, and u + v d = x 1 + y 1 d. Therefore, we have u + v d x 1 + y 1 d (17) Next, we will define the positive integer by the condition ) ( (x 1 + y 1 d u + v ) ( ) +1 d < x 1 + y 1 d (18) That is, the th solution generated fro (x 1, y 1 ) is the largest solution not exceeding (u.v). Another way of stating equation (18) is x + y d u + v d < x+1 + y +1 d We will now asseble an iportant inequality in three parts. First, consider (x 1 + y 1 d) : (x 1 + y 1 d) 1 = (x 1 + y (x 1 y 1 d) 1 d) (x 1 y = (x 1 y 1 d) (19) 1 d) (x 2 1 dy1) 2 Since x 2 1 dy 2 1 = 1, the denoinator in (19) is 1, and we have (x 1 + y 1 d) = (x 1 y 1 d) Therefore, (u + v d)(x 1 + y 1 d) = (u + v d)(x 1 y 1 d) Second, the following begins with the left inequality of (18): (x 1 + y 1 d) (u + v d) (x 1 + y 1 d) (x 1 + y 1 d) (u + v d)(x 1 + y 1 d) 1 (u + v d)(x 1 + y 1 d) (20) (21) Third, the following begins with the right inequality of (18): (u + v d) < (x 1 + y 1 d) +1 (u + v d)(x 1 y 1 d) < (x 1 + y 1 d) +1 (x 1 y 1 d) (u + v d)(x 1 y 1 d) < (x 1 + y 1 d) +1 (x 1 + y 1 d) (u + v d)(x 1 y 1 d) < (x 1 + y 1 d) (22) 12

Cobining equation (20) with inequalities (21) and (22), we have the following inequality: 1 (u + v d)(x 1 + y 1 d) = (u + v d)(x 1 y 1 d) < (x 1 + y 1 d) (23) Inequality (23) is key to the rest of the proof. Specifically, we will show that the leftost inequality is in fact an equality. That is, we will show that 1 = (u + v d)(x 1 + y 1 d). 3.4 Define a and b Suppose that a and b are integers deterined by a + b d = (u + v d)(x 1 y 1 d) (24) We will ake three observations. First, we will show that a 2 db 2 = 1. a + b d = (u + v d)(x 1 y 1 d) a + b d = (u + v d)(x y d) a + b d = (ux dvy ) + d(vx uy ) (25) By equation (25), we can see that a 2 db 2 = 1 as follows: a 2 db 2 = (ux dvy ) 2 d(vx uy ) 2 [ = (ux dvy ) + ] [ d(vx uy ) (ux dvy ) ] d(vx uy ) = (u + v d)(x y d)(x + y d)(u v d) = (u 2 dv 2 )(x 2 dy 2 ) = 1 Second, we will show that a b d = (a + b d) 1 > 0. To begin, a 2 db 2 = 1 (a + b d)(a b d) = 1 (26) (a b d) = (a + b d) 1 Fro inequality (23), we know that 1 (u + v d)(x 1 y 1 d). Cobining this with the definition of a + b d fro (24), we see that 1 a + b d which iplies that a + b d is positive. The ultiplicative inverse of a + b d ust also be positive, so fro equation (26), we see (a b d) = (a + b d) 1 > 0. (27) Third, we will show that a b d 1 a + b d. We know fro equation (26) that (a + b d)(a b d) = 1, and we just stated that 1 (a + b d). The ultiplicative inverse of a + b d, which is a b d, ust be less than one. Threrefore, a b d 1 a + b d. (28) 13

This copletes our three observations about a and b. In order for the inequality (28) to hold, b ust be greater than or equal to zero. Here s why: a b d a + b d b d b d 0 2b d 0 b Fro inequality (27), we have a b d > 0 which iplies a > b d. Since b 0, it follows that b d 0, and a > 0. Therefore, we have the following conditions on a and b: a > 0 and b 0. (29) 3.5 Obtain a Contradiction By equation (24) and inequality (22), we have: a + b d = (u + v d)(x 1 y 1 d) < (x 1 + y 1 d) a + b d < x 1 + y 1 d (30) Since a + b d x 1 + y 1 d, then by the contrapositive of Theore 3, a and b are not both positive integers. (Note that everything else in the hypothesis of 3 ust be true: we defined x 1 and y 1 to be positive integers, and we know that a 2 +b 2 d = x 2 1+y 2 1 d = 1. Additionally, if a is positive, a > x 1 since x 1 is the sallest x-value that satisfies x 2 dy 2 = 1 and a x 1 since a = x 1 would iply a + b d = x 1 + y 1 d, which is false.) We know that a > 0 and b 0 fro equation (29). The only way to satisfy these conditions and ake a and b not both positive is to let b = 0. In this case, a = 1 since a 2 db 2 = 1. Therefore, by the defintion of a and b in equation (24), we have a + b d = (u + v d)(x 1 y 1 d) 1 = (u + v d)(x 1 y 1 d) 1 = (u + v d)(x 1 + y 1 d). (31) By equation (31), (u + v d) = (x 1 + y 1 d). We have now proved the following theore: Theore 4. If (x, y) = (u, v) is a positive integer solution of x 2 dy 2 = 1, then there exists a positive integer such that u + v d = (x 1 + y 1 d), where (x 1, y 1 ) is the fundaental solution of x 2 dy 2 = 1. Proof. The proof is contained in section 3.3. 14

4 What About k 1? We have proved the existence of a fundaental solution for equations of the for x 2 dy 2 = 1, but what happens for other values of k? Soeties solutions exist for particular values of d and k, and other ties no solution can be found. With a definition and a theore we can quickly identify any Pell Equations that have no solution at all. 4.1 Identifying Unsolvable Pell Equations Definition 2. An integer a is a quadratic residue odulo if there exists an integer n, 0 < n <, such that n 2 a (od ). If no such integer n exists, then a is a quadratic nonresidue odulo. Theore 5. If k is a quadratic nonresidue odulo d, then the Pell Equation x 2 dy 2 = k has no integer solution. Proof. First, rewrite the Pell Equation as: y 2 = x2 k. (32) d The right-hand side of equation (32) ust be an integer if it is to be a perfect square. This iplies that x 2 k ust be divisible by d, or x 2 k 0 (od d). In other words, x can only be a solution if x 2 k (od d). But this can only happen if k is a quadratic residue odulo d. If k is a quadratic nonresidue odulo d, then no integer x exists such that x 2 k (od d), and there cannot possibly be an integer y that satisfies equation (32). Therefore, the Pell Equation x 2 dy 2 = k has no integer solution if k is a quadratic nonresidue odulo d. Theore 5 can identify Pell Equations for which no integer solution exists. The inverse of Theore 5 is not true. For exaple, 7 1 is a quadratic residue odulo 3, but the equation x 2 3y 2 = 7 does not have an integer solution. 1 Additionally, the proof of Theore 5 can help us search for solutions to a Pell Equation. Suppose we wish to look for a solution to x 2 dy 2 = k by choosing an x-value and checking to see if the corresponding y-value is an integer. Which x-values should we test? Provided that k is a quadratic residue odulo d, the proof above suggests that we should only choose x-values whose square is congruent to k odulo d. Our task is especially easy if d is a prie, say d = p. Since Z p, the set of integers odulo p, is a field, there are exactly two integers in Z p whose squares are congruent to k odulo d. Specifically, if one of these two integers is, the other is p. Therefore, the set of x-values that ake the right-hand side of equation (32) an integer are: {, p, p +, 2p, 2p +, 3p,...} 1 The fact that x 2 3y 2 = 7 has no solution can be verified by considering the integers odulo 4. The only quadratic residues odulo 4 are 0 and 1, so x 2 and y 2 ust each be congruent to either 0 or 1 odulo 4. In this case, x 2 3y 2 will never be congruent to 3 odulo 4. Therefore, x 2 3y 2 7. 15

Our task would then be to test each of these values until we (hopefully) find one that akes (x 2 k)/d a perfect square. 4.2 If k is a Square While the previous section identified any Pell Equations without solutions, we can also identify any Pell Equations with k 1 that have solutions. Consider the following theore: Theore 6. If k is a perfect square, then the Pell Equation x 2 dy 2 = k is solvable in integers for all positive, nonsquare integers d. Proof. Since k is a perfect square, let k = 2. Theore 1 says that the equation x 2 dy 2 = 1 is solvable in integers for all positive, nonsquare integers d. Let (u, v) be a solution, and we have: u 2 dv 2 = 1 (33) Multiply both sides of equation (33) by 2 to obtain: 2 (u 2 dv 2 ) = 1 2 2 u 2 d 2 v 2 = 2 (u) 2 d(v) 2 = k Therefore, (u, v) is a solution to x 2 dy 2 = k where x = 2. We see that beginning with any solution of x 2 dy 2 = 1 we can produce a solution of x 2 dy 2 = k siply by ultiplying our given solution by. In fact, Pell Equations with k square have infinitely any solutions. Pell Equations where k = 1 have infinitely any solutions, each of which corresponds to a solution in the case where k is a square. 5 Investigation of x 2 dy 2 = 4 Having proved that equations of the for x 2 dy 2 = 4 have integer solutions, we will now investigate patterns that occur in such solutions. Since 4 = 2 2, we know by Theore 6 that if (u, v) is a solution of x 2 dy 2 = 1, then (2u, 2v) is a solution of x 2 dy 2 = 4. This ethod of finding solutions obtains only even solutions. Might odd solutions ever exist to Pell Equations with k = 4? The following theore liits the values of d for which odd solutions ight appear: Theore 7. If x 2 dy 2 = 4 can be solved for odd integers x and y, then d 5 (od 8). 16

Proof. Let x and y be odd integers such that x 2 dy 2 = 4. Note that the square of any odd integer is congruent to 1 (od 8), so x 2 y 2 1 (od 8). Therefore, d 5 (od 8). x 2 dy 2 = 4 1 d 4 (od 8) d 3 (od 8) d 5 (od 8) Theore 7 says that if odd solutions exist, then d 5 (od 8), but it does not provide any exaples of odd solutions. We will investigate equations x 2 dy 2 = 4 with d 5 (od 8) to see if odd solutions actually exist. 5.1 Cases when d 5 (od 8) It is not difficult to find odd integers x and y that satisfy an equation of the for x 2 dy 2 = 4 with d 5 (od 8). Considering the case d = 5, we find that the first solution is x = 3, y = 1. The eleven sallest positive integer solutions appear in Table 1. x y 3 1 7 3 18 8 47 21 123 55 322 144 843 377 2207 987 5778 2584 15127 6765 Table 1: Solutions to x 2 5y 2 = 4 Observe in Table 1 that every third solution is even, while the other solutions are odd. Furtherore, the even solutions are those guaranteed by Theore 6; that is, they are twice the integer solutions of x 2 5y 2 = 1. For exaple, (18, 8) is a solution of x 2 5y 2 = 4, and (9, 4) is a solution of x 2 5y 2 = 1. Does this pattern of odd and even solutions continue, and does it exist in the solutions for other Pell Equations with d 5 (od 8) and k = 4? Exaining the solutions to equations with d = 13 and d = 21 (see Tables 2 and 3), we again see the pattern of two odd solutions followed by one even solution. Again, each even solution corresponds to a solution of the equation with k = 1. Why ight this be? 17

x y 11 3 119 33 1298 360 14159 3927 154451 42837 1684802 467280 18378371 5097243 200477279 55602393 2186871698 606529080 Table 2: Solutions to x 2 13y 2 = 4 x y 5 1 23 5 110 24 527 115 2525 551 12098 2640 57965 12649 277727 60605 1330670 290376 6375623 1391275 Table 3: Solutions to x 2 21y 2 = 4 5.2 Odd-Even Solution Patterns In this section, we will use the convention that (x 1, y 1 ) is the sallest positive integer solution to x 2 dy 2 = 4. Suppose that (x n, y n ) satisfies x 2 n dy 2 n = 4 n. Then, (x 2 1 dy 2 1)(x 2 n dy 2 n) = 4 4 n (x 1 + y 1 d)(xn + y n d)(x1 y 1 d)(xn y n d) = 4 n+1 ( (x 1 x n + dy 1 y n ) + (x 1 y n + x n y 1 ) ) ( d (x 1 x n + dy 1 y n ) (x 1 y n + x n y 1 ) ) d = 4 n+1 (x 1 x n + dy 1 y n ) 2 d(x 1 y n + x n y 1 ) 2 = 4 n+1 Therefore, we see that solutions (x n, y n ) of x 2 n dy 2 n = 4 n can be found recursively by x n+1 = x 1 x n + dy 1 y n and y n+1 = x 1 y n + x n y 1. (34) 18

Note that since (x n, y n ) satisfy x 2 n dyn 2 = 4 n, solutions to x 2 dy 2 = 4 are given by y n ) 2. n 1 ( xn, 2 n 1 The following theore, then, explains the pattern of odd and even solutions that we have seen in soe Pell Equations with d 5 (od 8) and k = 4: Theore 8. Suppose that d 5 (od 8) and the sallest positive integer solution of x 2 dy 2 = 4 is (x 1, y 1 ), with x 1 and y 1 both odd. With x n and y n as defined in equation (34), the first solution to be divisible by 2 n occurs at n = 3 and provides a solution of x 2 dy 2 = 1. Proof. First, we have x 2 1 dy 2 1 = 4 with x 1 and y 1 both odd. By equation (34) and the fact that the square of any odd integer is congruent to 1 (od 8), x 2 and y 2 are congruent to: x 2 x 2 1 + 5y 2 1 6 y 2 2x 1 y 1 2 or 6 In either case, x 2 and y 2 contain exactly one factor of two, so we can divide by two and obtain ( ) x 2 2 ( 2 d y2 ) 2 2 = 4, and we have the second odd solution to x 2 dy 2 = 4. Next, x 3 and y 3 are congruent to: x 3 x 1 x 2 + 5y 1 y 2 x 1 (x 2 1 + 5y 2 1) + 5y 1 (2x 1 y 1 ) x 3 1 + 5x 1 y 2 1 + 10x 1 y 2 1 x 1 + 5x 1 + 2x 1 8x 1 0 and y 3 y 1 x 2 + x 1 y 2 y 1 (x 2 1 + 5y 2 1) + x 1 (2x 1 y 1 ) x 2 1y 1 + 5y 3 1 + 2x 2 1y 1 y 1 + 5y 1 + 2y 1 8y 1 0 We see that x 3 and y 3 both contain a factor of 2 3. Thus, we can divide the by 4 to obtain a solution to x 2 dy 2 = 4, or by 8 to obtain a solution to x 2 dy 2 = 1. Furtherore, we can observe that x 3 and y 3 do not both contain factors of 16. If they did, then x 3 /8 and y 3 /8 would both be even, and we would not have a solution of x 2 dy 2 = 1. Since ( ) x 3 2 ( 8 d y3 ) 2 8 = 1, one of x3 and y 3 has a factor of 8 and not 16. The next theore shows that if the initial solution of x 2 dy 2 = 4 is odd, then every third solution corresponds to a solution of x 2 dy 2 = 1. Theore 9. If x n and y n are solutions of x 2 n dy 2 n = 4 n, with d 5 (od 8), and x 1 and y 1 (the sallest such solution) are both odd, and x k and y k satisfy ( xk 2 k ) 2 d ( yk 2 k ) 2 = 1, then x k+3 and y k+3 are the next solution to provide a solution to x 2 dy 2 = 1. 19

Proof. As in the previous proof, we use the recursion defined in equation (34) to obtain successive solutions to x 2 n dy 2 n = 4 n. We obtain the following congruences: x k+1 x 1 x k + 5y 1 y k y k+1 x 1 y k + y 1 x k x k+2 6x k + 2x 1 y 1 y k y k+2 2x 1 x k y 1 + 6y k x k+3 8x 1 x k + 8y 1 y k 0 y k+3 8x k y 1 + 8x 1 y k 0 Since ( ) x k 2 ( 2 d yk ) 2 k 2 = 1, we know that k xk and y k each contain k ultiples of 2, and they do not both contain k + 1 ultiples of 2. With the first iteration, x k+1 and y k+1 both contain exactly k ultiples of 2, providing the odd solution ( x k+1, y ) k+1 2 k 2 to x 2 dy 2 = 4. At the k second iteration, we gain a factor of 2, so x k+2 and y k+2 both contain exactly k + 1 factors of 2, providing a solution to x 2 dy 2 = 4. At the third iteration, the coefficients of 8 indicate that both x k+3 and y k+3 have three ore factors of 2 than x k and y k. We see that x k+3 and 2 y k+3 k+3 are both integers, and they satisfy x 2 dy 2 = 1. Therefore, every third solution of 2 k+3 x 2 dy 2 = 4 is even, and can be divided by two to obtain a solution of x 2 dy 2 = 1. Corollary 1. If x 1 and y 1 are both odd, then x 3i and y 3i always provide a solution to x 2 dy 2 = 1 for any positive integer i. Proof. Theore 8 says that if x 1 and y 1 are both odd, then the first even solution of x 2 dy 2 = 4 is (x 3, y 3 ). Theore 9 says that if (x k, y k ) is an even solution of x 2 dy 2 = 4, then the next even solution is (x k+3, y k+3 ). Therefore, all of the even solutions occur with subscripts that are ultiples of 3. In other words, (x 3i, y 3i ) is always an even solution, so it can be divided by 2 to obtain ( x 3i, ) y 3i 2 2 ), which is a solution of x 2 dy 2 = 1. 5.3 More Patterns in Solutions If we exaine solutions to Pell Equations x 2 dy 2 = 4 for any values of d, d 5 (od 8), we encounter any patterns. Table 4 lists the sallest positive integer solution for the first 30 Pell Equations of this for (5 d 237). First, we observe that for soe values of d, the sallest solution is even. These cases are indicated in bold in Table 4. In these cases, Theores 8 and 9 do not apply, since they require that x 1 and y 1 be odd. The author does not know why the sallest positive integer solution of x 2 dy 2 = 4 is even for soe values of d 5 (od 8), but such values of d appear to be scattered haphazardly through Table 4. Additionally, in these cases, the only solutions to x 2 dy 2 = 4 are those that are twice the solutions to x 2 dy 2 = 1. Notice that each odd integer greater than 1 appears as an x-value in the solution for soe d in the table. Also notice that these odd integers also appear as y-values in the solution for 20

d x y d x y d x y 5 3 1 85 83 9 165 13 1 13 11 3 93 29 3 173 171 13 21 5 1 101 402 40 181 1703027 126585 29 27 5 109 68123 6525 189 110 8 37 146 24 117 11 1 197 786 56 45 7 1 125 123 11 205 43 3 53 51 7 133 173 15 213 73 5 61 1523 195 141 190 16 221 15 1 69 25 3 149 3723 305 229 227 15 77 9 1 157 45371 3621 237 77 5 Table 4: Solutions to x 2 dy 2 = 4 for d 5 (od 8) d following the row in which they appeared as an x-value. We can explain these occurrances by the following two theores: Theore 10. Let be odd and d = 2 4. Then d 5 (od 8) and (x, y) = (, 1) is the solution to x 2 dy 2 = 4. Proof. Since is odd, 2 1 (od 8). Then d = 2 4 3 5 (od 8). Let (x, y) = (, 1), and it follows that: x 2 dy 2 = 2 ( 2 4)(1) 2 = 2 2 + 4 = 4 Therefore, (x, y) = (, 1) is the solution of x 2 dy 2 = 4 with d = 2 4. The previous proof explains why the list of solutions of x 2 dy 2 = 4, d 5 (od 8), contains solutions (, 1) for every odd integer (see Table 4). The next theore explains the solutions ( 2 + 2, ). Theore 11. Let be odd and d = 2 + 4. Then d 5 (od 8) and (x, y) = ( 2 + 2, ) is the solution to x 2 dy 2 = 4. Proof. Since is odd, 2 1 (od 8). Then d = 2 + 4 5 (od 8). Let (x, y) = ( 2 + 2, ), and it follows that: x 2 dy 2 = ( 2 + 2) 2 ( 2 + 4) 2 = 4 + 4 2 + 4 4 4 2 = 4 Therefore, (x, y) = ( 2 + 2, ) is the solution of x 2 dy 2 = 4 with d = 2 + 4. 6 The Fundaental Solution Revisited We will now prove the ost exciting result of our work with x 2 dy 2 = 4. There exists a fundaental solution to x 2 dy 2 = 4, d 5 (od 8) fro which all other solutions can be obtained. This proof is siilar to the proof fro section 3 of the existence of a fundaental solution for equations of the for x 2 dy 2 = 1. 21

6.1 Preliinary Work Fro any solution to x 2 dy 2 = 4, we can obtain another solution as follows. Let (x 1, y 1 ) be a solution. Then, x 2 1 dy 2 1 = 4 (x 1 + y 1 d)(x1 y 1 d) = 4 (x 1 + y 1 d) 2 (x 1 y 1 d) 2 = 4 2 ) ) (x 21 + 2x 1 y 1 d + dy 21 (x 21 2x 1 y 1 d + dy 21 = 4 2 ( (x 2 1 + dy1) 2 + (2x 1 y 1 ) ) ( d (x 2 1 + dy1) 2 (2x 1 y 1 ) ) d = 4 2 ( x 2 1 + dy1) 2 2 d (2x1 y 1 ) 2 = 4 2 ( ) x 2 1 + dy1 2 2 ( ) 2 2x1 y 1 d = 4 2 2 Therefore, for any solution (x 1, y 1 ) of x 2 dy 2 = 4, define x n and y n such that x n + y n d = (x 1 + y 1 d) n 2 n 1. (35) It follows that (x n y n d) = (x 1 y 1 d) n 2 n 1 and x 2 n dy 2 n = 4. Moreover, x n+1 > x n and y n+1 > y n ). As in section 3, this suggests that if x 1 and y 1 are to generate all the other solutions, then they should be as sall as possible. Therefore, we will define (x 1, y 1 ) to be a positive integer solution to x 2 dy 2 = 4, d 5 (od 8), with x 1 as sall as possible. Recall fro Theore 3 that if (p, q) and (r, s) are both positive integer solutions to x 2 dy 2 = 4 and p > r, then q > s and p + q d > r + s d. This helps us order the solutions of x 2 dy 2 = 4, since the solution with the th -sallest x-value also contains the th -sallest y-value. 6.2 An Arbitrary Solution (u, v) Suppose that (u, v) is an arbitrary positive integer solution of x 2 dy 2 = 4. Since x 1 is the sallest positive integer x satisfying x 2 dy 2 = 4, then u x 1. If u > x 1, then u + v d > x 1 + y 1 d by the above paragraph. If u = x1, then clearly v = y 1 and u + v d = x 1 + y 1 d. Therefore, we have u + v d x 1 + y 1 d. As in Section 3, we define the positive integer so that the th solution generated fro (x 1, y 1 ) is the largest not exceeding (u, v). That is, x + y d u + v d < x+1 + y +1 d (x 1 + y 1 d) u + v d < (x 1 + y 1 d) +1 (36) 2 1 2 22

Working with inequality (36): (x 1 + y 1 d) u + v d < (x 1 + y 1 d) +1 2 1 2 (x 1 y 1 d) (x 1 + y 1 d) (u + v d) (x 1 y 1 d) < (x 1 + y 1 d) +1 (x 1 y 1 d) 2 2 1 2 2 2 4 2 (u + v d) (x 1 y 1 d) 4 < (x 2 1 2 1 + y 1 d) 4 2 (u + v d) (x 1 y 1 d) 2 < x 1 + y 1 d (37) Our task is now to show that the left-hand inequality of (37) is, in fact, an equality. 6.3 Define a and b Suppose that a and b are the positive integers deterined by a + b d = (u + v d) (x 1 y 1 d) 2. (38) In Section 3.3, it was obvious that a and b ust be integers, but this tie it is not obvious, since we are dividing by 2. We can prove that a and b ust be integers as follows: a + b d = (u + v d) 1 2 (x 1 y 1 d) 2 1 a + b d = 1 2 (u + v d)(x y d) a + b d = ux dvy 2 + vx uy d 2 Since (u, v) and (x, y ) both satisfy x 2 dy 2 = 4 and d 5 (od 8), u and v have the sae parity, and x and y have the sae parity. If either (u, v) or (x, y ) are even, then (ux dvy, vx uy ) is even. Otherwise, both (u, v) and (x, y ) are both odd, but (ux dvy, vx uy ) is still even. Therefore, a = ux dvy and b = vx uy are both 2 2 integers. 23

Consider a 2 db 2 : ( ) 2 ( ) 2 a 2 db 2 ux dvy vx uy = d 2 2 = 1 ( (ux dvy ) + ) ( d(vx uy ) (ux dvy ) ) d(vx uy ) 4 = 1 ((u + v ) ) d)(x y d) ((x + y d)(u v d) 4 = 1 4 (u2 dv 2 )(x 2 dy 2 ) = 1 4 4 4 = 4 Therefore, x 2 db 2 = 4. Since a 2 db 2 = 4, we have (a b d)(a + b d) = 4, so a + b d and a b d have the sae sign. However, 2 a + b d by inequality (37). Therefore, a + b d and a b d are both positive, and since their product is 4, we have: 0 < a b d 2 and 2 a + b d. (39) We will now show that a ust be positive and b ust be nonnegative. Fro the inequalities in (39), we have: a b d a + b d b d b d 0 2b d 0 b Therefore, b is nonnegative. Since 0 < a b d, we have b d < a, and it follows that 0 b d < a. This iplies that 0 < a, so a is positive. 6.4 Obtain a Contradiction We will now obtain a contradiction to coplete our proof. Cobining the definition of a and b fro equation (38) with inequality (36), we have a+b d < x 1 +y 1 d. This does not satisfy the conclusion of Theore 3, so soething in the hypothesis of the theore ust be false. That is, it cannot be true that a, b, x 1, and y 1 are positive integers for which a 2 db 2 = 4, x 2 1 dy 2 1 = 4, and a > x 1. However, it is true that a 2 db 2 = 4 and x 2 1 dy 2 1 = 4, and a, x 1, and y 1 are positive integers. We know that since a is a positive integer, then a > x 1 by the iniality of x 1. The only possibility is that b is not positive. Therefore, b = 0. 24

Since we previously showed that a 2 db 2 = 4, we now see that a = 2. Thus, we have: However, it is also true that 2 = a + b d 2 = (u + v d) (x 1 y 1 d) 2 4 = (u + v d) (x 1 y 1 d) 2 1. Therefore, it follows that 4 = x 2 dy 2 = (x 1 y 1 d) (x 1 y 1 d). 2 1 2 1 u + v d = (x 1 + y 1 d) 2 1 and we can finally conclude that u + v d = x + y d by the definition of xn + y n d in equation (35). In suary, we have proved the following theore: Theore 12. If (x, y) = (u, v) is a positive integer solution of x 2 dy 2 = 4, with d 5 (od 8), then there exists a positive integer such that u + v d = (x 1 + y 1 d) 2 1 where (x 1, y 1 ) is the fundaental solution of x 2 dy 2 = 4. Proof. The proof is contained in Section 6. Interestingly, the proof of Theore 12 holds for any odd d, though we know fro Theore 7 that if x 2 dy 2 = 4 can be solved for odd integers x and y, then x 5 (od 8). 7 Prograing In order to quickly find solutions to lots of Pell Equations, I wrote a coputer progra. After the user enters values of d and k, y progra checks any integers x in an attept to find one that akes y an integer. My progra is soewhat ore efficient than an exhaustive search that tests all positive integers x; as discussed in Section 4.1, y progra only tests values of x whose square is congruent to k odulo d. Using such an exhaustive search, y progra can quickly solve Pell Equations that have solutions with x less than a few billion. It is true that ore sophisticated ethods exist to find solutions to Pell Equations. One clever ethod is credited to the eleventh-century Indian atheatician Bhaskara and is the subject of a paper I wrote for Senior Math Seinar titled Bhaskara s Method for Solving Pell Equations [4]. The generally accepted ethod for solving Pell Equations today involves continued fractions, but I have not studied it. 25

My progra, PellSolver, has two odes: it can solve a single equation or any equations at once. If the user chooses to solve a single equation, the progra asks for values of d and k, as well as a axiu value of x to test. The progra identifies the Pell Equation as unsolvable if k is a quadratic nonresidue odulo d. Otherwise, the progra tests all values of x whose square is congruent to k odulo d, stopping when it finds an integer solution (x, y) or when x reaches the user-specified axiu. If the search is successful, the progra outputs the sallest positive integer solution to the Pell Equation, as well as the aount of tie it took to find the solution. Solving any equations with a single coand is useful if we wish to investigate patterns in solutions while varying d, k, or both. For exaple, the solutions found to Pell Equations where d 5 (od 8) and k = 4 in Table 4 of Section 5.3 were found using PellSolver. If the user chooses to solve any equations, the progra asks for iniu and axiu values of d. If these values are different, the progra asks for a step by which to increent d to obtain the next equation. For exaple, to solve x 2 dy 2 = 4 for values of d between 5 and 45 with d 5 (od 8), the user would choose d-iniu as 5, d-axiu as 45, and d-step as 8. The progra allows the user to adjust k siilarly, by specifying a inuu, axiu, and a step. Lastly, the progra asks for a axiu value of x as an upper liit to test. For each specified value of k, the progra then attepts to solve x 2 dy 2 = k for each specified value of d. (That is, increenting d and k is accoplished with nested loops, with k being increented in the outer loop and d in the inner loop.) Saple output fro PellSolver follows, with user input in bold: PellSolver Menu: 1. Solve a single equation 2. Solve any equations 3. Quit 1 We will attept to find solutions to equations of the for x^2- dy^2 = k Enter a value for d: 46 Enter a value for k: 1 Enter a ax value for x: 10000000 Solution: x = 24335, y = 3588 found in 0 s PellSolver Menu: 1. Solve a single equation 2. Solve any equations 3. Quit 1 26

We will attept to find solutions to equations of the for x^2- dy^2 = k Enter a value for d: 4 ERROR: d=4 is a perfect square PellSolver Menu: 1. Solve a single equation 2. Solve any equations 3. Quit 2 Enter a in value for d: 50 Enter a ax value for d: 55 Enter a step for d: 1 Enter a in value for k: 1 Enter a ax value for k: 1 Enter a ax value for x: 100000000 x^2-50y^2 = 1 -- Solution: x = 99, y = 14 x^2-51y^2 = 1 -- Solution: x = 50, y = 7 x^2-52y^2 = 1 -- Solution: x = 649, y = 90 x^2-53y^2 = 1 -- Solution: x = 66249, y = 9100 x^2-54y^2 = 1 -- Solution: x = 485, y = 66 x^2-55y^2 = 1 -- Solution: x = 89, y = 12 The search took 70 illiseconds. The Java source code for y progra is included in Appendix A. 27

8 Table of Solutions Table 5 contains the fundaental solutions of the Pell Equations x 2 dy 2 = 1 for nonsquare d < 100. d x y d x y d x y 2 3 2 37 73 12 69 7775 936 3 2 1 38 37 6 70 251 30 5 9 4 39 25 4 71 3480 413 6 5 2 40 19 3 72 17 2 7 8 3 41 2049 320 73 2281249 267000 8 3 1 42 13 2 74 3699 430 10 19 6 43 3482 531 75 26 3 11 10 3 44 199 30 76 57799 6630 12 7 2 45 161 24 77 351 40 13 649 180 46 24335 3588 78 53 6 14 15 4 47 48 7 79 80 9 15 4 1 48 7 1 80 9 1 17 33 8 50 99 14 82 163 18 18 17 4 51 50 7 83 82 9 19 170 39 52 649 90 84 55 6 20 9 2 53 66249 9100 85 285769 30996 21 55 12 54 485 66 86 10405 1122 22 197 42 55 89 12 87 28 3 23 24 5 56 15 2 88 197 21 24 5 1 57 151 20 89 500001 53000 26 51 10 58 19603 2574 90 19 2 27 26 5 59 530 69 91 1574 165 28 127 24 60 31 4 92 1151 120 29 9801 1820 61 1766319049 226153980 93 12151 1260 30 11 2 62 63 8 94 2143295 221064 31 1520 273 63 8 1 95 39 4 32 17 3 65 129 16 96 49 5 33 23 4 66 65 8 97 62809633 6377352 34 35 6 67 48842 5967 98 99 10 35 6 1 68 33 4 99 10 1 Table 5: Fundaental solutions to x 2 dy 2 = 1 for nonsquare d < 100 28

References [1] Barbeau, Edward J. Pell s Equation. Springer, 2000. [2] Pell, John. Dictionary of Scientific Biography. Vol 10, pg 495. New York: Charles Scribner s Sons. [3] Vanden Eynden, Charles. Eleentary Nuber Theory, second edition. McGraw Hill, 2001. [4] Wright, Matthew. Bhaskara s Method for Solving Pell Equations. 2006. 29

A Listing of PellSolver 1 /* class: PellSolver 2 * author: Matthew Wright 3 * date: 3 April 2006 4 * version: 6 5 */ 6 7 iport java.io.*; 8 iport java.ath.*; 9 iport java.util.*; 10 11 class PellSolver 12 { 13 public static void ain(string[] args) throws IOException 14 { 15 boolean repeat = true; 16 while(repeat) 17 { 18 Syste.out.println("PellSolver Menu:\n1. Solve a single equation\n"+ 19 "2. Solve any equations\n3. Quit"); 20 BufferedReader in = new BufferedReader(new InputStreaReader(Syste.in)); 21 int choice = (new Integer(in.readLine())).intValue(); 22 switch(choice) 23 { 24 case 1: solveone(); 25 break; 26 case 2: solvemany(); 27 break; 28 default: repeat = false; 29 } 30 }//end while 31 }//end ain() 32 33 //ethod to solve a single Pell Equation 34 public static void solveone() throws IOException 35 { 36 //variables 37 long ax; 38 boolean debug = false; 39 40 //Objects 41 BufferedReader in = new BufferedReader(new InputStreaReader(Syste.in)); 42 int d, k; 43 44 //get input 45 Syste.out.println("We will attept to find solutions to equations of the for"+ 46 "x^2- dy^2 = k"); 47 Syste.out.println("Enter a value for d: "); 48 d = Integer.parseInt(in.readLine()); 49 30

50 //d cannot be a square 51 if(math.floor(math.sqrt(d)) - Math.sqrt(d) == 0) 52 { 53 Syste.out.println("ERROR: d="+d+" is a perfect square\n\n"); 54 return; 55 } 56 57 Syste.out.println("Enter a value for k: "); 58 k = Integer.parseInt(in.readLine()); 59 Syste.out.println("Enter a ax value for x: "); 60 ax = Long.parseLong(in.readLine()); 61 62 //create a Pell object 63 Pell eq = new Pell(d, k, true); 64 65 //start tier 66 long begintie = Syste.currentTieMillis(); 67 68 //look for a solution 69 Pair solution = null; 70 try 71 { 72 solution = eq.sartsearch(0, ax); 73 } 74 catch(quadraticnonresidueexception e) 75 { 76 Syste.out.println("NO SOLUTION because "+k+" is a quadratic nonresidue od "+d+"\n\n"); 77 } 78 79 //stop tier 80 long tieelapsed = Syste.currentTieMillis() - begintie; 81 82 //do we have a solution? 83 if(solution == null) 84 { 85 Syste.out.println("Max value reached; no solution found in "+tieelapsed+" s\n\n"); 86 } 87 else 88 { 89 Syste.out.println("Solution: x = "+solution.x+", y = "+solution.y+" found in "+ 90 tieelapsed+" s\n\n"); 91 } 92 93 }//end solveone() 94 95 //ethod to solve any Pell Equations 96 public static void solvemany() throws IOException 97 { 98 //variables 99 int d1, //starting value for d 100 d2, //ending value for d 31

101 dd=1, //d step (default is 1) 102 k1, //starting value for k 103 k2, //ending value for k 104 dk=1, //k step (default is 1) 105 ax; //ax value for x 106 107 //use a BufferedReader for input 108 BufferedReader in = new BufferedReader(new InputStreaReader(Syste.in)); 109 110 //input d 111 Syste.out.println("\nEnter a in value for d: "); 112 d1 = Integer.parseInt(in.readLine()); 113 Syste.out.println("Enter a ax value for d: "); 114 d2 = Integer.parseInt(in.readLine()); 115 if(d1!= d2) 116 { 117 Syste.out.println("Enter a step for d: "); 118 dd = Integer.parseInt(in.readLine()); 119 } 120 121 //input k 122 Syste.out.println("Enter a in value for k: "); 123 k1 = Integer.parseInt(in.readLine()); 124 Syste.out.println("Enter a ax value for k: "); 125 k2 = Integer.parseInt(in.readLine()); 126 if(k1!= k2) 127 { 128 Syste.out.println("Enter a step for k: "); 129 dk = Integer.parseInt(in.readLine()); 130 } 131 132 //input ax 133 Syste.out.println("Enter a ax value for x: "); 134 ax = Integer.parseInt(in.readLine()); 135 136 //start tier 137 long begintie = Syste.currentTieMillis(); 138 139 //loop k 140 for(;k1 <= k2; k1+=dk) 141 { 142 //loop d 143 for(int di = d1; di <= d2; di+=dd) 144 { 145 //ake sure d is nonsquare 146 if(math.floor(math.sqrt(di)) - Math.sqrt(di) == 0) 147 { 148 continue; 149 } 150 151 //create a Pell object 32

152 Pell eq = new Pell(di, k1, true); 153 154 //look for a solution 155 Pair solution = null; 156 try 157 { 158 solution = eq.sartsearch(0, ax); 159 //did we find a solution? 160 if(solution == null) 161 { 162 Syste.out.println(eq+"!! Max value reached; no solution found."); 163 } 164 else 165 { 166 Syste.out.println(eq+" -- Solution: x = "+solution.x+", y = "+solution.y); 167 } 168 } 169 catch(quadraticnonresidueexception e) 170 { 171 Syste.out.println(eq+"!! NO SOLUTION because "+k1+ 172 " is a quadratic nonresidue od "+di); 173 } 174 }//end loop d 175 }//end loop k 176 177 //stop tier 178 long tieelapsed = Syste.currentTieMillis() - begintie; 179 Syste.out.println("The search took "+tieelapsed+" illiseconds.\n\n"); 180 }//end solvemany() 181 }//end class PellSolver6 182 183 class Pell 184 { 185 //data ebers 186 int d, k; 187 boolean output; 188 189 //constructor 190 public Pell(int d, int k, boolean o) 191 { 192 this.d = d; 193 this.k = k; 194 this.output = o; 195 } 196 197 //ethod to exhaustively search to find the sallest positive integer solution greater 198 // than start 199 //tests all values of x between start and start + ax 200 //returns null if no solution is found 201 public Pair exhaustivesearch(int start, long ax) 202 { 33