Find all infinite sets of integer solutions

133 Views Asked by At

The solution to a math problem that I was working turned out to be the formula $$r + \sqrt{w(2r-w)}$$

My new question became, what are all the possible solutions for $r$ and $w$ where $r$ and $w$ are integers $> 0$ such that the expression yields an integer?

I tried to show that there are infinite solutions for $r$ when $w=2$. $$2(2r-2) = (2n)^2$$ $$2r - 2 = 2n^2$$ $$r-1=n^2$$ $$r=n^2 + 1$$ for when $n > 1$ so that $r > 0$.

For example, when $w=2, n = 6$

$$r = 6^2 + 1 = 37$$ plugging $w$ and $r$ back into the expression yields an integer. $$37 + \sqrt{2(2 \cdot 37 - 2)} = 49$$

I began to realize that there seems to be an infinite amount of integers $r$ for any given $w$. I wrote a program that finds $r$ for any given $w$ and compiled them into a table. I discovered that the set for $r$ can be generated by the function $an^2+bn+c$ where $n$ is an integer $>0$

$$\begin{array}{c|c|c|} \text{w} & \text{r} & \text{a} & \text{b} & \text{c}\\ \hline \text{1} & \{5, 13, 25, 41, 61, 85, 113, 145, ...\} & 2 & 2 & 1 \\ \hline \text{2} & \{5, 10, 17, 26, 37, 50, 65, 82, ...\} & 1 & 2 & 2 \\ \hline \text{3} & \{15, 39, 75, 123, 183, 255, 339, 435, ...\} & 6 & 6 & 3 \\ \hline \text{4} & \{10, 20, 34, 52, 74, 100, 130, 164, ...\} & 2 & 4 & 4 \\ \hline \text{5} & \{25, 65, 125, 205, 305, 425, 565, 725, ...\} & 10 & 10 & 5 \\ \hline \text{6} & \{15, 30, 51, 78, 111, 150, 195, 246, ...\} & 3 & 6 & 6 \\ \hline \text{7} & \{35, 91, 175, 287, 427, 595, 791, 1015, ...\} & 14 & 14 & 7 \\ \hline \text{8} & \{13, 20, 29, 40, 53, 68, 85, 104, ...\} & 1 & 4 & 8 \\ \hline \text{9} & \{17, 29, 45, 65, 89, 117, 149, 185, ...\} & 2 & 6 & 9 \\ \hline \text{10} & \{25, 50, 85, 130, 185, 250, 325, 410, ...\} & 5 & 10 & 10 \\ \hline \end{array}$$

I noticed a pattern in the polynomial generating functions, and attempted to describe it in a piecewise function. Because of my programming background, I am having a difficult time expressing it in math terms. Consider $q(w)$ a function that returns a function in terms of n where $n > 0$ that will generate all possible integer $r$ for a given $w$. The order of the piecewise must be followed from top to bottom, so if 2 is passed as $w$, the piecewise will use the odd power of 2 case before the even case.

$$ q(w) = \begin{cases} 2n^2 + 2n\sqrt{w} + w, & \text{if $w$ is square} \\ n^2 + n \cdot 2^{(log_2(w) + 1)/2} + w, & \text{if $w$ is odd power of 2 (ex. $2^{3}$)} \\ w \cdot q(1), & \text{if $w$ is odd} \\ w / 2 \cdot q(2), & \text{if $w$ is even} \\ \end{cases} $$

For example, $q(25)$ generates $$2n^2 + 2n \sqrt{25} + 25$$ which will yield all $r$ for $w=25$ given any integer $n$ where $n > 0$

For example, choosing $n=12$ (an arbitrary integer $> 0$) yields $$2(12)^2 + 2(12)\cdot 5 + 25 = 433$$

If we plug $w=25$ and $r=433$ into our original expression, it evaluates to an integer: $578$.

From what I can tell, this piecewise function covers all the possible solutions for $r$ and $w$, as checked by a computer program. Of course, I have proved nothing here, and I would like to know how to prove something like this, and I would especially like to know if there is a better way to go about solving this and if there was a simple answer that I missed. Thank you for all replies.

1

There are 1 best solutions below

2
On BEST ANSWER

The following expression:

$$r + \sqrt{w(2r-w)}$$

...is an integer if:

$$w(2r-w)=k^2$$

...which can be written as:

$$(w-r)^2+k^2=r^2$$

So $(w-r)$, $k$ and $r$ must be a Pythagorean triple.

For example:

$$w-r=5,\space k=12,\space r=13\implies w=18$$

$$w-r=3,\space k=4,\space r=5\implies w=8$$

$$w-r=8,\space k=15,\space r=17\implies w=25$$

It's a well known fact that there are infinitely many such triples and you can construct them in as many different ways. You can start with Euclid's formula, for example:

$$w-r=m^2-n^2, \ k = 2mn, \ r=m^2+n^2\implies w=2m^2$$

And your solution will be:

$$r+\sqrt{w(2r-w)}=m^2+n^2+\sqrt{2m^2(2(m^2+n^2)-2m^2)}=(m+n)^2$$