# Finding all solutions in the Roth's theorem

Roth's theorem. For all algebraic irrational $\alpha$ $$\displaystyle \left \lvert \alpha - \frac{p}{q} \right \rvert < \frac{1}{q^{2 + \epsilon}}$$ with $\epsilon>0$, has finitely many solutions.

How to find all solution for $\alpha=\sqrt{2}$ and $\epsilon=1$

I tried:

FindInstance[{Abs[Sqrt - p/q] < 1/q^3, GCD[p, q] == 1}, {p,q}, Integers]


but there is an error message FindInstance does not handle GCD so well so leave it out and try:

FindInstance[{Abs[Sqrt - p/q] < 1/q^3}, {p, q}, Integers, 5]

(*{{p -> 1, q -> 1}, {p -> 2, q -> 1}, {p -> 3, q -> 2}}*)


3 answers are better than none. You can always do some post processing cleanup to weed out bad solutions but in this case there are none.

• Hi;To the downvoter, what did I do wrong? I can try to fix it – bobbym Mar 11 '17 at 19:29

Consider the convergents and semiconvergents of your irrational number.

I have some bulky code to calculate semi-convergents.

SemiConvergents[v_, {1}] := Join[{0}, Convergents[v, 1]]
SemiConvergents[v_, 1] := Join[{0}, Convergents[v, 1]]

SemiConvergents[v_, {n_?OddQ}] :=
Block[{a = Last[ContinuedFraction[v, n]],
c = Take[Convergents[v, n - 1], -2]},
(Numerator[c[]] + Range[0, a]*Numerator[c[]])/
(Denominator[c[]] + Range[0, a]*Denominator[c[]])
]

SemiConvergents[v_, {2}] :=
Block[{a = ContinuedFraction[v, 2]}, Join[{Infinity}, a[] + 1/Range[a[]]]]
SemiConvergents[v_, 2] :=
Block[{a = ContinuedFraction[v, 2]}, Join[{Infinity}, a[] + 1/Range[a[]]]]

SemiConvergents[v_, {n_?EvenQ}] :=
Block[{a = Last[ContinuedFraction[v, n]],
c = Take[Convergents[v, n - 1], -2]},
(Numerator[c[]] + Range[0, a]*Numerator[c[]])/
(Denominator[c[]] + Range[0, a]*Denominator[c[]])
]


I use the following to calculate rational approximations to irrational a, subject to exponent 2+eps.

RothAttempt[a_, eps_] :=
Block[{r, kmax = 10},
r = DeleteDuplicates[
Flatten[Table[SemiConvergents[a, {k}], {k, 1, kmax}]]];
Pick[r, Thread[Abs[a - r] < 1/Denominator[r]^(2 + eps)]]
]


I do not know how to chose kmax such that all solutions are found...