Tcl Library Source Code

View Ticket
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.
Ticket UUID: 3c17835a2da341ad99c5e70007615f281f250534
Title: find interval of Legendre and 2 other estimated primes from two entries
Type: Patch Version: 8.6
Submitter: anonymous Created on: 2018-07-31 00:57:43
Subsystem: math :: special Assigned To: arjenmarkus
Priority: 5 Medium Severity: Cosmetic
Status: Closed Last Modified: 2019-04-24 19:02:32
Resolution: Accepted Closed By: arjenmarkus
    Closed on: 2019-04-24 19:02:32
possibly, difference over interval using NumberPrimesLegendreModified (related previous ticket cd42b3ddf8,2017-05-28 )
would be useful to some. two numbers entered, limit1 and limit2 and difference returned. both limits must be greater than one. find interval of est. primes from two entries on positive number line. Inclusive, interval differences for numberPrimesGauss, numberPrimesLegendre, NumberPrimesLegendreModified might be useful.
### differenceNumberPrimesLegendreModified --
#     Return the approximate difference number of primes 
#     between a lower and higher limit as given values
#     for approximate number of primes based on the
#     modified formula by Legendre
# Arguments:
#     limit1     The lower limit for the interval, largest prime to be included in the l.limit
#     limit2     The upper limit for the interval, largest prime to be included in the u.mlimit
# Returns:
#     Approximate difference number of primes
proc ::math::numtheory::differenceNumberPrimesLegendreModified {limit1 limit2} {
    if { $limit1 <= 1 } {
        return -code error "The lower limit must be larger than 1"
    if { $limit2 <= 1 } {
        return -code error "The upper limit must be larger than 1"

     set aa [::math::numtheory::numberPrimesLegendreModified [expr ($limit1)]]   
     set bb [::math::numtheory::numberPrimesLegendreModified [expr ($limit2)]] 
     expr ( $bb-$aa)
statements invoking difference
 puts " [ ::math::numtheory::differenceNumberPrimesLegendreModified 100  200  ] "
         #puts " [ ::math::numtheory::differenceNumberPrimesLegendreModified 100  0  ] " invokes error.
User Comments: arjenmarkus added on 2019-04-24 19:02:02:
I was a trifle hasty with my conclusion. The procedures I was looking for are contained in the file primes.tcl. 

Added the above convenience procedure and updated the tests and the manual.

(Note to self: still a bunch of tests to be added!)

arjenmarkus added on 2019-04-18 19:05:54:
Hm, it turns out that the file numtheory.tcl contains only a small part of the original package. I will need to examine this more closely. This requires a new ticket, as I cannot currently apply this rightaway.