# When is $5n^2+14n+1$ a perfect square?

This specific quadratic came up as part of a puzzle, but the context isn't really important. I just need to find all positive integers $n$, where $5n^2+14n+1$ is a perfect square.

Unfortunately I'm not really a number theorist and I don't know enough "tricks" to make this work out. The only tricks I know are to either (a) recognize this as a Pell equation variant, or (b) represent the quadratic as the sum of two perfect squares, and somehow use Euclid's theorem on Pythagorean triples.

I don't think this is a Pell equation variant, or if it is, I don't see how. When you complete the square you get $5(n+\frac{7}{5})^2 - \frac{44}{5}$ which doesn't seem helpful as the inside of the square isn't an integer.

Similarly I don't see how to see it as a sum of two squares, as 5 is only the sum of two squares in one way -- $1^2+2^2$ -- and then the two squares would have to be of the form $(2n+a)^2 + (n+b)^2$, and so $a^2+b^2=1$, and either $(a,b)=(1,0)$ or $(a,b)=(0,1)$, neither of which work.

So I'm a bit at a loss, and would appreciate any kind of hint.

• squares are certain remainders on division by 8. – user451844 Sep 10 '17 at 22:42
• \begin{align} 5n^2 + 14n + 1 &= \{m^2 : (n, m)\in \mathbb{Z}^+\} \\ \implies 0 &= 5n^2 + 14n + (1 - m^2) \\ \implies n &= \frac{-14 + \sqrt{196 - 20(1 - m^2)}}{10} \\ &= \frac{\sqrt{44 + 5m^2} - 7}{5} \end{align} Now from $1, 2, 3,\ldots$ test for $n$, and if $m$ is an integer, there you go. For example: $$n = 2, \qquad m = 7$$ $$n = 5, \qquad m = 14$$ $$n = 21, \qquad m = 50$$ It is much easier than testing for $n$ via the quadratic form – Mr Pie Sep 11 '17 at 11:50

If you wish to understand this, for example why there are six orbits, i recommend this new book, Weissman, An Illustrated Theory of Numbers, which tells how to draw the Conway topograph.

Your Pell variant comes from $$(5n+7)^2 - 5 m^2 = 44.$$

My program calls it $w^2 - 5 v^2 = 44.$

There are several orbits for this. You want the ones where $w \equiv 2 \pmod 5,$ so they end in a $2$ or a $7.$ There are infinitely many, it will take some time to describe a recurrence. Anyway, given such a $w,$ then take $$n = \frac{w - 7}{5} \; \; .$$

Alright, there are six distinct orbits of successful $w.$ In each case, we get a linear recurrence from

$$\color{blue}{ w_{k+2} = 322 w_{k+1} - w_k}$$ $$(A).....7, \; 1487, \; 478807, \; 154174367,...$$ $$(B).....17, \; 5257, \; 1692737, \; 545056057,...$$ $$(C).....32, \; 10192, \; 3281792, \; 1056726832,...$$ $$(D).....112, \; 36032, \; 11602192, \; 3735869792,...$$ $$(E).....217, \; 69857, \; 22493737, \; 7242913457,...$$ $$(F).....767, \; 246967, \; 79522607, \; 25606032487,...$$

The matching sequences of $n_k$ satisfy

$$\color{blue}{ n_{k+2} = 322 n_{k+1} - n_k + 448}$$ For example, the first orbit of $n$ actually contains $0,$ not positive quite yet: $$(A).....0, \; 296, \; 95760, \; 30834872,...$$ $$(B).....2, \; 1050, \; 338546, \; 109011210,...$$ $$(C).....5, \; 2037, \; 656357, \; 211345365,...$$ $$(D).....21, \; 7205, \; 2320437, \; 747173957,...$$ $$(E).....42, \; 13970, \; 4498746, \; 1448582690,...$$ $$(F).....152, \; 49392, \; 15904520, \; 5121206496,...$$

I ran a separate thing to just report the first 24 values of $n,$ in order rather than six families:

0
2
5
21
42
152

296
1050
2037
7205
13970
49392

95760
338546
656357
2320437
4498746
15904520

30834872
109011210
211345365
747173957
1448582690
5121206496


==========================================================

jagy@phobeusjunior:~$./Pell_Target_Fundamental Automorphism matrix: 9 20 4 9 Automorphism backwards: 9 -20 -4 9 9^2 - 5 4^2 = 1 w^2 - 5 v^2 = 44 Sun Sep 10 15:48:48 PDT 2017 w: 7 v: 1 ratio: 7 SEED KEEP +- w: 8 v: 2 ratio: 4 SEED KEEP +- w: 13 v: 5 ratio: 2.6 SEED KEEP +- w: 17 v: 7 ratio: 2.42857 SEED BACK ONE STEP 13 , -5 w: 32 v: 14 ratio: 2.28571 SEED BACK ONE STEP 8 , -2 w: 43 v: 19 ratio: 2.26316 SEED BACK ONE STEP 7 , -1 w: 83 v: 37 ratio: 2.24324 w: 112 v: 50 ratio: 2.24 w: 217 v: 97 ratio: 2.23711 w: 293 v: 131 ratio: 2.23664 w: 568 v: 254 ratio: 2.23622 w: 767 v: 343 ratio: 2.23615 w: 1487 v: 665 ratio: 2.23609 w: 2008 v: 898 ratio: 2.23608 w: 3893 v: 1741 ratio: 2.23607 w: 5257 v: 2351 ratio: 2.23607 w: 10192 v: 4558 ratio: 2.23607 w: 13763 v: 6155 ratio: 2.23607 w: 26683 v: 11933 ratio: 2.23607 w: 36032 v: 16114 ratio: 2.23607 w: 69857 v: 31241 ratio: 2.23607 w: 94333 v: 42187 ratio: 2.23607 w: 182888 v: 81790 ratio: 2.23607 w: 246967 v: 110447 ratio: 2.23607 w: 478807 v: 214129 ratio: 2.23607 w: 646568 v: 289154 ratio: 2.23607 w: 1253533 v: 560597 ratio: 2.23607 w: 1692737 v: 757015 ratio: 2.23607 w: 3281792 v: 1467662 ratio: 2.23607 w: 4431643 v: 1981891 ratio: 2.23607 w: 8591843 v: 3842389 ratio: 2.23607 w: 11602192 v: 5188658 ratio: 2.23607 w: 22493737 v: 10059505 ratio: 2.23607 w: 30374933 v: 13584083 ratio: 2.23607 w: 58889368 v: 26336126 ratio: 2.23607 w: 79522607 v: 35563591 ratio: 2.23607 Sun Sep 10 15:50:49 PDT 2017 w^2 - 5 v^2 = 44 jagy@phobeusjunior:~$

• Yeah I figured that not too long after I posted that comment; kind of embarrassing. Anyway great answer; I've learned a lot (also for future reference to self and others: the pdf jpr2718.org/pell.pdf contains some useful info on orbits, etc. when you don't have library access for a whole book) – Richard Rast Sep 11 '17 at 1:31

HINT.-Another method is given by the fact that, for example, $$5n^2+14n+1=(2n+1)^2+(n+5)^2-5^2$$ so you want that $$(2n+1)^2+(n+5)^2=5^2+w^2$$

The general solution of the equation $x^2+y^2=z^2+w^2$ is given by the known enough parametrization with four parameters $$x=tX+sY\\y=tY-sX\\z=tX-sY\\w=tY+sX$$

What you have to do if you want to try this way is to submit the arbitrary parameters in the general case to the following restriction:

$$\begin{cases}tX+sY=2n+1\\tY-sX=n+5\\tX-sY=5\end{cases}$$ (This is not immediate!)

• Very interesting -- is there a name for this theorem, or a link to read about it? (That there is a recurrence as you described) – Richard Rast Sep 11 '17 at 1:52
• The proof of this parametrization is very easy. You can see, for example, page 15 in Diophantine Equations by L.J. Mordell. – Piquito Sep 11 '17 at 7:32
• I don't have access to an academic library anymore, so that's not as helpful as you might imagine... I'll take your word for it. – Richard Rast Sep 11 '17 at 10:02
• Let $AB=CD$ $$(a,C)=t\Rightarrow A=tX,\space C=tZ\\(B.D)=s\Rightarrow B=sY,\space D=sW$$ This implies $XY=ZW$. Since $(Y,W)=1$ and $(X,Z)=1$, $X=\pm W,\space Y=\pm Z$ and $$A=tX, \space B=sY,\space C=\pm tY, \space D=\pm sX$$ Writting now from the equation to be solved $(x+z)(x-z)=(w+y)(w-y)$ you can do $$x+z=tX,\space x-z=sY\\w+y=\pm tY,\space w-y=\pm sX$$ You can replace $\pm w=w$ and $\pm y=y$ – Piquito Sep 11 '17 at 17:08

For these equations we use the standard approach. For a private quadratic form: $$Y^2=aX^2+bX+1$$

Using solutions of Pell's equation: $$p^2-as^2=1$$

Solutions can be expressed through them is quite simple.

$$Y=p^2+bps+as^2$$

$$X=2ps+bs^2$$

$p,s$ - these numbers can have any sign.

Finding solutions of equations Pell - standard procedure.