Brute Force for solving Diophantine equation

In version 10.1 on my circa 2011 PC:

AbsoluteTiming[
 M = 2000;
 r = Range[0, M];
 xx = 2`^r;
 yy = -(5`^r);
 grid = # + yy & /@ xx;
 Position[Round@grid, 3] - 1
]
{3.3214, {{2, 0}, {3, 1}, {7, 3}}}

By luck it seems in this instance Round isn't actually needed:

AbsoluteTiming[
 M = 2000;
 r = Range[0, M];
 xx = 2`^r;
 yy = -(5`^r);
 grid = # + yy & /@ xx;
 Position[grid, 3`] - 1
]
{1.70207, {{2, 0}, {3, 1}, {7, 3}}}

If actual "brute force" is not the goal, then perhaps:

RepeatedTiming[
  M = 2000;
  r = Range[0, M];
  sol = 2`^r ⋂ 5`^r + 3
]

x -> Log[2, sol]
y -> Log[5, sol - 3]
{0.00485, {4., 8., 128.}}

x -> {2., 3., 7.}

y -> {0., 1., 3.}

Maybe double loop is not necessary:

Reap[Do[If[IntegerQ[Log[2, 5^y + 3]], Sow[y]], {y, 100000}]]

Takes around 12 seconds.


This is an incomplete answer to a question that was not asked. One can show that there are no solutions in intervals in a way that is much faster than exhaustive search. I'll give the general idea but I'm not going to make a rigorous proof.

First we rewrite by taking the base-2 logarithms of both sides.

x = log_2(5^y+3) = log_2(5^y (1+3/5^y)) = y log_2(5) + 3/log(2) 5^(-y) + O(5^(-2*y)) (which assumes y>=1)

Since x is an integer we require thaty times the base-2 log of 5 be "close" to an integer, for integer-valued y. The place to look for candidates is the denominators of the convergents of continued fraction approximations to log_2(5).

In[1]:= cc = Convergents[ContinuedFraction[N@Log[2, 5]]]

(* Out[1]= {2, 7/3, 65/28, 137/59, 339/146, 1493/643, 9297/4004, \
20087/8651, 29384/12655, 49471/21306, 177797/76573, 227268/97879, \
4268621/1838395, 4495889/1936274, 31243955/13456039, \
35739844/15392313} *)

We already know that y=1 and y=3 give valid solutions. Let's suppose we checked by brute force that there are no solutions for y between 4 and 28. The next "good" candidate value is y=59. Well, in principle maybe some other value between 29 and 58 would work? Here is what we know from the convergents list. The fraction 137/59 is closer to log_2(5) than any other rational with denominator no larger than 59. So let's check how close it is.

In[2]:= N[137/59 - Log[2, 5], 20]

(* Out[2]= 0.00010580341772239789239 *)

So it is around 10^(-4) away. If y is in the range {29,59} then the first correction term is far smaller than this, since it is bounded below by 3/log(2)*5^(-29):

In[3]:= N[3/Log[2] 5^(-29), 20]

(* Out[3]= 2.3236230070198052257*10^-20 *)

What this shows is that no value for y in the range {29,30,...,59} will give an integer value for log_2(5^y+3). One can handle successive ranges by moving from one denominator to the next. For example, the maximum value our first-order correction gives in the ninth such interval is far to small to make up the difference between the closest rational approximation and log_2(5) with suitably bounded denominator in that interval.

{d9, d10} = Denominator /@ cc[[9 ;; 10]]
minDistToInteger9 = N[cc[[10]] - Log[2, 5], 20]
maxAvaliableInInterval9 = N[3/Log[2] 5^(-d9), 20]

(* Out[7]= {12655, 21306}

Out[8]= 4.8483327777503868560*10^-10

Out[9]= 1.4821457784228658814*10^-8845 *)

My guess is that there are no more solutions besides the ones already found. But I have no idea how one might prove that.