juusprime

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2021 License: GPL-3.0 Imports: 15 Imported by: 0

README

juusprime : Prime Tuplet generation written in golang

December/January 2021/2022:

-- NEWS --: I've prepared a mariadb/mysql database that has hundreds of thousands of Tuplets (Sext/Quint/Quad), and has a sample of twins included. Zip file is around 26 Mb, decompresses to sql file of around 86 Mb. It is hosted at:

https://www.pzktupel.de/Links.html

or by direct link:

https://www.pzktupel.de/Julius_Schoen/juustuplets_DB_2021_12.zip

It is also available at my downloads page (link below).

This is the package code for juusprime which is an engine to generate Prime Tuplets (Sextuplets and/or Quintuplets and/or Quadruplets).

The generation/scanning of Tuplets is NOT efficient (ie., it is slow), it is, however, a proof of concept for my take on prime Tuplet patterns.

A pdf file is available in the file list that details the underlying theory and structures used for the algorithms, only algebra is needed. A nutshell summary is given below.

New as of 3 December 2021:

  • Add notification code for Twin Tuplets (those separated by 7 in TNumbers, by 210 in Integer value)

New as of December 28 2021 (v1.2.0):

  • Fix a bug affecting generating a quad only 29basis file.
  • Add a "scan" function to speed up, a bit, tuplet searches.
  • "scan" automation added.
  • Experimental analysis tools added.
  • Experimental artificial potPrimes..

See at bottom for other recent additions.

juusprime is free software, licensed under the GNU GPL, version 3. It is written in pure Go, no other dependencies.

Recommended is to use the associated go application I wrote. It is an interactive linux terminal application which uses this package to generate tuplets, provide information, and help with the process of generation and organization. The go code is found at:

https://github.com/Juuliuus/juusprime_app

If you do not use golang, then you can also download a compiled, ready to run, executable from my website (you may need to set it as executable before it will run): Download page (gpg sig): https://www.timepirate.org/downloads.html App Direct Download: https://www.timepirate.org/downloads/juusprime_app

This project started its life as a proof of concept for prime structures that I first worked out on paper. I needed to implement the paper scribbles to see that it actually worked. It worked well enough that I thought I would share it for those interested in this kind of thing.

It uses a gestalt-y block approach to tuplet generation, not brute force. The concepts, as I first outlined with pencil and paper, indicate that it will be 100% accurate and find 100% of the wanted tuplets in the region you are searching.

It uses go's big Int (and where needed, big Float), which means it can work with any integer that you care to type in. But, as usual for primes, the bigger the numbers the longer its going to take.

Each run will output a rawdata file, a prettydata file, and an info file. These are all text files.


Install

Install in the usual Go manner with:

go get github.com/Juuliuus/juusprime

Basic usage

For those that prefer to write their own code for this package:

Be sure you are happy with config data file paths by calling Configure().

Before you can generate Tuplets you need what I refer to as a "29basis" file. Call GenerateBasis() function to write this file. This will take a minute or two, the file is about 190Mb.

You can now generate tuplets for any range you desire at any time, call the GeneratePrimeTupletsInteractive() routine.

Support for Automation for producing Tuplets (using basis-#) has been added so that processing can be done with scripts:

GeneratePrimeTupletsAutomated(auto *AutomationStruct)

Automation has been added to the associated pre-compiled executable (link above)


NEWS SECTION

First twin sextuplet found by juusprime package in November 2021.

Upon finding it, a search showed a mysterious page in Japan where this one, and 16 others (!), was found, corroborating this find.

I checked the other 16 from the japan page and they are correct. Those and others I found are included in the database mentioned at the top of this file.

Check out the link if you are interested: https://www.gensu.co.jp/saito/puzzle/text/prime1_smp_A6x2.txt

This twin sextuplet is the first one

Basis-902 TNum = 194530218151 ---primes--- ┣━┫ (0) 5835906544537 5835906544541 5835906544543 5835906544547 5835906544549 5835906544553

TNum = 194530218158 ---primes--- ┣━┫ (0) 5835906544747 5835906544751 5835906544753 5835906544757 5835906544759 5835906544763

Nutshell overview

With these structures the number line is broken up into 2 types of blocks of numbers: TNumbers (Template Numbers) and Basis Numbers. It is recommended to do basis number generation because it is then assured that no numbers on the number line are left out by accident.

This is a very short overview. The details are available in the pdf file which will be updated as new analysis routines are written..

These regions arise out of splitting the prime universe into 3 separate regions and they arise naturally, which helps to turn the chaos of the primes into groups that useful and easy(ier) to work with: primes 2-3-5, primes 7-29, and the primes 31-59.

The routines do not factor out or search for primes at all. The blocks and structures contain patterns that can be combined to "grok" the entire block.

Performance

For the generation of basis-0 (see pdf) tuplets it takes about 20 minutes to generate all possible tuplets (Sext's, Quints, and quads) but only about 40 seconds if you filter for sextuplets only.

For basis-1000 (the thousand and first basis), filtered by Sextuplets only, it took a bit under 2 minutes:

Final counts (from TNumber 215656441028 to 215872097468)
(Natural numbers from 6469693230835 to 6476162924064)
(filtered by: Sextuplets only)
177 Sextuplets
0 LQuints
0 RQuints
0 Quads

When generating the one time 29basis file, individual processor cores go to 100%, but this basis generation process only takes about a minute.

However, at least on my machine, the processor usage does not peg out when generating tuplets. And I'm not sure why. Perhaps the go language ability to compile to spread work across processors has kicked in?

In any case, on my dual-core quad processor, usage remains at about the 20% level, leaving the computer very responsive to other programs while generating tuplets.

I did do, for testing purposes, a rather large range of TNumbers (it is not an entire basis, just a portion) in basis-86000000000

This puts the sextuplets in the 10^20 range.

It found 7 Sextuplets in about 5.5 hours. Here is the prettydata output:

TNumbers from 18546453926011000028 to 18546453926100000027
(Natural #'s from 556393617780330000835 to 556393617783000000834)
filtered by: Sextuplets only
BASIS:86000000000

TNum = 18546453926016026965
BeginsAt : 556393617780480808945
EndsAt : 556393617780480808974
[Basis-0-TNum : 16026965]
---primes--- ┣━┫ (0)
556393617780480808957
556393617780480808961
556393617780480808963
556393617780480808967
556393617780480808969
556393617780480808973

TNum = 18546453926049112178
BeginsAt : 556393617781473365335
EndsAt : 556393617781473365364
[Basis-0-TNum : 49112178]
---primes--- ┣━┫ (0)
556393617781473365347
556393617781473365351
556393617781473365353
556393617781473365357
556393617781473365359
556393617781473365363

TNum = 18546453926052983318
BeginsAt : 556393617781589499535
EndsAt : 556393617781589499564
[Basis-0-TNum : 52983318]
---primes--- ┣━┫ (0)
556393617781589499547
556393617781589499551
556393617781589499553
556393617781589499557
556393617781589499559
556393617781589499563

TNum = 18546453926062497662
BeginsAt : 556393617781874929855
EndsAt : 556393617781874929884
[Basis-0-TNum : 62497662]
---primes--- ┣━┫ (0)
556393617781874929867
556393617781874929871
556393617781874929873
556393617781874929877
556393617781874929879
556393617781874929883

TNum = 18546453926079720686
BeginsAt : 556393617782391620575
EndsAt : 556393617782391620604
[Basis-0-TNum : 79720686]
---primes--- ┣━┫ (0)
556393617782391620587
556393617782391620591
556393617782391620593
556393617782391620597
556393617782391620599
556393617782391620603

TNum = 18546453926082821469
BeginsAt : 556393617782484644065
EndsAt : 556393617782484644094
[Basis-0-TNum : 82821469]
---primes--- ┣━┫ (0)
556393617782484644077
556393617782484644081
556393617782484644083
556393617782484644087
556393617782484644089
556393617782484644093

TNum = 18546453926092051529
BeginsAt : 556393617782761545865
EndsAt : 556393617782761545894
[Basis-0-TNum : 92051529]
---primes--- ┣━┫ (0)
556393617782761545877
556393617782761545881
556393617782761545883
556393617782761545887
556393617782761545889
556393617782761545893

FYI, The 29Basis file contains only possible locations, but these are also the only locations we need to search. The statistics for the possibilities in the 29basis file are:

1956955 Sextuplets
5010341 LQuints
5010341 RQuints
5528488 Quads

From this one can see that filtering for what you are interested in is a good idea if you want to save time. A Sextuplets only search only has to check 2 million TNumbers, and the Sextuplets are destroyed faster by the potPrime look up tables.


I'm a biologist and computer programmer, not a mathematician. But I have made every effort, and done many tests, to insure the structures I build, and the results, are correct. Please let me know if you find any problems.


History

v1.2.0 December 28 2021:

  • Fix a bug affecting generating a quad only 29basis file.
  • Add a "scan" function to speed up, a bit, tuplet searches.
  • "scan" automation added.
  • Experimental analysis tools added.
  • Experimental artificial potPrimes..

v1.1.0 March 17 2021:

  • Implement new getCrossNumModDirect for 30% speed increase
  • Add analysis routines.
  • automation with GeneratePrimeTupletsAutomated()

v1.0.1 March 5, 2021

  • add twin sextuplet check during Tuplet generation
  • add automation routines for use through shell scripts, etc.
  • Add initial Helper structure to hold useful runtime vars.

v1.0.0 February 2021

Documentation

Index

Constants

View Source
const (
	CSextuplet = iota
	CLQuint29
	CRQuint13
	CQuad
	CXNoTrack
	CX17
	CX19
	CX23
	CX25
)

the integer representation of the Tuplet symbols

View Source
const (

	//Basis29PathStr const defining a string for Basis29Path
	Basis29PathStr = "Basis29Path"
	//DataPathStr const defining a string for DataPath
	DataPathStr = "DataPath"
)
View Source
const (
	Basis29Msg = `` /* 516-byte string literal not displayed */

)

some large string constants for printing into various information files

Variables

View Source
var (
	//SymbolCount : map to hold accumulated symbols
	SymbolCount map[int]int
	//FilterMap : map to hold filtering choices
	FilterMap = map[int]uint{
		CSextuplet: filterSextuplet,
		CLQuint29:  filterLQuint29,
		CRQuint13:  filterRQuint13,
		CQuad:      filterQuad,
		CXNoTrack:  filterXNoTrack,
	}
)
View Source
var (

	//Basis29Path : string to hold configuration path to 29basis files
	Basis29Path string
	//DataPath : string to hold configuration path to write tuplet files
	DataPath string
)
View Source
var (
	AllowHugeCombos bool
)
View Source
var (

	//TemplateLength : This a constant used a lot in big.Int calcs, it is the length of a Template (30)
	TemplateLength *big.Int
)

Functions

func AddSymbols

func AddSymbols(symbol1, symbol2 *int) int

AddSymbols : Return the "addition" of effects that determine whether the two symbols add to a significant result

func AdjustTNumsForFilename

func AdjustTNumsForFilename(n *big.Int) string

AdjustTNumsForFilename : used to keep filename lengths under control, if the incoming TNumber or basis (n) is bigger than 9999999999999999999999999999999 it returns an md5 hash, otherwise returns the string representation of the incoming number

func AnalyzeCritSectByCSIDRange added in v1.2.0

func AnalyzeCritSectByCSIDRange(fromID, toID *CritSectID, primesOnly, doAdd, details bool)

AnalyzeCritSectByCSIDRange : Given a from and to CritSectID will analyze in detail all TNumbers in that (inclusive) range, be aware this can be a LOT of information, details shows very detailed information, primesOnly will reject non-Prime pP's and lump together until the next Prime pP, doAdd assumes the "toID" is to be added to the "fromID" instead of being a static toID, this always prints a summary and will print a ".B." represenation where "." is a critical section where there are clear channels, and "B" is a critical section that is "black", i.e., no clear channels

func AnalyzeCritSectByTNumber added in v1.2.0

func AnalyzeCritSectByTNumber(tTarget *big.Int, details bool)

AnalyzeCritSectByTNumber : Given a TNumber will analyze its parent CritSectID for clear channels and/or sextuplets, details shows a lot of information, the calculated crit length will be inclusive, caller be aware: the "to" var here is processed as LTE(<=)

func AnalyzeTNumbersInteractive added in v1.1.0

func AnalyzeTNumbersInteractive()

AnalyzeTNumbersInteractive : interactive full analysis of any TNumbers you like >= 32, =careful= large TNumbers could take a while and can produce LOTS of output.

func ArtIntToTNum added in v1.2.0

func ArtIntToTNum(rNum, interval int) int

IntToTNum : given any integer return the TemplateNum where it will be found. Key function for this package.

func ArtTNumToInt added in v1.2.0

func ArtTNumToInt(tNum, interval int) int

func Basis29RangeTNum

func Basis29RangeTNum() (startTNum, endTNum int)

Basis29RangeTNum : func that returns the start/end values, in TNumbers, of a 29Basis range, not used, primarily here so that an interested person can see how they were determined, The pattern then begins again and repeats to infinity

func BasisToTNumRange

func BasisToTNumRange(basis, returnHereBegin, returnHereEnd *big.Int)

BasisToTNumRange : basis is 0 based, results are set directly to passed in param pointers, results are the beginning and ending TNumbers for the specified basis

func BuildInflationMap added in v1.2.0

func BuildInflationMap(p *PrimeGTE31, n *big.Int)

BuildInflationMap : Builds, from first principles, the inflated structure for p at n by repeadedly adding the values, essentially equivalent to doing the inflation by hand, used primarily as a check to other inflation routines

func ChangeFileExt

func ChangeFileExt(fName, newExt string) string

ChangeFileExt : change the extension of fName to newExt

func CheckTwinSextuplet added in v1.0.1

func CheckTwinSextuplet(filename string, out *os.File)

CheckTwinSextuplet : testing, check rawdata files for twin Sextuplets, can also serve as template for other quick tests one wants.

func Choose29BasisFile

func Choose29BasisFile() (string, bool)

Choose29BasisFile : Routine that prepares a list of 29basis files from the Basis29Path and presents them to the user.

func ClearSymbolCounts

func ClearSymbolCounts()

ClearSymbolCounts : Clears the SymbolCount map which is used to accumulate results

func ConfigFilename

func ConfigFilename() string

ConfigFilename : return the expected path of the config file, executable name + ".config", dev environment writes jup.config to HOME

func Configure

func Configure()

Configure : should be called at least once or routines will have to default to HOME folder for writing/reading data, the answers will be written to config file, for now simple setup instead of full blown ini file

func CountClearTNumbers added in v1.2.0

func CountClearTNumbers(fromTNum, toTNum, maxN *big.Int, detailed bool) []int

CountClearTNumbers : fromTNum/toTNum are inclusive, detailed gives a lot of output, returned []int has 3 rows: Sextuplet, Clear, and total counts, this func tests each TNumber to see if it has a clear channel, if so adds to sextuplet total if a true sextuplet, otherwise goes into "unused" clear channels, caller be aware - - toTNum is processed as LTE (<=) since it is inclusive

func CritLen added in v1.2.0

func CritLen(csid *CritSectID, returnHereLen *big.Int)

CritLen : get the true critical length (between families), length is returned in the return param, also see CritLenForceGetN()

func CritLenForceGetN added in v1.2.0

func CritLenForceGetN(p *PrimeGTE31, len, returnHereN *big.Int)

CritLenForceGetN : complement to CritLen(), given a length (in TNumbers) returns in the return param the n needed to get as close as possible to the provided given length, e.g., given the length of the 29Baseis (215656441) returns the n where the prime's critical length begins exceeding a complete Basis

func CrossingAtTNumCountingNumber

func CrossingAtTNumCountingNumber(prime, tNum *big.Int) *big.Int

CrossingAtTNumCountingNumber : Given the Prime and TemplateNum, return the crossing number in Counting number format (starting at 1), only for humans preferring counting numbers rather than mod results, do not use in calculations!

func CrossingAtTNumExpandedCountingNumber

func CrossingAtTNumExpandedCountingNumber(prime, tNumExpanded *big.Int) *big.Int

CrossingAtTNumExpandedCountingNumber : Given the Prime and TemplateNum expanded to int, return the crossing number in Counting number format (starting at 1), only for humans preferring counting numbers rather than mod results, do not use in calculations!

func CrossingAtTNumExpandedMod

func CrossingAtTNumExpandedMod(prime, tNumExpanded *big.Int) *big.Int

CrossingAtTNumExpandedMod : Given the Prime and a TemplateNum expanded to number line integer, return the crossing number in mod format (starting at 0), Key function for this package

func CrossingAtTNumMod

func CrossingAtTNumMod(prime, tNum *big.Int) *big.Int

CrossingAtTNumMod : Given the Prime and TemplateNum return the crossing number, Key function for this package, "prime" is not necessarily a prime #, but a potentially prime #

func DisplayProgress

func DisplayProgress(from, to int64, part int) func()

DisplayProgress : from and to are usually ranges of TNumbers, but it depends on what you want to measure, part is how fine to divide the notifications: for example, 20 will partition it into 5% blocks, 100 into 1% blocks, this is setup as a closure func, its virtue is being able to accurately measure progress even when the index vs TNum do not match, ie. "jerky" progress, primarily used when generating "small" int/int64 compatible ranges, see also DisplayProgressBig

func DisplayProgressBig

func DisplayProgressBig(from, to *big.Int, part int64) func(*big.Int, *big.Int)

DisplayProgressBig : closure for displaying progress for data where the range is not evenly, ie. 1 to 1, probed, for example, a range from 234 to 2345 which is actually indexed randomly in that range, used when processing GTE 31's against the Basis29 file, works for huge numbers

func DisplayProgressBookend

func DisplayProgressBookend(msg string, isStarting bool) time.Time

DisplayProgressBookend : Display the msg, isStarting is true for the first call (a header) and false for the end call (a footer), it returns a Time, meant to be used to wrap DisplayProgress

func Factorial added in v1.2.0

func Factorial(n int64) *big.Int

TODO:

func FileClose

func FileClose(f *os.File)

FileClose : close a file previously opened with FileOpen with error checking, usually called with defer

func FileExists

func FileExists(name string) bool

FileExists : Returns true if file or directory (?) exists

func FileOpen

func FileOpen(p string, append bool) (*os.File, error)

FileOpen : wrapper for opening files, if append is true the file is opened for reading/writing/appending, if false the file is created or overwritten

func GenCombinations added in v1.2.0

func GenCombinations(start, k, n int) []string

GenCombinations : returns slice of strings containing all combinations of (n choose k) with all possible k values.

func GenerateBasis

func GenerateBasis()

GenerateBasis : the default and recommended 29 basis file generation routine for new/inexperienced users

func GenerateBasis29

func GenerateBasis29(ctrl *GenPrimesStruct, f *os.File)

GenerateBasis29 : The engine func that generates 29Basis files, it can be called with a GenPrimesStruct already filled in if you are comfortable with that, otherwise recommended to use GenerateBasisInteractive()

func GenerateBasisInteractive

func GenerateBasisInteractive()

GenerateBasisInteractive : Interactive func to take user input and generate 29Basis files, generally one only needs the "no filter" version, but one is allowed to choose other varieties, recommended to always use default ranges unless you are completely comfortable with juusprimes and filtering

func GeneratePrimeTuplets

func GeneratePrimeTuplets(ctrl *GenPrimesStruct)

GeneratePrimeTuplets : The engine func that generates juusprime Tuplets, it can be called with a GenPrimesStruct already filled in if you are comfortable with that, otherwise recommended to use GeneratePrimeTupletsInteractive

func GeneratePrimeTupletsAutomated added in v1.0.1

func GeneratePrimeTupletsAutomated(auto *AutomationStruct) int

GeneratePrimeTupletsAutomated : For use with automation through code or shell scripts, etc. Pass in a filled automation structure.

func GeneratePrimeTupletsInteractive

func GeneratePrimeTupletsInteractive()

GeneratePrimeTupletsInteractive : The user interactive func to begin the generation of juusprimes

func GeneratePrimes7to23

func GeneratePrimes7to23()

GeneratePrimes7to23 : Trivial output, but important as sanity check that the routines give back the correct effects, The primes 7 to 23 cannot be generated using the general methods I've written, this func prints them out for completeness, but they are not for use in any further routines or analysis

func GetCritLength added in v1.1.0

func GetCritLength(abs bool, p *PrimeGTE31, fixedN, n, returnHereLen *big.Int) error

GetCritLength : deprecated, moved to PrimeGTE31 method, given fixedN (a chosen, fixed n level), and n the n-level you want to compare to, calculate the number of Templates between them, prime is a *PrimeGTE31, and abs flag is whether to return the absolute value, result is returned in last parameter

func GetCritLengthByDiff added in v1.1.0

func GetCritLengthByDiff(abs bool, p *PrimeGTE31, N, diff, returnHereLen *big.Int) error

GetCritLengthByDiff : deprecated, moved to PrimeGTE31 method, return the total number of Templates for potPrime p between fromN and toN, toN can be less than fromN, if abs is true return the length's absolute value, result returned in last param,

func GetCrossNumMod

func GetCrossNumMod(givenTNum, n *big.Int, p *PrimeGTE31, returnHereCrossNumMod *big.Int)

GetCrossNumMod : returns in pointer param the offset (crossing number) for the GTE 31 Prime at level n at the specified given target TNumber, NOTE - After the release I realized that this function is very poorly named and misleading, It does NOT return a crossing number, it returns the relative offset of givenTNum into the prime's Natural Progression. Renaming the function would require a major version number change because it would break existing code, this is the original CrossNumMod function built using TNumber mod algorithms, also see the newer GetCrossNumModDirect or GetCrossNumModSimple funcs which are simpler and faster, This DOES NOT return errors if you send in too small a TNumber because this routine is used very often in loops, caller needs to validate the TNumbers submitted are >= the p's startTemplateNumber

func GetCrossNumModDirect added in v1.1.0

func GetCrossNumModDirect(givenTNum, n *big.Int, p *PrimeGTE31, returnHereCrossNumMod *big.Int)

GetCrossNumModDirect : An alternative to GetCrossNumMod original, it uses a direct "mod" operation which then adjusts back to TNumbers crossing, basically "unwrapping" the expansions, result is returned in parameter, A bit less calculation and requires no floor function since effectiveTNum is not required, also see GetCrossNumModSimple, This DOES NOT return errors if you send in too small a TNumber because this routine is used very often in loops, caller needs to validate the TNumbers submitted are >= the p's startTemplateNumber

func GetCrossNumModSimple added in v1.2.0

func GetCrossNumModSimple(givenTNum, n *big.Int, p *PrimeGTE31, returnHereCrossNumMod *big.Int)

GetCrossNumModSimple : Another alternative to GetCrossNumMod original, but even slightly faster, found by inspection rather than derivation, also see GetCrossNumModDirect, This DOES NOT return errors if you send in too small a TNumber because this routine is used very often in loops, caller needs to validate the TNumbers submitted are >= the p's startTemplateNumber

func GetEffectDisplay

func GetEffectDisplay(symbol int) string

GetEffectDisplay : Return a user friendly string for symbol. used where only the effect is shown.

func GetEffectiveTNum

func GetEffectiveTNum(n *big.Int, p *PrimeGTE31, returnHereTNum *big.Int)

GetEffectiveTNum : "effective" TNumber is the TNumber where the square of the potential prime (p) resides, ie. where it begins its effect on the following TNumbers. It is the Start Template Number for the calculated potential GTE 31 primes

func GetEffectiveTNumSimple

func GetEffectiveTNumSimple(n *big.Int, p *PrimeGTE31, returnHereTNum *big.Int)

GetEffectiveTNumSimple : lighter alternative to GetEffectiveTNum: see note in GetEffectiveTNum

func GetFileInfosFromFolder

func GetFileInfosFromFolder(path string) ([]os.FileInfo, error)

GetFileInfosFromFolder : a func that gets a list of all files in given path

func GetFilesInFolder added in v1.2.0

func GetFilesInFolder(folder, ext string) ([]string, error)

GetFilesInFolder : Given a folder return slice of files in folder

func GetFilter

func GetFilter(filterType int) (pre, post uint)

GetFilter : Returns the pre & post filters for routines working with GTE 31 Primes

func GetFilter29

func GetFilter29(filterType int) (disallow, finalPass uint)

GetFilter29 : Returns the disallow & finalPass filters for routines working with LTE 29 Primes

func GetFilterAbbrev

func GetFilterAbbrev(filterType int) string

GetFilterAbbrev : abbreviation for filter types, usually used in file names

func GetFilterDesc

func GetFilterDesc(filterType int) string

GetFilterDesc : Human readable description for filter types, usually used in information and messages to the user

func GetLocalPrimes added in v1.2.0

func GetLocalPrimes()

GetLocalPrimes : helper for analysis routines, initializes the p## *PrimeGTE31 variables for direct use, can be called any number of times

func GetNfromInt

func GetNfromInt(rNum *big.Int, p *PrimeGTE31, returnedHereN *big.Int)

GetNfromInt : the compliment to GetNfromTNum where an Int (regular number line value) is used, rather than an already known Template Number. rNum is a "real" number, ie. a number line integer, not a Template Number, p is is a potential prime of type PrimeGTE31

func GetNfromIntComplicated

func GetNfromIntComplicated(rNum *big.Int, p *PrimeGTE31, returnedHereN *big.Int)

GetNfromIntComplicated : the compliment to GetNfromTNumComplicated where an Int (regular number line value) is used, rather than an already known Template Number. rNum is a "real" number, ie. a number line integer, not a Template Number. p is a PrimeGTE31

func GetNfromTNum

func GetNfromTNum(givenTNum *big.Int, p *PrimeGTE31, returnedHereN *big.Int)

GetNfromTNum : Given a TNum and a PrimeGTE31 the n value, ie how many potential primes must be tested to complete the calculation, Validation that givenTNum is equal to or greater than p's effective start TNumber is the responsibility of the calling func(), This is later derived algebraic equation that turns out to be far simpler and just as accurate, The first equation was quite complicated, see GetNfromTNumComplicated, result is returned in param and in p.Helper.MaxN

func GetNfromTNumComplicated

func GetNfromTNumComplicated(givenTNum *big.Int, p *PrimeGTE31, returnedHereN *big.Int)

GetNfromTNumComplicated : Given a TNum & PrimeGTE31 return the the n value, ie. how many potential primes must be tested, Validation that givenTNum is equal to or greater than p's effective start TNumber is the responsibility of the calling func(), to complete the calculation. This comes from the first derivation of the formula and is complicated in many ways (lots of roots), a simpler form was found, see GetNfromTNum, result is returned in param and in p.Helper.MaxN

func GetSymbolDisplay

func GetSymbolDisplay(symbol int) string

GetSymbolDisplay : Return a user friendly string for symbol, used where Symbol is displayed either screen or file.

func GetSymbolEnglish added in v1.2.0

func GetSymbolEnglish(symbol int) string

GetSymbolEnglish : Return the english phrase for the symbol, used where Symbol is displayed either screen or file.

func GetSymbolString

func GetSymbolString(symbol int, fullSymbol bool) string

GetSymbolString : Similar to GetSymbolDisplay. Return a user friendly string for symbol, with the addition of a less busy string for Sextuplets which is used if fullSymbol is false

func GetTNum29Basis added in v1.2.0

func GetTNum29Basis(tNum, basisnum *big.Int) *big.Int

func GetUserBoolChoice added in v1.2.0

func GetUserBoolChoice(prompt, deflt string, result *bool) (canceled bool)

GetUserBoolChoice : wraps GetUserInput to allow various true values

func GetUserConfirmation

func GetUserConfirmation(prompt, answer string) bool

GetUserConfirmation : basic confirmation "dialog"

func GetUserInput

func GetUserInput(prompt, defaultTo, cancel string) (string, bool)

GetUserInput : Good for basic input, returns the string the User enters. The calling func must deal with type verification

func GetUserInputInteger

func GetUserInputInteger(prompt, defaultTo, cancel string) (string, bool)

GetUserInputInteger : Get input and validate that answer is a Number. Loops forever unless canceled.

func HelpOutputFiles

func HelpOutputFiles()

HelpOutputFiles : func that returns juusprime file information to stdout

func HelpSymbols

func HelpSymbols()

HelpSymbols : Display the explanation and symbols used for Tuplets

func HelpSymbolsMath

func HelpSymbolsMath()

HelpSymbolsMath : Display how symbol "math" is done

func HumanReadable

func HumanReadable(tNum *big.Int, symbol *int, tNum29, notify *string, f *os.File)

HumanReadable : Output to f a neatly packaged human readable format of the found Tuplet's details, Using this one can translate a .rawdata file by sending in the Tnumber and the effect integer, tNum29 is the corresponding TNumber from the 29Basis file and must be calculated, and notify is any message that needs to be communicate, generally used to inform in the pretty file that a basis number change occurred, currently it does check using ProbablyPrime if the found primes are probably prime, pretty much useless since they must be! But at higher numbers it is worthwhile because it would show in the pretty data if an erroneous result (false negative) has ever been seen.

func InflatePrimeGTE31Position added in v1.2.0

func InflatePrimeGTE31Position(prime *PrimeGTE31, idx int, n, returnHereOffset *big.Int) (effect int)

InflatePrimeGTE31Position : Given any idx <= prime.value-1 use n to calculate its expanded position. This is similar to the Lookup Table where c + qn is used, but this can be for any position in the prime's cycle using the CQModel slice, used for analysis, offset result returned in parameter, effect at that pos in result

func InitGTE31

func InitGTE31(prime *PrimeGTE31)

InitGTE31 : fill in the appropriate data for the particular GTE 31 prime, in essence these are "constants" associated with that GTE 31 prime, they can be calculated with pen and paper

func IntToBasisNum

func IntToBasisNum(anInt, returnHereBasisNum *big.Int) error

IntToBasisNum : Given an integer, return the basis Number it will be found in to the passed in pointer param

func IntToTNum

func IntToTNum(rNum *big.Int) *big.Int

IntToTNum : given any integer return the TemplateNum where it will be found. Key function for this package.

func IsConfigured

func IsConfigured() bool

IsConfigured : check to see if config/paths have been setup, if false is returned then recommended to run Configure()

func JuusTestReadChunk added in v1.2.0

func JuusTestReadChunk(file string, buf int)

func NChooseK added in v1.2.0

func NChooseK(n, k int64) int

TODO:

func ReadConfig

func ReadConfig()

ReadConfig : open the configuration file and retrieve settings

func ScanPrimeTuplets added in v1.2.0

func ScanPrimeTuplets(auto *AutomationStruct) int

ScanPrimeTuplets : SLOW, EXPERIMENTAL For use with SCAN automation through code or shell scripts, etc, uses big.Probablyprime to pre-qualify tuplets for further investigation, useful for large basis Numbers, Pass in a filled automation structure

func ShowCombos added in v1.2.0

func ShowCombos(n int)

TODO:

func ShowMe

func ShowMe(choice int, p *PrimeGTE31, b *big.Int) error

ShowMe : testing and internal use, good to use when you want to see unexported variable results without a lot of bother

func ShowSymbolCounts

func ShowSymbolCounts(from, to *big.Int, filter int, f *os.File)

ShowSymbolCounts : Print out the SymbolCount map accumulated results

func ShowSymbolFileDesignations

func ShowSymbolFileDesignations(f *os.File)

ShowSymbolFileDesignations : a routine that assembles the pieces that are printed to the info file so people can understand the symbol strings in file names

func ShowTwinSextupletResults added in v1.0.1

func ShowTwinSextupletResults(twins *string, f *os.File)

ShowSymbolCounts : Print out the SymbolCount map accumulated results

func Slice2d added in v1.2.0

func Slice2d(dx, dy int) [][]string

template for a 2D slice strings, send in x, y

func Slice3d added in v1.2.0

func Slice3d(dx, dy, dz int) [][][]string

template for a 3D slice strings, send in x, y, z

func SymbolIsOfInterest

func SymbolIsOfInterest(symbol int) bool

SymbolIsOfInterest : basic filtering func, rejects any thing that is not a Tuple, only used in GeneratePrimes7to23()

func TNumLastNatNum

func TNumLastNatNum(tNum *big.Int) *big.Int

TNumLastNatNum : helper func that calculates the last natural number in a TNumber range

func TNumToBasisNum

func TNumToBasisNum(tNum, returnHereBasisNum *big.Int) error

TNumToBasisNum : Given a TNumber, return the basis Number it will be found in to the passed pointer param

func TNumToInt

func TNumToInt(tNum *big.Int) *big.Int

TNumToInt : given any Template Number return the number

Types

type ArtControl added in v1.2.0

type ArtControl struct {
	I         int
	Templates []int
	ArtPrimes []*ArtPrime
}

TODO:

func NewArtControl added in v1.2.0

func NewArtControl(interval int) *ArtControl

type ArtPrime added in v1.2.0

type ArtPrime struct {
	Value    int
	I, F     int
	NatProgs []int
}

func NewArtPrime added in v1.2.0

func NewArtPrime(interval, f int) *ArtPrime

type AutomationStruct added in v1.0.1

type AutomationStruct struct {
	BasisFile, OutputPath    string
	FromBasisNum, ToBasisNum string
	Filter                   int
}

AutomationStruct : used to pass automation params into automation routines

func GetNewAutomationStructure added in v1.0.1

func GetNewAutomationStructure() *AutomationStruct

GetNewAutomationStructure : return a pointer to an AutomationStruct

type CritSectID added in v1.2.0

type CritSectID struct {
	N *big.Int
	//actually relates to the idx, 0-7, of the 8 pP familes
	//but for traversing true crit sects a "sub"N more sense
	SubN int64
}

CritSectID : abbrev csID, Unique identifier for each Critical Section in format "n:subN", N is the usual n, subN is an index from 0 to 7 corresponding with the 8 potPrimes 31 to 59, while there are associated "math" routines the CS ID's have no 0 or negative value, ie., 0:0 is equivalent to 1 and stands for n=0, pP=31

func NewCritSectID added in v1.2.0

func NewCritSectID(n *big.Int, p *PrimeGTE31) *CritSectID

NewCritSectID : returns a pointer to a CritSectID struct, n >= 0, p is any PrimeGTE31, each of which have a constant "subN"

func (*CritSectID) Add added in v1.2.0

func (id *CritSectID) Add(csID *CritSectID)

Add : adds csID to id

func (*CritSectID) AsString added in v1.2.0

func (id *CritSectID) AsString() string

AsString : central func to return a string representation of the CritSectID

func (*CritSectID) Compare added in v1.2.0

func (id *CritSectID) Compare(csID *CritSectID) int

Compare : compares id with csID, returns -1 if <, 0 if =, +1 if greater

func (*CritSectID) GetTNumberRange added in v1.2.0

func (id *CritSectID) GetTNumberRange(from, to, L *big.Int)

GetTNumberRange : generally analysis use only, returns in params the corresponding from/to TNumber and its (inclusive) length (L)

func (*CritSectID) ID2Int added in v1.2.0

func (id *CritSectID) ID2Int() *big.Int

ID2Int : This gives back the integer representation of the csID allowing a unique integer for each csID, also math can be used and a csID can then be set from an the resulting integer, see SetFromInt

func (*CritSectID) Increment added in v1.2.0

func (id *CritSectID) Increment(value int) error

Increment : increments the csID by value, value must >= 0

func (*CritSectID) SetFromID added in v1.2.0

func (id *CritSectID) SetFromID(csID *CritSectID) error

SetFromID : Sets, copies, the id's values to those of csID

func (*CritSectID) SetFromInt added in v1.2.0

func (id *CritSectID) SetFromInt(value *big.Int) error

SetFromInt : Set the csID by an integer value, value is a corresponding integer of any csID, obtain it with ID2Int()

func (*CritSectID) SetFromString added in v1.2.0

func (id *CritSectID) SetFromString(value string) error

SetFromString : sets id's vars from a string representation of format "n:subN", eg. 0:0, 123:7, n >=0, subN is 0-7, only returns error if an invalid format otherwise adjusts to valid values

func (*CritSectID) SetFromTNumber added in v1.2.0

func (id *CritSectID) SetFromTNumber(tNumber *big.Int)

SetFromTNumber : Sets id's vars to the appropriate values based on tNumber

func (*CritSectID) String added in v1.2.0

func (id *CritSectID) String() string

Stringer for CritSectID

func (*CritSectID) Subtract added in v1.2.0

func (id *CritSectID) Subtract(csID *CritSectID) error

Subtract : subtracts csID from id, csID's have no 0, if the subtraction results in 0 or less id is set to 0:0 (equiv to 1), caller is reponsible to compare and only subtract if csID is < id

type GenPrimesStruct

type GenPrimesStruct struct {
	BasisNum    *big.Int
	DefaultPath string
	FilterType  int

	From                *big.Int
	FullPathto29RawFile string //only used for GTE 31s
	To                  *big.Int
	OpMode              int
	// contains filtered or unexported fields
}

GenPrimesStruct : A structure that can be filled in to control prime generation (both LTE 29's and GTE 31's, though the usage is slightly different), for GTE 31's it will call its Prepare() method which adjusts parameters based on OpMode and returns a proper filename

func NewGenPrimesStruct

func NewGenPrimesStruct() *GenPrimesStruct

NewGenPrimesStruct : returns a pointer to GenPrimesStruct which is used to control prime GTE 31's generation

func (*GenPrimesStruct) Prepare

func (ctrl *GenPrimesStruct) Prepare() (fileName string)

Prepare : Method for GenPrimesStruct which takes the OpMode and prepares proper settings, it returns a proper filename and fullpath, Always used for GTE 31's, LTE 29's are special and handled slightly differently, Generally no need to call this, it is done automatically when generating Tuplets

type PrimeGTE31

type PrimeGTE31 struct {
	Helper  *PrimeHelper
	Prime   *primeBase
	LookUp  *primeGT30Lookup
	CQModel []*PrimeGTE31InflationModel
	// contains filtered or unexported fields
}

PrimeGTE31 : Structure to use for primes greater than or equal to 31, the sextuplet program only uses this for primes 31, 37, 41, 43, 47, "49", 53, and 59, there are no need for others since these can do the checking for sextuplets via lookups all the way out to infinity + 1

func GetPrimeGTE31Slice added in v1.1.0

func GetPrimeGTE31Slice() []*PrimeGTE31

GetPrimeGTE31Slice : helper for analysis routines, gives back a slice of all Primes GTE 31, len = 8, so [0]-[7] is 31-59

func NewPrimeGTE31

func NewPrimeGTE31(prime *big.Int) *PrimeGTE31

NewPrimeGTE31 : Return a pointer to an initialized PrimeGTE31 prime is the prime value the variable will have.

func P31 added in v1.1.0

func P31() *PrimeGTE31

P31 : Call to get a *PrimeGTE31 for pP(31) for whatever purpose you like

func P37 added in v1.1.0

func P37() *PrimeGTE31

P37 : Call to get a *PrimeGTE31 for pP(37) for whatever purpose you like

func P41 added in v1.1.0

func P41() *PrimeGTE31

P41 : Call to get a *PrimeGTE31 for pP(41) for whatever purpose you like

func P43 added in v1.1.0

func P43() *PrimeGTE31

P43 : Call to get a *PrimeGTE31 for pP(43) for whatever purpose you like

func P47 added in v1.1.0

func P47() *PrimeGTE31

P47 : Call to get a *PrimeGTE31 for pP(47) for whatever purpose you like

func P49 added in v1.1.0

func P49() *PrimeGTE31

P49 : Call to get a *PrimeGTE31 for pP(49) for whatever purpose you like

func P53 added in v1.1.0

func P53() *PrimeGTE31

P53 : Call to get a *PrimeGTE31 for pP(53) for whatever purpose you like

func P59 added in v1.1.0

func P59() *PrimeGTE31

P59 : Call to get a *PrimeGTE31 for pP(59) for whatever purpose you like

func (*PrimeGTE31) DisplayFullCritLengths added in v1.2.0

func (prime *PrimeGTE31) DisplayFullCritLengths(fixedN *big.Int)

DisplayFullCritLengths : analysis use, testing, checking Will show first from 0 to fixedN-1, then from fixedN+1 to 0 the number of Templates between each diff of fixedN +/- n and will also display the appropriate offsets of each n level to the fixedN border, careful, large fixedN means lots and lots of output

func (*PrimeGTE31) GetCritLength added in v1.2.0

func (prime *PrimeGTE31) GetCritLength(abs bool, fixedN, n, returnHereLen *big.Int) error

GetCritLength : analysis use, critlen here is only between members of the same family, see GetCritLen for between families, given fixedN (a chosen, fixed n level), and n the n-level you want to compare to, calculate the number of Templates between them, prime is a *PrimeGTE31, and abs flag is whether to return the absolute value, result is returned in last parameter

func (*PrimeGTE31) GetCritLengthByDiff added in v1.2.0

func (prime *PrimeGTE31) GetCritLengthByDiff(abs bool, N, diff, returnHereLen *big.Int) error

GetCritLengthByDiff : analysis use, critlen here is only between members of the same family, return the total number of Templates for potPrime p between fromN and toN, toN can be less than fromN, if abs is true return the length's absolute value, result returned in last param,

func (*PrimeGTE31) GetQbyReverseInflation added in v1.2.0

func (prime *PrimeGTE31) GetQbyReverseInflation(n, offset, returnHereQ *big.Int) error

GetQbyReverseInflation : takes n and offset from other routines and returns, in the parameter, a q appropriate for that n, the q is used to "deconstruct" an inflated potPrime so that the offset can be re-traced to its actual natural progression position so that its effect can be retrieved, this is a VERY INEFFICIENT func, and is meant for testing and analyis only, it has been used to search for sextuplets and returns correct results, Lookup tables are the efficient way to see whether an offset has an effect of interest, if offset is in an inflated region then returns -1 in param

func (*PrimeGTE31) GetResultAtCrossNum

func (prime *PrimeGTE31) GetResultAtCrossNum(addResult *int, offset, n *big.Int) bool

GetResultAtCrossNum : tests the GTE 31 primes at the given offset (crossing number) for the applicable effect, addResult is changed and will be accumulated in the calling function, n is the current n-level (0 based) one is testing, offset is calculated by GetCrossNumModDirect() or GetCrossNumMod()

func (*PrimeGTE31) GetResultAtCrossNumByReverseInflation added in v1.2.0

func (prime *PrimeGTE31) GetResultAtCrossNumByReverseInflation(addResult *int, offset, n *big.Int) bool

GetResultAtCrossNumByReverseInflation : Alternative to GetResultAtCrossNum(), Used for testing and analysis because it is very inefficient and slow, It uses GetQbyReverseInflation() which re-contructs the inflation at n to get the q needed to take the offset back to its natural progression index to get its effect, addResult is changed and will be accumulated in the calling function, n is the current n-level (0 based) one is testing, offset is calculated by GetCrossNumModDirect() or GetCrossNumMod()

func (*PrimeGTE31) InflateCrossingNum added in v1.2.0

func (prime *PrimeGTE31) InflateCrossingNum(crossNum int, n, returnHereInflated *big.Int) int

InflateCrossingNum : Given a natural progression crossing number and n return in parameter the inflated value for the crossing and in result the effect at those crossing numbers, this func is intended for analysis

func (*PrimeGTE31) MemberAtN added in v1.1.0

func (p *PrimeGTE31) MemberAtN(n, returnMember *big.Int)

MemberAtN : return the member of the potPrime family at n, e.g. family 31, n=0 return 31, n=1 return 61, n=2 return 91, etc.

func (*PrimeGTE31) ShowDetails

func (prime *PrimeGTE31) ShowDetails(withPausing bool)

ShowDetails : print to screen all the GTE 31 details

func (*PrimeGTE31) String

func (prime *PrimeGTE31) String() string

Stringer for PrimeGTE31

func (*PrimeGTE31) SubN added in v1.2.0

func (prime *PrimeGTE31) SubN() int64

Value : Getter for a prime's value

type PrimeGTE31InflationModel added in v1.2.0

type PrimeGTE31InflationModel struct {
	Q30     int
	CEffect int
	//rather than have to look ahead to the next index position, I store
	//this value to help the routine and keep it simple
	Wait bool
}

PrimeGTE31InflationModel : This models a natural progression such that one can project forward to any n any position in the natural Progression and/or reverse engineer, or de-inflate, an inflated potPrime, used for analysis and testing, it also holds effect information, Wait is used as a helper var when re-constructing the q var, which is the inflation factor which is then based on n level, see note in code at the getPrimeGTE31InflationModel() func

type PrimeHelper added in v1.0.1

type PrimeHelper struct {
	//can use this to control "n" looping
	MaxN *big.Int
}

PrimeHelper struct : holds variables that don't belong properly to a prime's properties, but that can be useful in calculations, looping, etc.

type PrimeIF

type PrimeIF interface {
	// contains filtered or unexported methods
}

PrimeIF : interface for the prime struct's and useful methods, experimental, needs to be developed

type PrimeLTE29

type PrimeLTE29 struct {
	Prime          *primeBase
	CrossNumEffect map[*big.Int]int
}

PrimeLTE29 : Structure to use for primes 7 to less than or equal to 29. Primes LTE 29 are useful only in generating the sequence showing all possible prime sextuplets (the 29Basis)

func NewPrimeLTE29

func NewPrimeLTE29(prime *big.Int) *PrimeLTE29

NewPrimeLTE29 : Return a pointer to an initialized PrimeLTE29 prime is the prime value the variable will have.

func (*PrimeLTE29) GetEffect

func (prime *PrimeLTE29) GetEffect(crossingNum *big.Int) int

GetEffect : Given the prime's crossing number return the effect the crossing has for that Template Number. These are "constants" in the sense that for each prime the patterns repeat forever, These numbers came from on paper analysis, We assumes it is being compared to the 2,3,5 template and, so, against a Sextuplet

func (*PrimeLTE29) ShowDetails

func (prime *PrimeLTE29) ShowDetails(withPausing bool)

ShowDetails : produce the details in mod & counting numbers of how the prime will effect the Prime Templates

func (*PrimeLTE29) ShowRawDetails

func (prime *PrimeLTE29) ShowRawDetails()

ShowRawDetails : display the basic data of the prime structure and the "raw" crossing effects. Natural progressions are derived from this data.

func (*PrimeLTE29) String

func (prime *PrimeLTE29) String() string

Stringer for PrimeLTE29

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL