# Integer Solutions of the Equation $u^3 = r^2-s^2$

The question says the following:

Find all primitive Pythagorean Triangles $$x^2+y^2 = z^2$$ such that $$x$$ is a perfect cube.

The general solution for each variable are the following: $$x=r^2-s^2$$ $$y=2rs$$ $$z=r^2+s^2$$ such that $$\gcd(r,s) = 1$$and $$r+s \equiv 1 \pmod {2}$$

In order to make $$x$$ a perfect cube, I shall have the equation $$x=u^3=r^2-s^2$$. However, I am stuck to find a general formula for such cubes.

I know that a subset of the solutions might be the difference between two consecutive squares. This difference is always an odd integer. I can collect some examples such $$14^2-13^2 = 27$$ but I cannot give a formula for such type either.

Any ideas?

• Any cube can be represented by a difference of squares. $$x^3=(y-z)(y+z)$$ – individ Dec 19 '18 at 15:06
• One general class of solutions is given by $r=\frac{u^2+u}{2}$ and $s=\frac{u^2-u}{2}$, but I am fairly sure this is not an exhaustive solution set. – Frpzzd Dec 19 '18 at 15:06
• @individ let $y = 5, z= 1$, then $4*6=24$ which is not a cube. My point is that when will $(y-z)(y+z)$ is a cube? – Maged Saeed Dec 19 '18 at 15:10
• @MagedSaeed Write $u^3=(r-s)(r+s)$. Since $r+s$ and $r-s$ must have the same parity, and $u$ and $u^2$ must have the same parity, we may let $u=r-s$ and $u^2=r+s$. The same can be done for any two divisors of $u^3$ that have the same parity. – Frpzzd Dec 19 '18 at 15:18
• Maged, I'm sure individ meant that if you can write down a factorization, any factorization will do, $u^3=ab$ such that $a$ and $b$ have the same parity, then you can solve for $y$ and $z$ from the system $a=y-z$, $b=y+z$. The choice $a=x$, $b=x^2$ gives you the solution Frpzzd provided. – Jyrki Lahtonen Dec 19 '18 at 15:19

$$u^3=(r+s)(r-s)$$ and $$\gcd(r+s,r-s)=1$$, so $$r+s$$ and $$r-s$$ are odd, coprime perfect cubes.

So let $$r+s=a^3$$, $$r-s=b^3$$. Then $$r=\frac{a^3+b^3}2$$ $$s=\frac{a^3-b^3}2$$ where $$a$$ and $$b$$ are odd and coprime.

Conversely, if $$a$$ and $$b$$ are odd and coprime, let $$r=(a^3+b^3)/2$$ and $$s=(a^3-b^3)/2$$, which are coprime and have different parity. Indeed, $$r+s=a^3$$ which is odd and coprime with $$r-s=b^3$$

• That is what I was looking for. I just have scratched this on a paper and immediately found it as an answer of yours. :) – Maged Saeed Dec 19 '18 at 15:23

I assume you are allowing $$u,r,s$$ to be negative.

Let us substitute $$r-s=a$$ so that your equation is equivalent to $$u^3=a(a+2s)$$ thus, if $$u^3$$ can be written in the form $$u^3=xy$$ where $$x\equiv y \pmod 2$$, then we may let $$a=x$$ and $$a+2s=y$$, and solve an easy system of equations obtain values for $$r$$ and $$s$$.

Thus, if $$u^3=xy$$ and $$x\equiv y \pmod 2$$, then $$r=\frac{x+y}{2}$$ and $$s=\frac{x-y}{2}$$ is a possible solution.

Let's try and find the number of solutions $$(r,s)$$ given the value of $$u^3$$. Each solution $$(r,s)$$ can be put into one-to-one correspondence with a pair $$(x,y)$$ satisfying $$u^3=xy$$ and $$x\equiv y \pmod 2$$. If $$u$$ is even, there are $$(v_2(u^3)-1)d_o(u^3)$$ such pairs, and if $$u$$ is odd, there are $$d_o(u^3)$$ such pairs (where $$v_2(u^3)$$ is the 2-adic valuation of $$u^3$$ and $$d_o(u^3)$$ is the number of odd divisors of $$u^3$$), which can be easily proven by "dividing up" the factors of $$2$$ in $$u^3$$ between $$x$$ and $$y$$.

Thus, given $$u^3$$, there are $$d_o(u^3)$$ solutions if $$u$$ is odd and $$(v_2(u^3)-1)d_o(u^3)$$ solutions if $$u$$ is even.

• Thanks, but this did not give explicit formulas for $r$ and $s$. – Maged Saeed Dec 19 '18 at 15:26

$$1^2=1^3$$
$$3^2=(1+2)^2=1^3+2^3$$
$$6^2=(1+2+3)^2=1^3+2^3+3^3$$
...
The difference between two consecutive squares on the left will give you a cube:
$$1^3=1^2-0^2$$
$$2^3=3^2-1^2$$
$$3^3=6^2-3^2$$ ...
Which means the solutions are pairs of this form: $$(\frac{n(n-1)}{2}, \frac{n(n+1)}{2})$$
$$1^3=1^2-0^2$$
$$2^3=3^2-1^2$$
$$3^3=6^2-3^2$$
...

• Oh, this is nice and brilliant! – Maged Saeed Dec 19 '18 at 15:50

In this part of the discussion, we will sometimes refer to $$A,B,C$$ instead of $$x,y,z$$ and we will look for triples where $$A$$ is an $$even$$ cube such that $$A^2=x^3=C^2-B^2$$. It is convenient to be able to find a triple for every pair of natural numbers and we can do so if we vary the standard formula to have an effect similar to $$(m,n)=(2n+k-1,k)$$. We can then find the desired triples with: $$A=2n^2-2n+4nk$$ $$B=2n(2k-1)+(2k-1)^2$$ $$C=2n^2+2n(2k-1)+(2k-1)^2$$ In these functions, $$n$$ is a set number and $$k$$ is the member number within that set. It is easy to find these triples in a spreadsheet where one column is dedicated to testing if the cube root of $$A$$ is an integer. Here are primitives ($$A^2+B^2=C^2\land GCD(A,B,C)=1$$) where each f(n,k) is a triple from sets $$1$$ thru $$50$$ and member numbers up to $$300$$.

$$f(1,2)=8,15,17$$ $$f(1,16)=64,1023,1025$$ $$f(1,54)=216,11663,11665$$ $$f(1,128)=512,65535,65537$$ $$f(1,250)=1000,249999,250001$$ $$f(4,12)=216,713,745$$ $$f(4,61)=1000,15609,15641$$ $$f(4,170)=2744,117633,117665$$ $$f(27,3)=1728,295,1753$$ $$f(27,115)=13824,64807,66265$$ $$f(27,237)=27000,249271,250729$$ $$f(32,47)=8000,14601,16649$$ $$f(32,156)=21952,116625,118673$$

We can do the same for side $$A$$ odd if we let A,B,C be: $$A=(2n-1)^2+2(2n-1)k$$ $$B=2(2n-1)k+2 k^2$$ $$C=(2n-1)^2+2(2n-1)k+2k^2$$ There are an infinite number of these triples for side $$A$$ odd because the function for $$A$$ generates ever odd number $$>1$$. In a casual search, the primitives appear to be confined to $$Set_1$$ but this is not proven. Here are examples from $$k=1$$ to $$k=2000$$: $$f(1,13)=27,364,365$$ $$f(1,62)=125,7812,7813$$ $$f(1,171)=343,58824,58825$$ $$f(1,364)=729,265720,265721$$ $$f(1,665)=1331,885780,885781$$ $$f(1,1098)=2197,2413404,2413405$$ $$f(1,1687)=3375,5695312,5695313$$