Version 6 of New Prime Number Browser

Updated 2018-02-09 18:33:08 by kwj

New Prime Number Browser

A New Tcl/Tk Script for investigating Prime Numbers plotted in the Ulam Style -- KWJ

Not much here yet, except for the following. Use it to ‘roll your own’ list of prime numbers that can be used by the '''New Prime number Browser’’’. This will also work for ‘’’Prime Number Browser’’’, which is the older version, soon to be replaced.


#!/bin/sh
# \
exec wish "$0" ${1+"$@"}

#
#  Version of May 4, 2017
#

####   Calculate the Primes   ####

   set primes {}

   puts -nonewline "\n   ---   Compute all primes that are less than:  "
   flush stdout
       
   set max [gets stdin]
   if {$max < 2} {
       set max 2
   }

   set primes [list 2]
   for {set test 3} {$test <= $max} {incr test 2} {
      set maxTest [expr {int(sqrt($test))}]
      foreach prime $primes {
         if {$prime  > $maxTest} {
            lappend primes $test
               break
         }
         if {![expr {$test % $prime}]} {
            break
         }
      }
   }

   
####   Put Primes into PrimesList file  ####
 
   set strng "#  The Prime Numbers less than  $max \n# \nset primes { \n"
  
   set strngLen 2
   set f [open "PrimesList" w]

   foreach n $primes {
      if {$strngLen > 75} {
         puts $f $strng
         set strng {}
         set nLen [string length "$n "]
         set strngLen $nLen 
         append strng "$n "
      } else {
         set nLen [string length "$n "]
         incr strngLen $nLen
         append strng "$n "
      }
   }
   append strng "\n}"
   puts $f $strng
   close $f

   puts "\n   There are [llength $primes] primes less than $max \n"

exit


#======================== Output from Primer.tcl ===========================

#
#  The Prime Numbers less than  2000 
# 
set primes { 
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 
103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 
199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 
313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 
433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 
563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 
673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 
811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 
941 947 953 967 971 977 983 991 997 1009 1013 1019 1021 1031 1033 1039 1049 
1051 1061 1063 1069 1087 1091 1093 1097 1103 1109 1117 1123 1129 1151 1153 1163 
1171 1181 1187 1193 1201 1213 1217 1223 1229 1231 1237 1249 1259 1277 1279 1283 
1289 1291 1297 1301 1303 1307 1319 1321 1327 1361 1367 1373 1381 1399 1409 1423 
1427 1429 1433 1439 1447 1451 1453 1459 1471 1481 1483 1487 1489 1493 1499 1511 
1523 1531 1543 1549 1553 1559 1567 1571 1579 1583 1597 1601 1607 1609 1613 1619 
1621 1627 1637 1657 1663 1667 1669 1693 1697 1699 1709 1721 1723 1733 1741 1747 
1753 1759 1777 1783 1787 1789 1801 1811 1823 1831 1847 1861 1867 1871 1873 1877 
1879 1889 1901 1907 1913 1931 1933 1949 1951 1973 1979 1987 1993 1997 1999 
}

#   There are 303 primes less than 2000
#


gold31jan2018. Gauss-Legendre functions for number of primes has been loaded (c. 2017-05-28) in pending distribution of TCLLIB. Maybe coincidence, but sequence {7 11 13 14 } has been found on Sumerian tablet AO8862. Oeis {7 11 13 14} cited sequence property as Numbers n such that 16n+15 is prime. Tablet YBC10722 uses the input quantity 15 with the sequence {7 11 13 14}! Maybe your program could be used as example or exercise of the prime related functions in the TCLLIB.


Monster Prime Predicting Formula!

16 * m + 15 — an amazing formula!!

I’ve seen references to this formula in the past, but have been focused on what I think of as Prime Predictive Formulae which produce Prime Rich trajectories along Ulam Spirals. In my way of thinking, an important aspect of any such formula was it’s Potency, that is the ratio of predicted primes to the total number of predictions that a formula gave. Thus, for instance, Euler’s formula y = m² + m + 41 when applied to the set of all Primes Less Than 500K (PLT500K), yields 433 primes out of 706 predictions, for a potency of .394, which seemed pretty good.

For the same set of Prime Numbers, the above formula, 16 * m + 15 predicts 5197 Primes out of 31236 predictions, for a potency of 0.166. Although the Potency is not great, the fact that it calculates over 10 times as many primes is astounding and makes this simple equation truly Prime Predictive.

The following figure shows what these prime numbers look like. The red squares represent the prime numbers and the small red circles are the non primes that the formula produces. If one draws a line through the center, perpendicular to the Principle Axes it appears that the upper left portion of the plot contains many more primes than does the lower right portion. This is very puzzling indeed and seems to be somewhat analogous to the notion of Prime Rich directions.

PLT500K

The following figure shows these primes plotted on the smaller set of primes less than 100K (PLT100K). In this case, the formula predicts 1197 primes. Each red square is a prime number and the non primes are little red circles. Here the prime rich directions seem to be parallel to the Principle Axes. Euler’s formula is overlaid on the plot.

PLT100K

Many thanks to Gold for pointing this formula out to me.

See also: Primal Screens and Primal Screens— Part Two

Older Version of Browser: Prime Number Browser

Also: Gerard Sookahet and Ulam spiral