$k^{2}+(k+1)^{2}$ being a perfect square for infinitely many $k$

You can find infinitely many by considering solutions of Pell's equation $ m^2 - 2a^2=-1.$ Your (3,4,5) solution comes from$$(7-5\sqrt{2})(7+5\sqrt{2})=-1,$$ where $m=7$ and $a=5$. For example $$(7-5\sqrt{2})^3$$ yields $$696^2+697^2 = 985^2.$$

Just to make it a bit more clear note that $$\left( {m-1 \over 2} \right)^2 + \left( {m+1 \over 2} \right)^2 = a^2.$$


This is obvious by ascent in the ternary tree of Pythagorean triples. Explicitly, ascent yields this formula:

$\rm (x,x+1,z) \to (X,X+1,Z),\ \ X = 3x+2z+1,\ \ Z = 4x+3z+2\:.\ \ $ For example

$\rm (3,4,5)\to (20, 21, 29)\to (119, 120, 169)\to (696, 697, 985)\to (4059, 4060, 5741)\to\cdots$

This corresponds to always taking the middle branch in the tree, see below

$\qquad\qquad$ enter image description here

The reflection that yields the descent in the triples tree is the following

$\quad\quad (x,y,z)\; \mapsto (x,y,z) - 2 \dfrac{(x,y,z)\cdot(1,1,1)}{(1,1,1)\cdot(1,1,1)} (1,1,1)$

$\quad\quad\quad\quad\quad\quad = (x,y,z) - 2 \; (x+y-z) \; (1,1,1)$

$\quad\quad\quad\quad\quad\quad = (-x-2y+2z, \; -2x-y+2z, \; -2x-2y+3z)$

We ascend the tree by inverting this reflection, combined with trivial sign-changing reflections:

$\quad\quad (-3,+4,5) \mapsto (-3,+4,5) - 2 \; (-3+4-5) \; (1,1,1) = ( 5,12,13)$

$\quad\quad (-3,-4,5) \mapsto (-3,-4,5) - 2 \; (-3-4-5) \; (1,1,1) = (21,20,29)$

$\quad\quad (+3,-4,5) \mapsto (+3,-4,5) - 2 \; (+3-4-5) \; (1,1,1) = (15,8,17)$

Continuing in this way enables one to reflectively generate the entire tree of primitive Pythagorean triples. This has a beautiful geometric interpretation in terms of refelections - see my said MathOverflow post and see here for sums of four squares.


Just to add to Derek's excellent answer,

Pell's equation becomes essential in getting all the solutions to $$k^2 + (k+1)^2 = j^2$$.

Since $gcd(k,k+1) =1 $ we may assume that (by the formula for all primitive pythagorean triples) that

$$m^2 - n^2 = 2mn \pm 1$$

This is a quadratic in $m$ and solving for $m$ gives us

$$ m = n \pm \sqrt{2n^2 \pm 1}$$

Thus any solution of $$k^2 + (k+1)^2 = j^2$$ can be used to get a solution to the equation $$2n^2 \pm 1 = b^2$$ and vice versa.