Number Theory – Conditions for Existence of y with y^2-x^2 and y^2-w^2 Being Squares

diophantine equationselementary-number-theorynumber theorysquare-numbers

Let $(w,x)$ be two integers with $x^2-w^2$ beeing a perfect square. One simple example is $(w,x)=(4,5)$, since $5^2-4^2=9=\square_1=3^2$.

In this case we cannot find a third integer $y$ which satisfies that the differences $y^2-x^2=\square_2$ and $y^2-w^2=\square_3$ are again perfect squares.

A working example would be $(w,x)=(264,520)$ or $(w,x)=(264,561)$, since in both cases an integer $y=1105$ satisfies $y^2-x^2$ and $y^2-w^2$ beeing squares.

My question:
Does there exist a condition on $w,x$ that I may use to quickly check, whether such a third integer $y$ exist? It is quite sufficient (and very helpful) for me if this condition predicts/implies that for given $w,x$ there can be no such $y$.

It would be great, if we could determine this $y$ directly at the same time (although I guess it is almost impossible to obtain $y$ directly without bruteforce).

What I investigated so far:
I searched in various approaches to extract such a condition. For example I found in the paper entitled "Cycles" by R. C. Lyness a condition that produces cycles. For example I could generate:

[[697.   153.   185.   104.   672.   680.  ]
 [697.   705.3  680.   187.2  153.   107.87]
 [697.   491.4  107.87 479.42 705.3  852.81]
 [697.   842.78 852.81 130.43 491.4  473.78]
 [697.   672.   473.78 822.22 842.78 185.  ]
 [697.   153.   185.   104.   672.   680.  ]]

But it seems not to give me a condition that enables me to check whether for two given integers $w<x$ such a third integer $y$ exist. My code for producing Lyness Cycles is given below:

def get_6tuple(tp:list[float]) -> list[float]:
    w = tp[0]
    x = tp[1]
    y = tp[2]
    return [y,w,x,sqrt(x**2-w**2),sqrt(y**2-x**2),sqrt(y**2-w**2)]

def rotate_np(tuple:np.ndarray) -> np.ndarray:
    p = tuple[0]
    v = tuple[4]
    w = tuple[5]
    return [p, np.float(p*w/v), w, np.float(tuple[2]*w/v), tuple[1], np.float(p*tuple[3]/v)]

def generate_cycle_np(triple:np.ndarray) -> np.ndarray:
    res = np.empty((6,6), dtype=np.float)
    tuple = np.array(get_6tuple(triple), dtype=np.float)
    for i in range (0,6):
        res[i]=tuple
        tuple = rotate_np(tuple)
    return res

print(np.array_str(generate_cycle_np([153, 185, 697]), precision=2, suppress_small=True))

Best Answer

For there to be two solutions, the variable $\space y\space$ must have two distinct prime factors of the form $\space 4x+1, x\in\mathbb{N}.\quad$ There will be $\space 2^{f-1}\space$ primitive solutions (those with no common divisors) where $\space f\space $ is the number of such factors. For example, $\space 65=5\times13\space$ so there are $\space 2^{2-1}=2\space $ such solutions. There "can" be $\space 3\space$ solutions but one of those will be imprimitive like your $\space 264,520 \space$ where there are non-primitive solutions for each: $\space(264,448,520)=8\times (33,56,65)\space $ and $\space(520,576,776)=8\times (65,72,97).\qquad $

To "know" there will be $\space 3\space$ solutions we must also "know" there will be $\space 4\space$ solutions. For example, $\space 1105=5\times13\times 17\space$ so there are $\space 2^{3-1}=4\space$ solutions. Note: Wolfram Alpha can find these factors as fast as you can type them here. Wolfram Alpha can also provide a list of primes in a defined range and any product and/or power of these where $\space p=4x+1\space$ is a valid $\space y$-value for your purposes.

To find these solutions, we begin with Euclid's formula for generating triples $\space(A,B,C)\space$ where $\space A^2+B^2=C^2.\quad$ Note: ($y=C\space$ in your case.) $$ A=m^2-k^2,\quad B=2mk,\quad C=m^2+k^2$$ If we solve the $\space C$-function for $\space k\space$ and test a defined range of $\space m$-values, those that yield integers are for valid $\space (m,k)\space$ solutions in the formula.

$$C=m^2+k^2\implies k=\sqrt{C-m^2}\\ \qquad\text{for}\qquad \bigg\lfloor\frac{ 1+\sqrt{2C-1}}{2}\bigg\rfloor \le m \le \big\lfloor\sqrt{C-1}\big\rfloor$$ The lower limit ensures $m>k$ and the upper limit ensures $k\in\mathbb{N}$. $$C=1105\implies \bigg\lfloor\frac{ 1+\sqrt{2210-1}}{2}\bigg\rfloor=24 \le m \le \big\lfloor\sqrt{1105-1}\big\rfloor=33\quad \\ \text{and we find} \quad m\in\{24,31,32,33\}\Rightarrow k\in\{23,12,9,4\}\\$$ $$f(24,23)=(47,1104,1105)\quad f(31,12)=(817,744,1105)\\ f(32,9)=(943,576,1105)\quad f(33,4)=(1073,264,1105)\quad $$