# Are there any integer solutions to $x^2 - (n^2 - 2)y^2 = -1$?

I was just wondering if there are any integer solutions to the Diophantine equation:

$x^2 - (n^2 - 2)y^2 = -1 \ \$ for $n > 2$

I don't think there are any but can't prove why.

-
Sorry! It is meant to be $-1$ not $1$! –  Alex Kite May 25 '12 at 23:08

Note that if $d$ is divisible by a prime $p$ of the form $4k+3$, then the equation $x^2-dy^2\equiv -1$ cannot have a solution, for $x^2\equiv -1\pmod{p}$ does not have a solution.

If $n>2$ is odd, then $n^2-2\equiv -1\pmod{4}$, so $n^2-2$ is divisible by a prime of the form $4k+3$.

If $n$ is divisible by $4$, then again $n^2-2$ is divisible by a prime of the form $4k+3$. But this leaves the possibility $n\equiv 2\pmod{4}$, where $n^2-2$ need not have a prime divisor of the form $4k+3$.

Remark: Will Jagy has settled the problem in general, by observing that the continued fraction of $\sqrt{n^2-2}$ has period $4$. (If $\sqrt{d}$ has continued fraction with even period, then the equation $x^2-dy^2=-1$ has no integer solutions.)

There is an approach that does not use properties of continued fractions, but instead uses basic properties of Pell equations. Note that $x=n^2-1$, $y=n$ is a solution of the Pell equation $x^2-(n^2-2)y^2=1$. If there were solutions of $x^2-(n^2-2)y^2=-1$, there would be a fundamental solution $(a_0,b_0)$, and $(n^2-1,n)$ would be an "even power" of $(a_0,b_0)$, in the sense that $n^2-1+n\sqrt{n^2-2}=(a_0+b_0\sqrt{n^2-2})^{2k}$ for some positive integer $k$. This is not possible, for if $(a_0+b_0\sqrt{n^2-2})^{2k}=a+b\sqrt{n^2-2}$, then $a \ge n^2-1$, and we cannot have equality.

-
Hi, Andre. It follows from the continued fraction. I put in $n=6,14.$ –  Will Jagy May 25 '12 at 23:54
@WillJagy: I did check those two (as you observed, $n=10$ dies since $7$ divides $98$). Maybe the period of the continued fraction can easily be shown to be even in general, but I have not done the calculation. –  André Nicolas May 26 '12 at 0:00
@Iyengar: Thank you very much for pointing out the LaTeX error. –  André Nicolas Jun 26 '12 at 9:12
@AndréNicolas : You are always welcome sir. –  Iyengar Jun 26 '12 at 9:41
@AndréNicolas : Sir my bounty on this question is going to get expired within 3 days. Do you have any suggestions sir ? –  Iyengar Jun 26 '12 at 9:45

This can be a form of Pell's equation if $\,n^2-2\,$ is not a square, and it always has non-trivial solutions with $\,y>0\,$ by a theorem of Lagrange.

-
the OP changed the question. –  Will Jagy May 25 '12 at 23:28
Yeah...a little too late. –  DonAntonio May 26 '12 at 0:31
Just as a matter of interest $n^2 -2$ is never a square when $n$ is an integer, since for positive integers $x >y$, $x^2 - y^2$ is expressible as a sum of distinct odd numbers. –  Geoff Robinson May 26 '12 at 5:44

EDIT: in simple terms, this follows from the fact that the continued fraction for $\sqrt{n^2 -2}$ has period $4,$ with coefficients $$[n-1;1,n-2,1,2n-2]$$

There are no solutions for $$x^2 - (n^2-2)y^2 = -1$$ with $n>2.$The small values of $x^2 - (n^2-2)y^2,$ given by continued fractions or by this, the method of neighboring reduced forms, are $$1, \, 2, \; 3 - 2 n.$$

jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./Pell
Input n for Pell
7

0  form   1 4 -3   delta  -1
1  form   -3 2 2   delta  1
2  form   2 2 -3   delta  -1
3  form   -3 4 1   delta  4
4  form   1 4 -3

disc   28
Automorph, written on right of Gram matrix:
2  9
3  14

Pell automorph
8  21
3  8

Pell unit
8^2 - 7 * 3^2 = 1

=========================================
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$./Pell Input n for Pell 14 0 form 1 6 -5 delta -1 1 form -5 4 2 delta 2 2 form 2 4 -5 delta -1 3 form -5 6 1 delta 6 4 form 1 6 -5 disc 56 Automorph, written on right of Gram matrix: 3 20 4 27 Pell automorph 15 56 4 15 Pell unit 15^2 - 14 * 4^2 = 1 ========================================= jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./Pell
Input n for Pell
23

0  form   1 8 -7   delta  -1
1  form   -7 6 2   delta  3
2  form   2 6 -7   delta  -1
3  form   -7 8 1   delta  8
4  form   1 8 -7

disc   92
Automorph, written on right of Gram matrix:
4  35
5  44

Pell automorph
24  115
5  24

Pell unit
24^2 - 23 * 5^2 = 1

=========================================
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ Since Andre is asking about$n \equiv 2 \pmod 4$when$n^2 -2$may happen to have no prime divisors$q \equiv 3 \pmod 4,$I have also run$n=6,14.$========================================= jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$./Pell Input n for Pell 34 0 form 1 10 -9 delta -1 1 form -9 8 2 delta 4 2 form 2 8 -9 delta -1 3 form -9 10 1 delta 10 4 form 1 10 -9 disc 136 Automorph, written on right of Gram matrix: 5 54 6 65 Pell automorph 35 204 6 35 Pell unit 35^2 - 34 * 6^2 = 1 ========================================= jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./Pell
Input n for Pell
194

0  form   1 26 -25   delta  -1
1  form   -25 24 2   delta  12
2  form   2 24 -25   delta  -1
3  form   -25 26 1   delta  26
4  form   1 26 -25

disc   776
Automorph, written on right of Gram matrix:
13  350
14  377

Pell automorph
195  2716
14  195

Pell unit
195^2 - 194 * 14^2 = 1

=========================================
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ - How is the first one a solution? – DonAntonio May 25 '12 at 23:07 Also$\,\,x=-1\,,\,y=0\,\$ –  DonAntonio May 25 '12 at 23:08
Note that the OP made a mistake in the original post. –  Cameron Buie May 25 '12 at 23:11
Running low on edits. The first few continued fraction convergents are $$n-1, \; n, \; \frac{n^2 - n - 1}{n-1}, \; \frac{n^2 - 1}{n}.$$ Note that we have reached the first nontrivial positive Pell solution with the last one, as $$x = n^2 - 1, \; y = n$$ gives $$x^2 -(n^2 - 2) y^2 = 1.$$ –  Will Jagy May 26 '12 at 0:36
Hmmm. I give a pretty good introduction, including how to do the algorithm in detail, at math.stackexchange.com/questions/90406/… and mathoverflow.net/questions/22811/… –  Will Jagy May 26 '12 at 18:19