Homepage › Solution manuals › Ivan Niven › An Introduction to the Theory of Numbers › Exercise 3.6.4 (Find integers $x$ and $y$ such that $x^2 + y^2 = 89753$)
Exercise 3.6.4 (Find integers $x$ and $y$ such that $x^2 + y^2 = 89753$)
Use the method of Example 3 to find integers and such that , given that this number is prime.
Answers
Proof. Put . Since ,
so is a nonresidue modulo .
Let be the unique integer such that and . By fast exponentiation, we obtain
(With Sage,
sage: p = 89753 sage: is_prime(p) True sage: kronecker(2,p) 1 sage: kronecker(3,p) -1 sage: Mod(3,p)^((p-1)//4) 18750 )
Then
So , where , so that , which means that the form
has discriminant , so is properly equivalent to . There is a matrix such that . I keep track of in the algorithm to reduce , so that is the form in the same line.
We obtain
| Operation | G | |||
| 89753 | 37500 | 3917 | I | |
| 3917 | - 37500 | 89753 | ||
| 3917 | 1670 | 178 | ||
| 178 | -1670 | 3917 | ||
| 178 | 110 | 17 | ||
| 17 | -110 | 178 | ||
| 17 | -8 | 1 | ||
| 1 | 8 | 17 | ||
| 1 | 0 | 1 | ||
The last line means that
(and ). Thus
Therefore
thus
so
□
We can code the reduction in Sage with
def is_reduced(a,b,c): """ is q = (a, b, c) reduced ? (D < 0) """ if not(abs(b) <= a and a <= c): return False if abs(b) == a or a == c: return b >= 0 return True def reduce(q, verbose = 0): a, b, c = q G = Matrix([[1,0],[0,1]]) liste = [] while not is_reduced(a, b, c): if c < a: (a, b, c) = (c, -b, a) A = Matrix([[0, 1],[-1, 0]]) elif abs(b) > a or -b == a: k = (a - b) // (2 * a) c = a * k * k + b * k + c b = b + 2 * k * a A = Matrix([[1, k ],[0, 1]]) G = G * A liste.append(A) if verbose: print(’A = ’); print(A) print(’G = ’); print(G) print(’f.G = ’); print(a,b,c) return (a, b, c), G, liste f = (89753, 37500, 3917) (a,b,c), G, liste = reduce(f) (a,b,c) (1,0,1) G
liste
To obtain details:
reduce(f, verbose = 1)
(This gives the preceding array)
We can write these procedures in pure Python if we write a python class of matrices with the usual operations. It is easy to add a procedure that compute such that .
Try with the primes