Optimal n-tuple of integers fulfilling certain inequations

61 Views Asked by At

I am trying to find a set of integers $k_1, k_2, ..., k_n$ with $n\ge1$, that produces the minimal difference to a given $m$ (e.g. 1,000 or 1,000,000) in (1):

(1) $\prod_{i=1}^np_i^{k_i} - m \ge 0$ with $p_i$ being the i-th odd prime number (i.e. $p_1=3$),

(2) $log_3m \ge \sum_{i=1}^nk_i$ and

(3) $k_1\ge k_2\ge...\ge k_n\ge1$

Obviously there is always a minimum n-tuple, because n and $k_i$ have an upper limit due to condition (2) and therefore we have a finite set. So far my approach has been to calculate the minimum difference to m in (1) for n = 1, then for n = 2 etc and stop, if an increase in n leads to $k_n = 0$. I was wondering, if there is a better way to approach this problem than my trial and error method. Suggestions are much appreciated.
P.S.: I am not happy with the keyword maxima-minima, so feel free to add a more appropriate keyword.

Edit: I implemented now the suggestion from @ross-milikan, which has a lovely algorithmic structure. Only to avoid problems with accuracy limitations during the computation, I modified the initial approach in (1) to
(4) $\sum_{i=1}^n k_i log_3p_i - log_3m \ge 0$

Thanks for the helpful discussion, Ross.

1

There are 1 best solutions below

3
On BEST ANSWER

I would be surprised if there is a better approach than searching, but here are some thoughts to guide the search. Because the $k_i$ are decreasing your product is a product of things like primorials but skipping $2$. We can define $q_i=k_i-k_{i+1}$ and your product becomes $3^{q_1}15^{q_2}105^{q_3}1155^{q_4}15015^{q_5}255255^{q_6}4849845^{q_7}\ldots$. As these numbers are increasing so rapidly it is easy to find a maximum $n$. Even for $m=10,000,000$ it is obvious we want $n$ no greater than $7$ because $q_1=1,q_7=1$ is much lower than $q_8=1$. Now we can just search downwards, lowering $n$ and seeing if we can improve. If we make $n=6$ we need to multiply $255255$ by about $40$, so $q_1=1,q_2=1,q_6=1$ becomes our new best estimate.

For a range even up to $m$ in the billions there will not be many choices. It wouldn't be hard to just list and sort them, then look up the next one greater than $m$.

I find (if my handwork in a spreadsheet is correct) that there are only $140$ numbers up to $10,000,000$ that are candidates for $m$. The start of a table is shown below. The left column are the values of $m$ that are available. The subsequent columns show the $q_i$ corresponding to each. enter image description here