TITLE: Surprising behavior of Leibniz formula for Pi (as Euler product)
QUESTION [9 upvotes]: I wrote a program to compute successive approximations of Pi using the following Euler product:
π/4 = (3/4)*(5/4)*(7/8)*(11/12)*(13/12)...

in which the numerators are the odd prime numbers, and the denominators are the closest multiples of four (picture here).
I only printed out approximations which were better than all previous approximations.  For example, if we define term b(n) as a(1)*...*a(n), we get b(1)=3, b(2)=3.75, b(3)=3.28125, b(4)=3.0078125, b(5)=3.2584635416, b(6)=3.462117513020833, b(7)=3.289011637369791, b(8)=3.1519694858127165.  Of these, only terms 1, 3, 4, 5, and 8 lead to better approximations, whereas terms 2, 6, and 7 do not.
Here are the results for b(1) through b(5e9). Each line lists n (the number of terms), the n-th odd prime (i.e. the numerator), and b(n) = n-th approximation of Pi.
My main question:

Why are the majority of terms spaced an even number of primes apart?  You can see this in the long runs of odd terms (including the last 38) as well as runs of even terms.  Out of 71 terms listed below, only 12 are an odd number of primes apart (and half of those are consecutive primes):
n           nth prime    b(n)
--------    ---------    --------------------
1           3            3
3           7            3.28125
4           11           3.0078125
5           13           3.258463541666666667
8           23           3.151969485812717015
47          223          3.142881020579148847
49          229          3.142820561956869316
95          503          3.142133362655805143
247         1571         3.141912463610110751
251         1601         3.141870207419266742
253         1609         3.141868992307710322
742         5651         3.14162426815169492
4268        40771        3.141615756075984207
4270        40801        3.141615731534329301
4288        40961        3.141615677490338508
11445       121607       3.141598027134934751
30123       351863       3.141590250585033286
30701       359207       3.141592343379190447
30703       359231       3.141592343939149987
62592       781631       3.141592401246138009
62690       783019       3.141592434797031353
62992       787091       3.141592555331437549
3535871     59530267     3.141592744321108717
3535872     59530291     3.141592691548097889
3664203     61831547     3.141592690253390274
3664204     61831579     3.141592639444520594
3664214     61831747     3.14159263944470384
3664220     61831927     3.141592639444941319
3665670     61857923     3.141592639728499004
3665696     61858267     3.141592639729109027
3665842     61860691     3.14159263973972529
3665854     61860947     3.141592639739733499
3665866     61861159     3.141592639739846788
3708907     62634323     3.141592650836013723
3708909     62634331     3.141592650836016126
3708913     62634379     3.141592650836065776
3708929     62634631     3.141592650836687188
3708931     62634643     3.14159265083668959
3708935     62634763     3.141592650836755255
3708957     62635171     3.14159265083739669
3708983     62635603     3.141592650838468924
3708985     62635663     3.141592650838490544
3709017     62636359     3.141592650840072844
3709025     62636503     3.141592650840184947
3709031     62636603     3.14159265084026262
3709335     62641987     3.141592650886839043
3709529     62645567     3.141592650902843015
3788299     64058429     3.141592655663886643
3788307     64058573     3.141592655663770271
3788315     64058693     3.141592655663641654
3788349     64059221     3.141592655662596635
3788357     64059329     3.141592655662480267
26172875    496334123    3.141592653356849149
26172877    496334171    3.141592653356849699
26175227    496381447    3.141592653365838828
26175231    496381511    3.141592653365838903
26175239    496381651    3.141592653365841606
26175359    496384127    3.141592653365985622
26175361    496384219    3.141592653365985865
26175383    496384723    3.141592653365987204
26175619    496389431    3.141592653366111398
26176783    496412687    3.141592653369742264
26176787    496412771    3.141592653369743412
26176789    496412779    3.141592653369743501
26179059    496458439    3.141592653384679576
26179063    496458499    3.141592653384680369
26179191    496461071    3.141592653384854573
26180229    496481387    3.141592653390104058
26180235    496481471    3.141592653390104479
26180239    496481639    3.141592653390106083
26180241    496481663    3.141592653390106375


The 12 terms with odd spacing - often '1' - mentioned above: (3,4)=>(7,11), (4,5)=>(11,13), (3535871,3535872)=>(59530267,59530291), (3664203,3664204)=>(61831547,61831579)
Other questions:

What is the distribution of terms in this sequence? Does this sequence have characteristics that differ from than that of the Euler product containing all terms? Why are there such large gaps between successively better approximations, followed by clumps of improvements?  For example, after term 62,992, there are 3,472,879 intervening terms before the next improvement - after term 3,788,357, a whopping 22,384,518 terms before the next improvement - and at least 10 billion terms (and counting) before whichever one comes next. Although the series converges, at various scales it resembles a random walk - is there a better or more precise way to characterize it?

Thank you for your time -

REPLY [2 votes]: I'm afraid the answer to your main question is a bit more mundane than one might have hoped.
There are up and down steps, and for large numbers they're all very nearly the same size. The net change due to $n$ up steps and $n$ down steps is far less than the net change from any unbalanced set of steps. To an increasingly good approximation, you can think of the distance to $\pi/4$ as a random walk with the fractional part drifting much more slowly than the integer part – relative to the current step size, but that step size changes ever more slowly.
The improvements occur when the fractional part is close to $0$; then propitious patterns of $n$ up steps and $n$ down steps can decrease the record a bit. While the fractional part is near $0$, no parity changes can occur. For a parity change to occur, the fractional part has to drift almost by $1$, and that takes longer and longer the further you go. Note that there are relatively large jumps in the last column when the parity of the first column flips. This happens when the fractional part has drifted by about $1-2x$, where $x$ is the current record distance from $\pi/4$.
I don't know about the distribution, or how best to characterize it, but some of your other questions are related to the same phenomenon.
P.S.: This description is only accurate during the stretches of primes of the same order of magnitude. After no improvement has occurred e.g. from $62992$ to $3535871$ (because the process has been wandering around away from $\pi/4$), the step size has of course decreased so much that any memory of "fractional" and "integer" parts from the time of the last improvement has long been erased. Thus at the boundaries between such stretches there is a $50/50$ chance for a parity change.