# When can an odd integer $d$ be represented as $d=a^2-2b^2$ with coprime integers $a,b\$?

I found out that in a primitive pythagorean triple $$a^2+b^2=c^2$$ the difference $d=|a-b|$ (which must be odd) can occur, if and only if we can write $$d=a^2-2b^2$$ with positive coprime integers $a,b$. Moreover, $d$ is a possible difference if and only if $-d$ is a possible difference. We can replace the pair $(a/b)$ by $(a+2b/a+b)$ to get a solution of the desired form.

When can an odd integer $d$ be written as $d=a^2-2b^2$ with positive coprime integers $a,b$ ?

The representation $49=9^2-2\cdot 4^2$ shows that $d$ need not be squarefree.

• I know that this is a pell-type equation but I wonder how we can verify whether a coprime solution exists, this might be harder than to verify whether a solution exists at all. – Peter Jun 25 '18 at 13:22
• This math overflow question answers your question. – Sophie Jun 25 '18 at 13:29
• When a is odd then $d=a^2-2b^2$ is odd. – sirous Jun 25 '18 at 14:09

these are numbers that are not divisible by $4$ or by any prime $q \equiv 3,5 \pmod 8.$ You also are throwing out the single factor of $2$ that would otherwise be allowed.

   1 =  1
7 = 7
17 = 17
23 = 23
31 = 31
41 = 41
47 = 47
49 = 7^2
71 = 71
73 = 73
79 = 79
89 = 89
97 = 97
103 = 103
113 = 113
119 = 7 * 17
127 = 127
137 = 137
151 = 151
161 = 7 * 23
167 = 167
191 = 191
193 = 193
199 = 199
217 = 7 * 31
223 = 223
233 = 233
239 = 239
241 = 241
257 = 257
263 = 263
271 = 271
281 = 281
287 = 7 * 41
289 = 17^2
311 = 311
313 = 313
329 = 7 * 47
337 = 337
343 = 7^3
353 = 353
359 = 359
367 = 367
383 = 383
391 = 17 * 23
401 = 401
409 = 409
431 = 431
433 = 433
439 = 439
449 = 449
457 = 457
463 = 463
479 = 479
487 = 487
497 = 7 * 71
503 = 503
511 = 7 * 73
521 = 521
527 = 17 * 31
529 = 23^2
553 = 7 * 79
569 = 569
577 = 577
593 = 593
599 = 599
601 = 601
607 = 607
617 = 617
623 = 7 * 89
631 = 631
641 = 641
647 = 647
673 = 673
679 = 7 * 97
697 = 17 * 41
713 = 23 * 31
719 = 719
721 = 7 * 103
727 = 727
743 = 743
751 = 751
761 = 761
769 = 769
791 = 7 * 113
799 = 17 * 47
809 = 809
823 = 823
833 = 7^2 * 17
839 = 839
857 = 857
863 = 863
881 = 881
887 = 887
889 = 7 * 127
911 = 911
919 = 919
929 = 929
937 = 937
943 = 23 * 41
953 = 953
959 = 7 * 137
961 = 31^2
967 = 967
977 = 977
983 = 983
991 = 991

• I came to the same result, nevertheless, thank you. Since $d$ must be odd, we can even formulate it simpler : If $d>1$, then all prime factors of $d$ must be of the form $8k\pm 1$. This is also sufficient for the representation, so a pythagorean triple with such a $d$ will actually exist. – Peter Jun 25 '18 at 17:26