When looking at the Minimal Goldbach prime partition point {p,q} for each n; where n=10^i and i = 2,3,4,...,10; I notice that these points reside in an interval with center n/2 and radius 250:
Clear[mgppp, lowerbound, upperbound]
mgppp[n_?EvenQ] :=
Last[ Transpose@{n - #, #} &@
Select[n - Prime@Range@PrimePi[n/2], PrimeQ]]
lowerbound[n_?EvenQ] := Module[{d}, {m = n/2, d = (m - 250)}; d]
upperbound[n_?EvenQ] := Module[{d}, {m = n/2, d = (m + 250)}; d]
hello = Table[{n, lowerbound[n], mgppp[n][[1]], n/2, mgppp[n][[2]],
upperbound[n]}, {n, {10^2, 10^3, 10^4, 10^5, 10^6, 10^7, 10^8,
10^9, 10^10}}];TableForm[hello,
TableHeadings -> {None, {"n", "(n/2)-250", "MGPPPp", "n/2", "MGPPPq",
"(n/2)+250"}}, TableAlignments -> Center]
Mathematica takes about 45 minutes to build the above table. Notice that each lower bound value (n/2)-250 is less than p and each upper bound value (n/2)+250 is greater than q.
Now I want to verify (or not) that the same happens for ALL even n's between 10^2 and 10^10. To simplify the number of evaluations; I compare only the lowerbound values with the p values as follows:
Clear[mgppp, lowerbound]
mgppp[n_?EvenQ] :=
Last[ Transpose@{n - #, #} &@
Select[n - Prime@Range@PrimePi[n/2], PrimeQ]]
lowerbound[n_?EvenQ] := Module[{d}, {m = n/2, d = (m - 250)}; d]
bag = {}; For[n = 10^2, n <= 10^10, n += 2,
If[lowerbound[n] < mgppp[n][[1]], Nothing,
AppendTo[bag, {n, lowerbound[n], mgppp[n][[1]]}]]]; TableForm[bag,
TableHeadings -> {None, {"n", "(n/2)-250", "MGPPPp"}},
TableAlignments -> Center]
The above evaluation is very slow and it takes days to be evaluated using my personal computer. I would appreciate any suggestions about how to speed up the calculations; perhaps using "Compile" or any other method to do this. Thank you.
PrimePi
. Your algorithm as it is written will never be faster thanPrimePi[Range[1, 10^10/2, 2]]; // AbsoluteTiming
. $\endgroup$For
loop. It will callmgpppp
ormgppp2
once for everyn
between10^2
and10^8
, so it will not be faster thanPrimePi[Range[10^2, 10^10, 2]/2];
because those functions evaluatePrimePi
forn
divided by two.PrimePi
appears to be slow for largen
and that is a problem. $\endgroup$