# Finding triangular numbers that are also pentagonal

Problem: Find a general form for numbers that are both triangular and pentagonal

So far

The formula for the nth s-sided polygonal number is $k(s, n) = (s-2)(n (n-1))/2 + n$

Which gives forumla for triangular numbers $n(n+1)/2$ and pentagonal numbers $n(3n-1)/2$

Equating these $$x(x+1)/2 = y(3y-1)/2$$

$$x^2 + x + y - 3y^2$$

So I want integer solutions to this equation. I figured completing the squares so there is only one instance of x and y would make this easier to approach

$$(x + 1/2)^2 - 1/4 + y - 3y^2 = 0$$

$$(x + 1/2)^2 -3(y - 1/6)^2 - 1/6 = 0$$

This is the point I am stuck at. What direction should I go next? Have I made any mistakes with my reasoning so far?

There are a number of steps. The outcome is $$x_n = 0, 1, 20, 285, 3976, ...$$ $$y_n = 0, 1, 12, 165, 2296, ...$$ obeying $$\color{blue}{ x_{n+2} = 14 x_{n+1} - x_n + 6,}$$ $$\color{blue}{ y_{n+2} = 14 y_{n+1} - y_n -2.}$$ It took a while, but the recurrence for $x_n$ does give, eventually, the recurrence for the actual numbers, $0, 1, 210, 40755, 7906276, 1533776805,$ in that $$\color{blue}{ TP_{n+2} = 194 \, TP_{n+1} - TP_n + 16.}$$

some of the middle ground is completing the square twice, giving $$(6y-1)^2 - 3 (2x+1)^2 = -2,$$ or Pell type $$u^2 - 3 v^2 = -2.$$ As $2$ is prime, there is not much of a mess,

jagy@phobeusjunior:~$./Pell_Target_Fundamental Automorphism matrix: 2 3 1 2 Automorphism backwards: 2 -3 -1 2 2^2 - 3 1^2 = 1 u^2 - 3 v^2 = -2 Mon Feb 27 10:14:53 PST 2017 u: -1 v: 1 ratio: 1 u: 1 v: 1 ratio: 1 SEED KEEP +- u: 5 v: 3 ratio: 1.66667 u: 19 v: 11 ratio: 1.72727 u: 71 v: 41 ratio: 1.73171 u: 265 v: 153 ratio: 1.73203 u: 989 v: 571 ratio: 1.73205 u: 3691 v: 2131 ratio: 1.73205 u: 13775 v: 7953 ratio: 1.73205 u: 51409 v: 29681 ratio: 1.73205 u: 191861 v: 110771 ratio: 1.73205 u: 716035 v: 413403 ratio: 1.73205 u: 2672279 v: 1542841 ratio: 1.73205 u: 9973081 v: 5757961 ratio: 1.73205 u: 37220045 v: 21489003 ratio: 1.73205 Mon Feb 27 10:15:53 PST 2017 u^2 - 3 v^2 = -2 jagy@phobeusjunior:~$


This worked out nicely, https://oeis.org/A014979

Let's see, the "automorphism matrix" says that, given a solution $(u,v)$ to $u^2 - 3 v^2 = -2,$ the very next one is $$(2u+3v, u + 2v).$$ Howeve, we need to take every other solution to get $u \equiv -1 \pmod 6.$ That is, given a solution $(p,q)$ to $p^2 - q v^2 = -2,$ two solutions on is $$(7p+12q, 4p + 7q).$$ The matrix $$\left( \begin{array}{rr} 7 & 12 \\ 4 & 7 \end{array} \right)$$ has trace $14$ and determinant $1,$ so Cayley Hamilton says $$p_{n+2} = 14 p_{n+1} - p_n,$$ $$q_{n+2} = 14 q_{n+1} - q_n.$$ We have chosen solutions $$p_n = -1, 5, 71, 989, 13775, 191861,$$ $$q_n = 1, 3, 41, 571, 7953, 110771,$$ after which $x = (q-1)/2,$ $y = (p + 1)/6$

• Have you missed half the solutions ? $(p,q)=(1,1),(5,3),(19,11),\cdots$ ... should the recurrence be $p_n=4p_{n-1}-p_{n-2}$ ? I found it could be more easily derived & explained by looking at the continued fraction for root 3. – Donald Splutterwit Feb 27 '17 at 20:09
• @DonaldSplutterwit I left out half the solutions on purpose, as the original problem uses only numbers $5 \pmod 6.$ Put another way, the Pell equation is happy to use negative numbers, but the original problem does not allow those – Will Jagy Feb 27 '17 at 20:16
• My bad, they are solutions of the Pell equations BUT they do not give whole number solutions to the original problem. – Donald Splutterwit Feb 27 '17 at 20:23

$$y(3y-1)=x(x+1)$$

Using the first solution. $(p;s) - (2;1)$ Others will find the formula.

$$p_2=2p+3s$$

$$s_2=p+2s$$

The solution will have the form.

$$y=p^2-3ps+2s^2$$

$$x=p^2-5ps+6s^2$$

Or.

$$y=s(p-s)$$

$$x=s(3s-p)$$