# General solution to Pell-like equation y^2 + 2x^2 = n^2

ramsey2879
I discovered the following general solution to primitive forms of y^2 + 2x^2 = a^2
a = 3 + 4n(n+1)
y = 4n(n+1) - 1
x = 4n + 2

Moreover let P = {11, 17, 19, 41, 43 ...} = the set of prime divisors of numbers of the form 3+4n(n+1) without the 3, and let Q = { -1, 7, 17, 23 ...} = the set of prime divisors of numbers of the form 4n(n+1) -1 including the -1. My conjecture is that for any member "p" of set P there is a corresponding member "q" of set Q such that q^2 + 72x^2 = p^2 where x is an interger, e.g.

11^2 = 7^2 + 72*1
17^2 = -1^2 + 72*2^2
19^2 = 17^2 + 72*1
41^2 = 23^2 + 72*4^2
43^2 = 7^2 + 72*5^2
...

Last edited:

Homework Helper
y=1, x=0 and a=1 don't appear to be in that solution set.

ramsey2879
That's true

Homework Helper
there is a complete solution to this already using relative elementary number theory. n^" will be of the form x^2+2y^2 iff and only if n is a product of primes that are all congruent to 1 or 3 mod 8. see eg cox numbers of the form x^2+ny^2 chapter 1.

ramsey2879
matt grime said:
there is a complete solution to this already using relative elementary number theory. n^" will be of the form x^2+2y^2 iff and only if n is a product of primes that are all congruent to 1 or 3 mod 8. see eg cox numbers of the form x^2+ny^2 chapter 1.

OK but my conjecture is more rigid. Do you know if this is discussed in the Cox book titled Primes of the form x^2 + Ny^2.

Homework Helper
your conjecture is wrong. you onlyhave a subest of the primes congruent to 3 mod 8 as possible solutions, thus missing a significant proportion of the answers. you give a sufficient condition for a solution but not a necessary one.

cox does not discuss the x and y associated to a given a.

ramsey2879
ramsey2879 said:
Moreover let P = {11, 17, 19, 41, 43 ...} = the set of prime divisors of numbers of the form 3+4n(n+1) without the 3, and let Q = { -1, 7, 17, 23 ...} = the set of prime divisors of numbers of the form 4n(n+1) -1 including the -1. My conjecture is that for any member "p" of set P there is a corresponding member "q" of set Q such that q^2 + 72x^2 = p^2 where x is an interger, e.g.

11^2 = 7^2 + 72*1
17^2 = -1^2 + 72*2^2
19^2 = 17^2 + 72*1
41^2 = 23^2 + 72*4^2
43^2 = 7^2 + 72*5^2
...
I think you misread my conjecture, I strenthened the wording of it before my last post to avoid such a misreading. As you can see in my list of examples primes in set P include primes of the form 8n+3 and 8n+1 while primes in set Q include primes of the form 8n-1 and 8n + 1. Primes of the form 8n+5 do not appear to be in either subset but that does not contradict Cox.

Note that if a prime P(i) divides 3+4a(a+1) then it divides all instances of 3+4n(n+1) where n equals either a or P(i)-a-1 mod P(i) thus if a prime P(i) is to appear in set P it must appear as a factor of 3 + 4a(a+1) where a < P(i)/2.

17 appears in set P since it divides 51 and 51 = 3+4*3*(3+1)

Similar logic applies to set Q

I restate my conjecture

Let P(i) be a prime in set P, There exists either a prime or -1, Q(i), in set Q such that P(i)^2 - Q(i)^2 = 72n^2 where n is an integer.

Homework Helper
how can it be that i misread it when you changed it? anyway, i don;t know if your conjecture is true (it is a sufficient condition certainly) so why don't you post the proof? off the top of my head i'd say it might be true but i see no compelling evidence for it to be so.

Last edited:
Homework Helper
ramsey2879 said:
Let P(i) be a prime in set P, There exists either a prime or -1, Q(i), in set Q such that P(i)^2 - Q(i)^2 = 72n^2 where n is an integer.

If I understand your P and Q sets, this is false. 379 is prime and 3+4*129*(129+1)=379*177, so 379 is in P. The only solutions to 379^2-q^2=72*n^2 are:

379^2-(379)^2=72*(0)^2
379^2-343^2=72*(19)^2

but 379 is not in Q (can check 4*n*(n+1)-1 is never divisible by 379) nor is 343 (it's not prime).

Homework Helper
soon as you get a sufficiently large list of primes these things tend to happen.

ramsey2879
shmoe said:
If I understand your P and Q sets, this is false. 379 is prime and 3+4*129*(129+1)=379*177, so 379 is in P. The only solutions to 379^2-q^2=72*n^2 are:

379^2-(379)^2=72*(0)^2
379^2-343^2=72*(19)^2

but 379 is not in Q (can check 4*n*(n+1)-1 is never divisible by 379) nor is 343 (it's not prime).

Yes, I did not look far enough. Also p = 113 and 137 are exceptions. However, 113^2 =7^4 + 72*12^2; 137^2= 7^2*17^2 + 72*8^2; and 379^2= 7^6+72*19^2. 7 and 17 are in Q, so my new conjecture is that for every p in P there is a number q that is in Q or is a product of numbers in Q such that p^2-q^2=72*n^2 where n is an integer > 0. This is supported by the facts, since if p and q are odd and not divisible by 3, then p^2-q^2 is divisible by 6. 72= 2*6^2.

Homework Helper
how about, instead of making conjectures based only on small examples, you attempt to prove your statement?

Homework Helper

suppose that 72q^2=2.4.9.q^2=(n-p)(n+p), and we factor the RHS as XY with X>Y, then X-Y=2p. If more than one of the odd primes in the decomps of X and Y occurs in both then we have a contradiction, and if 2 appears with multiplicity greater than 1 in both then we have another contradiction, but 2 must appear in both X and Y. thus we have several cases to consider, but as we only care about an existence one. let's try and pick those that may help.

Take the case where X=2a^2 Y=4b^2 where b is odd, and thus p=a^2-2b^2. We haven't factored in the 3 yet, so let us suppose that the powers of 3 that must occur are factors of b (so replece b with 3c), hence we need to find a and c such that

p=a^2-18b^2
the other variations will lead to similiar. if you can find something about these you will have the answer.

sadly we're not non-positive definite forms here and i know nothing about those.

take another case that where a prime may divide both X and Y say the prime is r, then

X=4ra^2, Y=2r or X=2ra^2 Y=4r etc but this leads to the degenerate case when n=p.

ramsey2879
matt grime said:

suppose that 72q^2=2.4.9.q^2=(n-p)(n+p), and we factor the RHS as XY with X>Y, then X-Y=2p. If more than one of the odd primes in the decomps of X and Y occurs in both then we have a contradiction, and if 2 appears with multiplicity greater than 1 in both then we have another contradiction, but 2 must appear in both X and Y. thus we have several cases to consider, but as we only care about an existence one. let's try and pick those that may help.

Take the case where X=2a^2 Y=4b^2 where b is odd, and thus p=a^2-2b^2. We haven't factored in the 3 yet, so let us suppose that the powers of 3 that must occur are factors of b (so replece b with 3c), hence we need to find a and c such that

p=a^2-18b^2
the other variations will lead to similiar. if you can find something about these you will have the answer.

sadly we're not non-positive definite forms here and i know nothing about those.

take another case that where a prime may divide both X and Y say the prime is r, then

X=4ra^2, Y=2r or X=2ra^2 Y=4r etc but this leads to the degenerate case when n=p.
OK I get the idea. From Cox we know that
p^2 = y^2 + 2x^2 with gcd p,y = 1 (1)
if and only if p is of the form 8n+1 or 8n+3. Note that we must imposed the condition that gcd p,y = 1 or else we could multiply each side of (1) by 25 or 49 to yield a contradiction. Then p and y must have the same parity and both are odd since gcd=1.
We can then make the substitutions v=(p-y)/2 and u=(p+y)/2 which gives
p = u+v and y = u-v (2)
By (1) gcd u,v = 1 since gcd p,y=1
substituting (2) into (1) gives
uv = 2x^2 (3)
now we suppose that x = r*s with the factor s having the requirement of being odd so that p,y can be odd
But since gcd u,v and gcd p,y = 1
u=2r^2, v=s^2, with gcd r,s = 1 (4.1) or
u=s^2, v=2r^2, with gcd r,s = 1 (4.2)
then substituting 4 into 2 then into 1 with the requirement that p,y are odd gives
p = 2s^2 + r^2, y = 2s^2 - r^2, x = 2rs (5.1) or
p = 2s^2 + r^2, y = r^2 - 2s^2, x = 2rs (5.2)

as the general solution of (1)

Thus we know that p^2-y^2 must equal 8r^2s^2
Thus since 3 does not divide p (my condition of this post) and since p and y are both odd all I have to prove is that 3 does not divide y to show that 9 divides either r^2 or s^2.

Thus I need to show that 3 does not divide r^2-2s^2 as well as not dividing r^2+2s^2
1. if 3 divides either r or s then 3 does not divide y since gcd r,s =1
2. if r and s each = +/- 1 mod 3 then p is divisible by 3, this contradicts my conditions. QED

Homework Helper
ramsey2879 said:
OK I get the idea. From Cox we know that
p^2 = y^2 + 2x^2 with gcd p,y = 1 (1)
if and only if p is of the form 8n+1 or 8n+3. Note that we must imposed the condition that gcd p,y = 1 or else we could multiply each side of (1) by 25 or 49 to yield a contradiction.

we impose the restriction to make a primitive solution. if gcd(p,y) weren't 1 then it must be p, hence p divides y, and thus x so we have, after dividing through, that 1=a^2+2b^2, and thus a=1, b=0, which we shall call the degenrate case. p divides x since...

Then p and y must have the same parity and both are odd since gcd=1.

p is odd since it is congruent to 1 or 3 mod 8, it is not the coprimality, personlally i wouldn't cite the gcd as the "cause" of this stuff. the gcd being 1 doesn't force y to be odd: it is because if it were even then y^2+2x^2 would be even too, and hence 2 wolud divide p, but p is an odd prime.

oh, and p as is an odd prime, so if it divided y^2 it would divide 2x^2 and thus x to complete the argument in the last comment. the gcd stuff is always assumed.

We can then make the substitutions v=(p-y)/2 and u=(p+y)/2 which gives
p = u+v and y = u-v (2)
By (1) gcd u,v = 1 since gcd p,y=1
substituting (2) into (1) gives
uv = 2x^2 (3)
now we suppose that x = r*s with the factor s having the requirement of being odd so that p,y can be odd
But since gcd u,v and gcd p,y = 1
u=2r^2, v=s^2, with gcd r,s = 1 (4.1) or
u=s^2, v=2r^2, with gcd r,s = 1 (4.2)
then substituting 4 into 2 then into 1 with the requirement that p,y are odd gives
p = 2s^2 + r^2, y = 2s^2 - r^2, x = 2rs (5.1) or
p = 2s^2 + r^2, y = r^2 - 2s^2, x = 2rs (5.2)

as the general solution of (1)

Thus we know that p^2-y^2 must equal 8r^2s^2

this is all true, if there is a coprime solution

Thus since 3 does not divide p (my condition of this post) and since p and y are both odd all I have to prove is that 3 does not divide y to show that 9 divides either r^2 or s^2.

Thus I need to show that 3 does not divide r^2-2s^2 as well as not dividing r^2+2s^2
1. if 3 divides either r or s then 3 does not divide y since gcd r,s =1
2. if r and s each = +/- 1 mod 3 then p is divisible by 3, this contradicts my conditions. QED

this is all fine, though i don't think it supports your conclusion as is.

let p be congruent to 1 or 3 mod 8, then there are integers r and s such that

p=2r^2+s^2.

let y be 2r^2-s^2 (the sign doesn't matter) then

p^2=y^2+8r^2s^2

then your analysis implies that 3 must divide on of r or s, hence p^2=y^2+72n^2 as required.

no problem with that. but your conjecture is stronger in that it restricts the prime factors of y to be only of a certain kind, and i don't immediately see why that is true. so what is the argument here? we know that y^2 is 1 mod 8, but that doesn't even tell us that y is 1 or -1 mod 8, never mind its prime factors.

Last edited:
ramsey2879
matt grime said:
we impose the restriction to make a primitive solution. if gcd(p,y) weren't 1 then it must be p, hence p divides y, and thus x so we have, after dividing through, that 1=a^2+2b^2, and thus a=1, b=0, which we shall call the degenrate case. p divides x since...

Not only that. p = 11*5, y = 7*5 and x=6*5 would also be solution to p^2=y^2+2x^2 in opposition to the statement that p is a product only of primes of the form 8n+1 and 8n+3

no problem with that. but your conjecture is stronger in that it restricts the prime factors of y to be only of a certain kind, and i don't immediately see why that is true. so what is the argument here? we know that y^2 is 1 mod 8, but that doesn't even tell us that y is 1 or -1 mod 8, never mind its prime factors.

Ok I will work on my proof some more. My conjecture is based upon p being a prime divisor of (2n+1)^2 + 2*1^2 other than 3 and y being a divisor of (2m+1)^2-2*1^2 for some m. Now (2n+1)^2 +2*1 is a valid form for p in the most general solution of p^2 = y^2+2x^2, thus p must be a prime of the form 8n+1 or 8n+3 and also must not be 3. It is easy to show that any divisor of (2m+1)^2-2^1 is not divisible by 3. So what I have left to show is that there is a divisor y of a number of the form (2m+1)^2 - 2 such that p^2=y^2+72n^2 for any prime p of the form 8n+1 or 8n+3 other than 3 .

Returning to the most general solution we have p = 2r^2+s^2 = a prime not divisible by 3 and y = |2r^2-s^2| and x=2rs, s is odd. From my last post either r or s must be divisible by 3 in order for 3 not to divide p. Let r be divisible by 3, then y = 18t^2-s^2. It can easily be shown that s=1 or 5 mod 6. Substitute 6a+1 for s then y=18t^2-36a^2-12a-1. I have to go now