diff options
| author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2025-09-22 16:44:29 -0500 |
|---|---|---|
| committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2025-09-22 16:46:05 -0500 |
| commit | bec087c3855f1641ac3681d56c9f8247aa556d2e (patch) | |
| tree | 19b07482d8519326954b8a1acac310ccc4b1847c | |
| parent | d3fdb797db81ab81c4f91dd88d24723a88b39c2e (diff) | |
Add option to show logarithmic RC
This makes finding the RC of prime powers multiplication instead of
exponentation, which is much easier to do mentally.
| -rw-r--r-- | CHANGELOG.org | 1 | ||||
| -rw-r--r-- | README.org | 2 | ||||
| -rw-r--r-- | args.go | 15 | ||||
| -rw-r--r-- | factor_info.go | 16 |
4 files changed, 26 insertions, 8 deletions
diff --git a/CHANGELOG.org b/CHANGELOG.org index f26ba87..a53c84c 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -12,3 +12,4 @@ All notable changes to this software will be put in this changelog. - Compact display, and other cmdline arguments (-d, -f, -m, -t) - Program can calculate radices' totative digits. - Program can score radices' regulars like it does their factors. +- Program can calculate prime factors' regular complexities. @@ -100,6 +100,8 @@ This number measures how easy it is to work with powers of /n/ in radix /r/ - th (The exact value for both of these is \(\textrm{MPM}(r, n^e) / n^e\) - the RC simply condenses all the powers into a single number.) The Radix Info Script shows the complexity for all of the base's prime factors, not every number, in order to keep the output reasonably small. The regular complexity of a product of prime powers will be smaller than the largest of the multiplicands' complexities - prime powers are the worst case. + +If the ~-l~ argument is used, the program will display the base-2 logarithm of the complexities. This means that you can calculate the complexity of prime powers by multiplying by the power, instead of exponentiating (hard to do mentally!). ** Copyright & Contact Info radix_info: gives some information about number radices Copyright (C) 2023 Adrien Hopkins @@ -27,12 +27,13 @@ const ProgramVersion = "1.0.0-rc.1" // The arguments to this program type args struct { - Radix uint - Compact bool - FullMap bool - ExactMTCLarge bool - TotativeDigits bool - DigitMapOnly bool + Radix uint + Compact bool + FullMap bool + ExactMTCLarge bool + TotativeDigits bool + DigitMapOnly bool + LogRegularComplexities bool // If true, exit the program immediately after parsing args. Exit bool } @@ -45,6 +46,8 @@ func parseArgs() (args, error) { flag.BoolVar(&a.FullMap, "f", false, fmt.Sprintf("Show full digit map (up to %d) for every radix", maxSmallRadix)) + flag.BoolVar(&a.LogRegularComplexities, "l", false, + "Show the base-2 logarithm of the regular complexities") flag.BoolVar(&a.ExactMTCLarge, "m", false, fmt.Sprintf("Calculate exact MTC for very large radices (up to %d instead of %d), which may take a while.", maxExtended, maxNormal)) diff --git a/factor_info.go b/factor_info.go index 638e333..ae3b60a 100644 --- a/factor_info.go +++ b/factor_info.go @@ -68,6 +68,8 @@ type factorInfo struct { // The memorization for the product of prime powers // is less than the memorization of worst part of the product. PrimeRegularComplexities map[uint]float64 + // If true, the above field is the log2 of its true value. + LogRegularComplexities bool } const ( @@ -114,11 +116,17 @@ func getFactorInfo(a args) *factorInfo { totativeRatio := float64(totativeCount) / float64(radix) var prcs = factors.PrimeRegularComplexities(radix) + if a.LogRegularComplexities { + for regular := range prcs { + prcs[regular] = math.Log2(prcs[regular]) + } + } return &factorInfo{radix, factors.PrimeFactorize(radix), r_factors, factors.Score(radix), totativeCount, totativeRatio, totativeDigits, factors.BasicRank(radix), factors.Type(radix), - mtc_ptr, math.Log2(float64(radix)), digitMap, prcs} + mtc_ptr, math.Log2(float64(radix)), digitMap, prcs, + a.LogRegularComplexities} } func (fi *factorInfo) writeTo(w io.Writer) { @@ -148,7 +156,11 @@ func (fi *factorInfo) writeTo(w io.Writer) { fmt.Fprintf(w, "Base-2 Logarithm: %.3f\n", fi.Log2) fmt.Fprintf(w, "Number Length: %.4f×Decimal\n", 1/math.Log10(float64(fi.Radix))) - fmt.Fprint(w, "Prime Regular Complexities: ") + if fi.LogRegularComplexities { + fmt.Fprint(w, "log2(Prime Regular Complexities): ") + } else { + fmt.Fprint(w, "Prime Regular Complexities: ") + } writePRCMap(w, fi.PrimeRegularComplexities) fmt.Fprintln(w) if len(fi.DigitMap) > 0 { |
