Algorithm for coefficients in an ascending linear sum

26 Views Asked by At

I want to create a monotonically increasing sequence where each element of the sequence is the linear sum of a given finite set of positive irrational numbers. As a concrete example, consider the set $\{\sqrt{2}, \sqrt{3}, \sqrt{5}\}$ and the linear sum $s = \beta_1 \sqrt{2} + \beta_2 \sqrt{3} + \beta_3 \sqrt{5}$ . The sequence I want is: $$ 0 \times\sqrt{2} + 0 \times \sqrt{3} + 0 \times \sqrt{5} = 0\\ 1 \times\sqrt{2} + 0 \times \sqrt{3} + 0 \times \sqrt{5} \approx 1.41\\ 0 \times\sqrt{2} + 1 \times \sqrt{3} + 0 \times \sqrt{5} \approx 1.73\\ 0 \times\sqrt{2} + 0 \times \sqrt{3} + 1 \times \sqrt{5} \approx 2.24\\ 2 \times\sqrt{2} + 0 \times \sqrt{3} + 0 \times \sqrt{5} \approx 2.82\\ 1 \times\sqrt{2} + 1 \times \sqrt{3} + 0 \times \sqrt{5} \approx 3.15\\ 0 \times\sqrt{2} + 2 \times \sqrt{3} + 0 \times \sqrt{5} \approx 3.46\\ 1 \times\sqrt{2} + 0 \times \sqrt{3} + 1 \times \sqrt{5} \approx 3.65\\ 0 \times\sqrt{2} + 1 \times \sqrt{3} + 1 \times \sqrt{5} \approx 3.97\\ 0 \times\sqrt{2} + 0 \times \sqrt{3} + 2 \times \sqrt{5} \approx 4.47\\ 2 \times\sqrt{2} + 1 \times \sqrt{3} + 0 \times \sqrt{5} \approx 4.56\\ 1 \times\sqrt{2} + 2 \times \sqrt{3} + 0 \times \sqrt{5} \approx 4.88, $$ that particular sequence having been derived by trial and error!

Given a set of positive irrationals $\{n_1, n_2, \ldots , n_j\}$, is there a simple algorithm for generating successive integer $\beta_1, \beta_2, \ldots, \beta_j$, so that the sum $\beta_1 n_1 + \beta_2 n_2 + \ldots + \beta_j n_j$ forms a complete ascending sequence; that is, a sequence that doesn't skip any allowable sum.

I'm neither a mathematician nor a computer scientist but on the face of it, this problem seems to have some similar elements to the Knapsack Problem. If that's so, there might not be a guaranteed perfect algorithm other than an exhaustive search (over a limited range), but there might nonetheless be a very good (approximate) algorithm ... and I'd like to know what it is!

1

There are 1 best solutions below

0
On

Build a list of linear sums, starting from the coefficients $(0,0,0)\to0$. For every irrational, scan the list backwards to find the smallest element such that if you add that irrational to it, the sum exceeds the bottom of the list. This gives you $j$ candidates and you pick the smallest.

E.g.

Initially

$$0\sqrt2+0\sqrt3+0\sqrt5$$

and the next candidates are

$$\color{green}1\sqrt2+0\sqrt3+0\sqrt5, 0\sqrt2+\color{green}1\sqrt3+0\sqrt5,0\sqrt2+0\sqrt3+\color{green}1\sqrt5.$$

Obviously, the new list is

$$0\sqrt2+0\sqrt3+0\sqrt5\\\color{green}1\sqrt2+0\sqrt3+0\sqrt5$$

The next candidates are

$$\color{green}2\sqrt2+0\sqrt3+0\sqrt5,0\sqrt2+\color{green}1\sqrt3+0\sqrt5,0\sqrt2+0\sqrt3+\color{green}1\sqrt5.$$

The list becomes

$$0\sqrt2+0\sqrt3+0\sqrt5\\1\sqrt2+0\sqrt3+0\sqrt5\\0\sqrt2+\color{green}1\sqrt3+0\sqrt5$$

and so on.


In fact the implementation is easy: you keep a list of $j$ candidates, each being a tuple of multiplicities. Repeatedly, you pick the smallest sum and increment the multiplicity of the corresponding irrational.