Since the feasible discrete set RealAbs[Sqrt[2] - x / y] < 0.0001
is infinite, this is a hard task for NMaximize
. It can be done as follows. First, we find the maximum for x >= 1000 && y >= 1000
by
NMaximize[{Log[1/y, RealAbs[Sqrt[2] - x/y]],
Element[{x, y}, Integers] && x >= 1000 && y >= 1000 &&
RealAbs[Sqrt[2] - x/y] < 0.0001}, {x, y},Method->{"DifferentialEvolution", "ScalingFactor" ->3}]
which produces {1.51158, {x -> 1649, y -> 1166}}
and a warning
NMaximize::incst: NMaximize was unable to generate any initial points satisfying the inequality constraints {-0.0001+RealAbs[Sqrt[2]-Round[x]/Round[<<1>>]]<=0}. The initial region specified may not contain any feasible points. Changing the initial region or specifying explicit initial points may provide a better solution.
The above result is a feasible solution in view of
N[RealAbs[Sqrt[2] - x/y] /. { x -> 1649, y -> 1166}]
0.0000231443
Second, in order to be sure, we apply the known lower estimate for RealAbs[Sqrt[2] - x/y]
(see the "Liouville numbers and transcendence" section in that Wiki article for info) $$\exists A>0\, \forall\{x,y\}\in\mathbb{N} \left| \sqrt{2}-\frac{x}{y}\right|> \frac A {y^2} $$. According to Lemma from this section, we may take $A=\frac 1 {5}$ ($M=5$). This inequality implies the inequality ForAll[{x,y},{x,y} \[Element] PositiveIntegers && y>1, Log[1/y, RealAbs[Sqrt[2] - x/y]] < Log[1/y, 1/5] + 2]
. It is clear the maximum of Log[1/y, 1/5] + 2]
for all integers y >=1000
is attained at y==1000
and is equal to N[Log[1/1000, 1/5]]==0.23299
.
Third, now we apply counting for x>=1&&x<=999&&y>=2&&y<=999
Do[If[RealAbs[Sqrt[2] - x/y] < 0.0001, Print[{x, y, N[Log[1/y, RealAbs[Sqrt[2] - x/y]]]}]],
{x, 1, 999}, {y, 2, 999}]
{99,70,2.24473} {140,99,2.07542}... {997, 705, 1.59229}
Summarizing the above, we draw the conclusion that the maximum under consideration is equal to 2.224473
at {x==99,y==70}
.
Edit. 1000
in the above instead of 100
and constant $A= \frac 1 5$ instead of $A=\frac 1 3$.