### Checking the Firoozbakht conjecture: safe bounds

Doing Math with JavaScript

The table below gives "safe bounds" for the Firoozbakht conjecture as applied to prime gaps of a given size g ∈ [2,1510]. For example, a gap of size 22 is safe (it cannot violate the Firoozbakht conjecture) when such a gap occurs between primes above 181. The safe bounds are found by solving the inequalities (based on Dusart's π(x) bounds):

0  <  x/(ln x − 1.2)  <  ln x/(ln(x+g) − ln x)   for x > 4; 0  <  x/(ln x − 1.1)  <  ln x/(ln(x+g) − ln x)   for x > 60184,   g ≥ 110.

Use this data in conjunction with the table of first occurrence prime gaps up to 1019. For g = 2 and g = 4, one can manually check the Firoozbakht conjecture for small primes below the respective safe bounds. For g ∈ [6,1510], the actual first occurrence of prime gap g is already safe. (For g ∈ [22,1510], even the number of digits in the safe bound is smaller than that of the first-occurrence primes with gap g.) This verifies the Firoozbakht conjecture for primes up to 1019 (because gaps g > 1510 never occur between primes below 1019). To obtain safe bounds for large gaps, you can use e.g. Wolfram Alpha (the normal floating-point precision might not be sufficient). See also arXiv:1503.01744, arXiv:1506.03042.

```Gap of size g ...    is safe above  (digits)

function format5 (k) {
if (k<10) return '    '+k
if (k<100) return '   '+k
if (k<1000) return '  '+k
if (k<10000) return ' '+k
return k
}

function format18 (k) {
if (k<10) return '                 '+k
if (k<100) return '                '+k
if (k<1000) return '               '+k
if (k<10000) return '              '+k
if (k<100000) return '             '+k
if (k<1000000) return '            '+k
if (k<10000000) return '           '+k
if (k<100000000) return '          '+k
if (k<1000000000) return '         '+k
if (k<10000000000) return '        '+k
if (k<100000000000) return '       '+k
if (k<1000000000000) return '      '+k
if (k<10000000000000) return '     '+k
if (k<100000000000000) return '    '+k
if (k<1000000000000000) return '   '+k
if (k<10000000000000000) return '  '+k
if (k<100000000000000000) return ' '+k
return k
}

// GLOBAL PARAMETER
gap = 2;

function checkFiroozbakhtByDusart12(stop) {
var p, q=2, left=7, right=left, fl=fu(left), bnd, dgt;
for (var i=2; i<=stop; i=i+2) {
gap = i
right=left; while(fl*fu(right)>0 && isFinite(fu(right))) right=2*right;
bnd = bisect(fu,left,right)
dgt = Math.ceil(ln(bnd)/Math.LN10)
document.writeln ( '        ' + format5(gap) + '   ' + format18(Math.ceil(bnd)) + format5(dgt) );
}
}

function checkFiroozbakhtByDusart11(stop) {
var p, q=2, left=7, right=left, fl=fu1(left), bnd, dgt;
for (var i=110; i<=stop; i=i+2) {
gap = i
right=left; while(fl*fu1(right)>0 && isFinite(fu1(right))) right=2*right;
bnd = bisect(fu1,left,right)
dgt = Math.ceil(ln(bnd)/Math.LN10)
document.writeln ( '        ' + format5(gap) + '   ' + format18(Math.ceil(bnd)) + format5(dgt) );
}
}

checkFiroozbakhtByDusart12(108);
checkFiroozbakhtByDusart11(1510);

```

Note: It is easy to check that the safe bounds form an increasing sequence (as a function of increasing gap sizes g.) You might start checking actual first-occurrence gap sizes versus safe bounds one by one. However, once you encounter a safe maximal prime gap (such as the gap g = 8 following the prime pk = 89 – which is above the respective safe bound, i.e. above 28), any further verification can then be performed for maximal prime gaps only, i.e. for g = A005250(n), with pk = A002386(n).