How can I find the integer solutions to:

$$ x^2=\frac{1}{2} n (n+1) $$

By brute force I have found the solutions (6,8) (35,49) and (204,288) but then it gets harder.

Note that the perfect squares are the sums of the odd natural numbers, whereas the expression on the right is the sum of all natural numbers, so the problem is to find the values where these two sequences intersect.

  • $\begingroup$ See this OEIS for $x$. $\endgroup$ – mathlove Apr 20 '15 at 22:28
  • 2
    $\begingroup$ If this is from a course, have you already covered Pell equations? $\endgroup$ – André Nicolas Apr 20 '15 at 22:37
  • $\begingroup$ you can rewrite the equation as n^2 + n - 2x^2 = 0, which is a quadratic equation in n. The condition is 1+8x^2 = a perfect square. So you can just run through the values of x which make (1+8x^2) a perfect square. By the way (1,1) is also a solution. $\endgroup$ – user25406 Apr 21 '15 at 3:08
  • $\begingroup$ @user25406 Okay, if 6 is the first possible value of x, what is the 24th possible value? Let me know when you finish "running through them". $\endgroup$ – Tyler Durden Apr 21 '15 at 13:44
  • $\begingroup$ 6 is not the first value of x that is a solution to the above equation. x=1 is. Now I can't tell you what the 24th possible value is because my calculator sadly cannot handle large numbers. I can tell you that the only possible values are those for which (1+8x^2) is an odd perfect square. $\endgroup$ – user25406 Apr 22 '15 at 2:24

Rewrite as $2x^2=n^2+n$

Multiply by $4$ to obtain $8x^2=4n^2+4n$

Set $y=2x, z=2n+1$ and confirm $2y^2=z^2-1$ or $z^2-2y^2=1$, which is a Pell Equation. To solve the original problem you need solutions to the Pell equation with $y$ even.

Now note the factorisation $(z+y\sqrt 2)(z-y\sqrt 2)=1$ where the factors differ only in the sign of $\sqrt 2$.

The same is true of $(3+2\sqrt 2)(3-2\sqrt 2)=1$. Note: this is obtained by squaring $(1+\sqrt 2)(1-\sqrt 2)=-1$, but you want solutions for $+1$ only.

Note next that $(z+y\sqrt 2)(3+2\sqrt 2)=(3z+4y)+(2z+3y)\sqrt 2$, and we have $$(3z+4y)^2-2(2z+3y)^2=9z^2+24yz+16y^2-8z^2-24yz-18y^2=z^2-2y^2=1$$

So if $(z,y)$ is a solution of the Pell equation, so is $(3z+4y,2z+3y)$. If $y$ is even, so is $2z+3y$. Given a solution, you can find another.

Using $(z+y\sqrt 2)(3-2\sqrt 2)=(3z-4y)+(3y-2z)\sqrt 2$ you can find descending solutions, which is a help in showing whether you have all the solutions or not.

There is much to learn about Pell Equations and their solutions, but playing with the ideas here (you get two things multiplied together equal to $1$ - such things are called units - and the product of two units is also a unit) will help you when you meet the same ideas in other contexts.


$x^2 - 8y^2 -1 = 0$

by Dario Alejandro Alpern

$X0 = -1$
$Y0 = 0$

and also:
$X0 = 1$
$Y0 = 0$

If $(x,y)$ is a solution, $(-x,-y)$ is also a solution.

$Xn+1 = P Xn + Q Yn$
$Yn+1 = R Xn + S Yn$

P = 3
Q = 8
R = 1
S = 3

  • $\begingroup$ Thanks for the edit iadvd. $\endgroup$ – user25406 Apr 23 '15 at 18:45

As mathlove commented, the answer in terms of a recursion is Sloane sequence 1109:

$$ x = f(n) = 6*f(n-1) - f(n-2) :: f(0)=0, f(1)=1. $$

Once $x$ is known, the triangular numbers which are perfect squares can be computed by the quadratic formula.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.