Skip to content

Instantly share code, notes, and snippets.

@Marc-B-Reynolds
Created April 11, 2019 09:28
Show Gist options
  • Save Marc-B-Reynolds/e1c76dd6396689323ab584ee3bb927f9 to your computer and use it in GitHub Desktop.
Save Marc-B-Reynolds/e1c76dd6396689323ab584ee3bb927f9 to your computer and use it in GitHub Desktop.
factor PI into two doubles A*B
(*
Pi correctly rounded to 106 digits via sollya:
> display=dyadic!;
> round(Pi,106,RN);
63719069007931157819013617823235b-104
*)
s = 63719069007931157819013617823235
(* prime factors of 's' and nearby integers *)
f0 = FactorInteger[s]
f1 = FactorInteger[s + 1]
f2 = FactorInteger[s + 2]
f3 = FactorInteger[s + 3]
f4 = FactorInteger[s - 1]
f5 = FactorInteger[s - 2]
f6 = FactorInteger[s - 3]
(* output:
{{5, 1}, {7, 1}, {23, 1}, {29, 1}, {41, 1}, {41385037, 1}, {1608601017035651239, 1}}
{{2, 2}, {81761, 1}, {194833322146045051488526369, 1}}
{{3, 3}, {811, 1}, {2909945152666171522081272221, 1}}
{{2, 1}, {1344138743, 1}, {23702563942809867291733, 1}}
{{2, 1}, {3, 1}, {13, 1}, {816911141127322536141200228503, 1}}
{{17, 1}, {74509, 1}, {2874196414547, 1}, {17502308010263, 1}}
{{2, 9}, {11, 1}, {61, 1}, {263, 1}, {44131, 1}, {29700157, 1}, {538045097321, 1}}
*)
(* eye-ball bit requirements of largest prime *)
{N[Log2[f0[[Length[f0], 1]]]],
N[Log2[f1[[Length[f1], 1]]]],
N[Log2[f2[[Length[f2], 1]]]],
N[Log2[f3[[Length[f3], 1]]]],
N[Log2[f4[[Length[f4], 1]]]],
N[Log2[f5[[Length[f5], 1]]]],
N[Log2[f6[[Length[f6], 1]]]]}
(* output: {60.4805, 87.3324, 91.2331, 74.3275, 99.3661, 43.9926, 38.9689}
so only 'f5' & 'f6' have a largest prime that will fit in 53 bits.
Gro-Tsen's constants are 'f6' so (s-3).
(s-2) = 17 * 74509 * 2874196414547 * 17502308010263
no pairs of (s-2) allow both to fit in 53 bits so (s-3) is optimal.
*)
{ N[Log2[17502308010263 74509]], N[Log2[17 2874196414547]] }
{ N[Log2[17502308010263 17]], N[Log2[74509 2874196414547]] }
(*
{60.1777, 45.4738}
{48.0801, 57.5714}
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment