metanum 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -4
- package/format-metanum.js +213 -184
- package/metanum.js +627 -408
- package/package.json +30 -32
- package/test_mixed.js +316 -12
package/format-metanum.js
CHANGED
|
@@ -63,17 +63,10 @@ function regularFormat(num, precision) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// ─── MetaNum-Specific Polarize ───────────────────────────────────
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
// r0[3] = count of G operations (level 3), etc.
|
|
71
|
-
//
|
|
72
|
-
// In binary form αΓβ:
|
|
73
|
-
// bottom = α (mantissa in [1, 10))
|
|
74
|
-
// top = β (integer exponent)
|
|
75
|
-
// height = Γ level (1=E, 2=F, 3=G, ..., 22=Z)
|
|
76
|
-
// repeat = count of repeated operations at the highest level (>1 means repeated letters)
|
|
66
|
+
// r0 is [base, e, f, g, ...]: r0[0] is the argument, r0[1..] count the E/F/G…
|
|
67
|
+
// operations (levels 1, 2, 3, …). Binary form αΓβ: bottom = α (mantissa in
|
|
68
|
+
// [1,10)), top = β, height = Γ (1=E … 22=Z), repeat = count of repeated
|
|
69
|
+
// operations at the highest level (>1 means repeated letters).
|
|
77
70
|
function metaPolarize(r0, num) {
|
|
78
71
|
if (FORMAT_DEBUG >= 1) console.log("metaPolarize input:", JSON.stringify(r0))
|
|
79
72
|
if (r0.length === 0) r0 = [0]
|
|
@@ -289,25 +282,20 @@ function letterName(height) {
|
|
|
289
282
|
}
|
|
290
283
|
|
|
291
284
|
// ─── Letter token with the multiLetterLimit symbol carry ──────────
|
|
292
|
-
// A k-letter combination (Aa, Aaa,
|
|
293
|
-
//
|
|
294
|
-
//
|
|
295
|
-
//
|
|
296
|
-
// ω-exponent (k-1) and α's digits are the CNF coefficients — exactly the
|
|
297
|
-
// digits of the letter itself (uppercase index, then the lowercase indices),
|
|
298
|
-
// which keeps the diagonal mantissa inside [2,10) for the cascades.
|
|
285
|
+
// A k-letter combination (Aa, Aaa, …) sits at level ω^(k-1). Past
|
|
286
|
+
// FORMAT_OPTIONS.multiLetterLimit the notation switches to the symbol form
|
|
287
|
+
// !αAaβ: β is the top ω-exponent (k-1), α's digits are the CNF coefficients
|
|
288
|
+
// (the letter's own digits), keeping the diagonal mantissa inside [2,10).
|
|
299
289
|
function letterTokenOf(height) {
|
|
300
290
|
let plain = letterName(height)
|
|
301
291
|
let limit = Math.max(2, FORMAT_OPTIONS.multiLetterLimit | 0)
|
|
302
292
|
if (plain.length <= limit) return { sym: "", letter: plain, arg: 0, mant: null }
|
|
303
|
-
// The carried form is "!" + the
|
|
304
|
-
//
|
|
305
|
-
//
|
|
306
|
-
//
|
|
307
|
-
//
|
|
308
|
-
//
|
|
309
|
-
// exhausted (!ZZZYYY{maxSafeInteger}) does the notation fall back to the
|
|
310
|
-
// coarser !αAaβ form.
|
|
293
|
+
// The carried form is "!" + the single-letter αΓβ: "!" adds one ω^ layer
|
|
294
|
+
// on top of Γ, so a diagonal Aaa…a (= ω^k, too long for multiLetterLimit)
|
|
295
|
+
// becomes !αHβ with H = the finite level k (!2.000Aa4 = !1H10 = 10{ω^4}10
|
|
296
|
+
// vs 2.000Aa4 = 1H10 = 10{4}10); β is the argument (ω³*50/100/200 stay
|
|
297
|
+
// apart as !1H51/!1H101/!1H201). Only when the single-letter chain is
|
|
298
|
+
// exhausted does it fall back to the coarser !αAaβ form.
|
|
311
299
|
let expo = plain.length - 1
|
|
312
300
|
if (expo >= 1 && expo <= 22) {
|
|
313
301
|
return { sym: "!", letter: letterName(expo), arg: expo, mant: 1, useBeta: true }
|
|
@@ -343,22 +331,15 @@ function symbolName(layer) {
|
|
|
343
331
|
}
|
|
344
332
|
|
|
345
333
|
// ─── Ordinal Letter: Extract letter name from ordinal rows ───────
|
|
346
|
-
//
|
|
347
|
-
//
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
|
|
351
|
-
//
|
|
352
|
-
//
|
|
353
|
-
//
|
|
354
|
-
//
|
|
355
|
-
|
|
356
|
-
// Snap CNF coefficients (little-endian [a1, a2, …, ak], ordinal
|
|
357
|
-
// ω^(k-1)·ak + … + ω·a2 + a1) to the ones the letter grid can name:
|
|
358
|
-
// every ai must satisfy 0 ≤ ai ≤ 25 and the top ak ≤ 26. Larger
|
|
359
|
-
// coefficients carry UP — ω*2+96 → ω*3 (Ca), ω*99 → ω² (Aaa),
|
|
360
|
-
// ω²*100 → ω³ (Aaaa) — so an unnamed ordinal displays as the next
|
|
361
|
-
// nameable one above it, never as a lower/wrong letter.
|
|
334
|
+
// Format A (3+ elements): [count, v1..vN, diag] — diag 1-26 (A-Z, uppercase),
|
|
335
|
+
// v1..vN 0-25 (a-z, lowercase), count = repetition count.
|
|
336
|
+
// Format B (2 elements): [count, value] — count at ω-level, value the
|
|
337
|
+
// ordinal level number (901 means ω*901); letter is always "Aa".
|
|
338
|
+
|
|
339
|
+
// Snap CNF coefficients (little-endian [a1..ak], ordinal ω^(k-1)·ak+…+a1) to
|
|
340
|
+
// the ones the letter grid can name: 0 ≤ ai ≤ 25, top ak ≤ 26. Larger
|
|
341
|
+
// coefficients carry UP (ω*2+96 → ω*3 (Ca), ω*99 → ω² (Aaa), ω²*100 → ω³
|
|
342
|
+
// (Aaaa)), so an unnamed ordinal displays as the next nameable one above it.
|
|
362
343
|
function snapCoeffsToGrid(coeffs) {
|
|
363
344
|
let r = (coeffs || []).slice()
|
|
364
345
|
// little-endian ORDINAL carry: index 0 is the constant term. A term above
|
|
@@ -420,11 +401,10 @@ function getOrdinalLetter(ordRows) {
|
|
|
420
401
|
|
|
421
402
|
// ─── Reference Polarize (verbatim port of PowiainaNum's myPolarize) ──
|
|
422
403
|
// Recovers the display α ("bottom") and the diagonal level ("arrows") of an
|
|
423
|
-
// r0 chain STRUCTURALLY,
|
|
424
|
-
//
|
|
425
|
-
//
|
|
426
|
-
//
|
|
427
|
-
// ours: r0 = [base, cnt1, cnt2, ...] where cnt_i = count at level i
|
|
404
|
+
// r0 chain STRUCTURALLY, climbing log10 level by level — the only method that
|
|
405
|
+
// stays exact at high levels where the engine's fractional-arg bisect
|
|
406
|
+
// quantizes (level ≥ 20). Ground truth: format-powiainanum.js. Their array
|
|
407
|
+
// [base, [level, count, 1, 1], …] maps to our r0 = [base, cnt1, cnt2, …].
|
|
428
408
|
function refPolarizeArraySort(array) {
|
|
429
409
|
array.sort(function (a, b) {
|
|
430
410
|
if (typeof a == 'number') return
|
|
@@ -544,21 +524,16 @@ function refPolarize(array, hasOperationRepeat = true) {
|
|
|
544
524
|
}
|
|
545
525
|
}
|
|
546
526
|
// Convert a finite-chain polarize triple (bottom, repeation, arrows) into the
|
|
547
|
-
//
|
|
548
|
-
// (
|
|
549
|
-
//
|
|
550
|
-
//
|
|
551
|
-
// t
|
|
552
|
-
//
|
|
553
|
-
// t
|
|
554
|
-
//
|
|
555
|
-
//
|
|
556
|
-
//
|
|
557
|
-
// Truncation-marker normalization for finite rows: when the engine truncated
|
|
558
|
-
// an overflow cascade it reset r0 to [10] and bumped the LOWEST kept row's
|
|
559
|
-
// count by 1 over the uniform per-level fill (xCnt). That +1 marks the
|
|
560
|
-
// dropped tail, not a real operation — read the row as carrying xCnt so
|
|
561
|
-
// truncated displays match the untruncated anchor (cross-config stability).
|
|
527
|
+
// diagonal-letter display pair (mantissa, β). The value behaves as
|
|
528
|
+
// 10{arrows+1}(t), t = log10(bottom)+repeation; the diagonal convention is
|
|
529
|
+
// α = 2·5^f ∈ [2,10):
|
|
530
|
+
// t ∈ [2,10) -> mantissa t, β = arrows (3{100}3 -> 2.376Aa99)
|
|
531
|
+
// t ≥ 10 -> one level per smooth-log step f → 1+log10(f); the anchor
|
|
532
|
+
// t=10 is mantissa 2 at β=arrows+1 (10{100}10 -> 2.000Aa100)
|
|
533
|
+
// t ∈ [1,2) -> mantissa 2·5^(t-1), β = arrows-1
|
|
534
|
+
// Truncation marker: a truncated cascade resets r0 to [10] and bumps the
|
|
535
|
+
// lowest kept row's count by 1 over the uniform fill (xCnt) — read it as xCnt
|
|
536
|
+
// so truncated displays match the untruncated anchor.
|
|
562
537
|
function normalizedFiniteRows(r0, finiteRows) {
|
|
563
538
|
if (!finiteRows || finiteRows.length === 0 || r0[0] !== 10) return finiteRows
|
|
564
539
|
let sorted = finiteRows.slice().sort((a, b) => a[1] - b[1])
|
|
@@ -630,6 +605,57 @@ function formatR0ArgStr(argStr) {
|
|
|
630
605
|
return null
|
|
631
606
|
}
|
|
632
607
|
|
|
608
|
+
// De-layered !Aa x instance (decision 1B): the shape [[x],[1,0×k,1]] with
|
|
609
|
+
// k = max(1, floor(x)), x >= 1. Per the README the display is the APPROXIMATE
|
|
610
|
+
// binary form !α'Aa'β' (β' = floor(x), α' = 2·5^(x−β') ∈ [2,10)) — the
|
|
611
|
+
// mantissa carries only FORMAT_OPTIONS digits, so the round-trip recovers x
|
|
612
|
+
// to that precision (issue #20: tolerance-based assertion). An INTEGER x has
|
|
613
|
+
// α' = 2 exactly, and the binary spelling now denotes the ω^n diagonal
|
|
614
|
+
// cascade (issue #19), so it shows the exact letter token A(a×k)x instead.
|
|
615
|
+
// Returns null for every other shape (x < 2 included — the no-"!" binary form
|
|
616
|
+
// comes from formatOrdinal).
|
|
617
|
+
function formatBangAaValue(num, precision) {
|
|
618
|
+
if (num.sign !== 1 || num.layer !== 0) return null
|
|
619
|
+
let a = num.array
|
|
620
|
+
if (a.length !== 2 || a[0].length !== 1) return null
|
|
621
|
+
let x = a[0][0]
|
|
622
|
+
if (typeof x !== 'number' || !isFinite(x) || x < 2) return null
|
|
623
|
+
let row = a[1]
|
|
624
|
+
if (row.length < 3 || row[0] !== 1 || row[row.length - 1] !== 1) return null
|
|
625
|
+
for (let i = 1; i < row.length - 1; i++) if (row[i] !== 0) return null
|
|
626
|
+
let k = row.length - 2
|
|
627
|
+
if (k !== Math.max(1, Math.floor(x))) return null
|
|
628
|
+
if (x === Math.floor(x)) {
|
|
629
|
+
// integer anchor: the letter token A(a×k)x is the exact spelling
|
|
630
|
+
return "A" + "a".repeat(k) + formatR0Arg(x, precision)
|
|
631
|
+
}
|
|
632
|
+
let beta = Math.floor(x)
|
|
633
|
+
let mant = 2 * Math.pow(5, x - beta)
|
|
634
|
+
return "!" + regularFormat(mant, precision) + "Aa" + formatR0Arg(beta, precision)
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
// The full rule-3 cascade of 10{ω^n}10 (n ≥ 2) — the stored form of !Aa<n>
|
|
638
|
+
// (issue #19: "!" adds one ω^, so !Aa3 = 10{ω^3}10). A cheap shape pre-filter
|
|
639
|
+
// (base [10], full row budget, top row [8, 9×n]) plus an exact comparison
|
|
640
|
+
// against the engine's own cascade, so nothing else matches. Displayed as the
|
|
641
|
+
// binary diagonal !2.000Aa<n>, which parses back to the same cascade.
|
|
642
|
+
function formatAaCascade(num, precision) {
|
|
643
|
+
if (num.sign !== 1 || num.layer !== 0) return null
|
|
644
|
+
let a = num.array
|
|
645
|
+
if (a.length !== MetaNum.maxRows || a.length < 3) return null
|
|
646
|
+
if (a[0].length !== 1 || a[0][0] !== 10) return null
|
|
647
|
+
let last = a[a.length - 1]
|
|
648
|
+
let n = last.length - 1
|
|
649
|
+
if (n < 2 || last[0] !== 8) return null
|
|
650
|
+
for (let i = 1; i < last.length; i++) if (last[i] !== 9) return null
|
|
651
|
+
let coeffs = []
|
|
652
|
+
for (let i = 0; i < n; i++) coeffs.push(0)
|
|
653
|
+
coeffs.push(1)
|
|
654
|
+
let ref = MetaNum._hyperopFromOrdinalRaw(MetaNum.TEN, MetaNum.TEN, coeffs)
|
|
655
|
+
if (!ref.eq(num)) return null
|
|
656
|
+
return "!" + regularFormat(2, precision) + "Aa" + formatR0Arg(n, precision)
|
|
657
|
+
}
|
|
658
|
+
|
|
633
659
|
function format(num, precision=3, small=false) {
|
|
634
660
|
if (MetaNum.isNaN(num)) return "NaN"
|
|
635
661
|
let sciSigDigits = FORMAT_OPTIONS.sciSignificantDigits // for E notation
|
|
@@ -645,14 +671,11 @@ function format(num, precision=3, small=false) {
|
|
|
645
671
|
if (num.sign < 0) return "-" + format(num.neg(), precision, small)
|
|
646
672
|
if (num.isInfinite()) return "Infinity"
|
|
647
673
|
|
|
648
|
-
// Sub-unit values (sign 2 / -2,
|
|
649
|
-
//
|
|
650
|
-
//
|
|
651
|
-
//
|
|
652
|
-
//
|
|
653
|
-
// (r0 = [2000], value 5e-4) came out as "2.000E-3" instead of "5.000E-4".
|
|
654
|
-
// Structured sign-2 forms (layer > 0, ordinal rows, power-tower r0) keep the
|
|
655
|
-
// letter-law path further down.
|
|
674
|
+
// Sub-unit values (sign 2 / -2, 0 < |v| < 1): a plain finite r0 stores the
|
|
675
|
+
// RECIPROCAL, so the real value is 1/r0 — format that number (decimals at
|
|
676
|
+
// or above 10^-smallNotationThreshold, αE-β below). Reading the raw r0
|
|
677
|
+
// printed the reciprocal (MetaNum(1).div(2000) → "2.000E-3"). Structured
|
|
678
|
+
// sign-2 forms keep the letter-law path below.
|
|
656
679
|
if ((num.sign === 2 || num.sign === -2) && num.layer === 0 &&
|
|
657
680
|
num.array.length === 1 && num.array[0].length === 1 &&
|
|
658
681
|
isFinite(num.array[0][0]) && num.array[0][0] !== 0) {
|
|
@@ -688,16 +711,12 @@ function format(num, precision=3, small=false) {
|
|
|
688
711
|
return prefix + regularFormat(mant, sciMantissaPrecision(expPart)) + "E-" + commaFormat(expPart)
|
|
689
712
|
}
|
|
690
713
|
}
|
|
691
|
-
// Tier 2: mag is large → "E-" + letter-law form of mag
|
|
692
|
-
// log10 of the reciprocal base.
|
|
693
|
-
//
|
|
694
|
-
//
|
|
695
|
-
//
|
|
696
|
-
//
|
|
697
|
-
// Γ ≥ G (G200): log10 = G200 (Γβ−1+1 = Γβ: the leading
|
|
698
|
-
// F(G(β−1)) collapses back to G(β))
|
|
699
|
-
// Roundtrip exact: "E-1.000G200" parses back to 1/G200,
|
|
700
|
-
// "E-1.000F499" to 1/F500 (test_mixed format block)
|
|
714
|
+
// Tier 2: mag is large → "E-" + the letter-law form of mag
|
|
715
|
+
// (= log10 of the reciprocal base). A chain of n same-level
|
|
716
|
+
// ops collapses to ONE next-level op with arg+n, so log10
|
|
717
|
+
// shifts only the OUTERMOST letter (EE1000 → E1000, F500 →
|
|
718
|
+
// F499, G200 → G200). Roundtrip exact: "E-1.000G200" parses
|
|
719
|
+
// back to 1/G200.
|
|
701
720
|
var recipStr = format(recipFmt, precision, small)
|
|
702
721
|
var magStr = recipStr
|
|
703
722
|
// leading run of E letters (e.g. "EE1.000E1,000"): strip one E
|
|
@@ -795,6 +814,12 @@ function format(num, precision=3, small=false) {
|
|
|
795
814
|
// ── Handle ordinal rows (Aa, Ab, ..., Aaa, ... range) ──
|
|
796
815
|
let hasOrdinalRows = array.length > 1
|
|
797
816
|
if (hasOrdinalRows) {
|
|
817
|
+
let bang = formatBangAaValue(num, multiPrecision)
|
|
818
|
+
if (bang !== null) return bang
|
|
819
|
+
// issue #19: the full 10{ω^n}10 cascade (stored !Aa<n>) — display the
|
|
820
|
+
// binary diagonal so the parser round-trips it
|
|
821
|
+
let cascade = formatAaCascade(num, multiPrecision)
|
|
822
|
+
if (cascade !== null) return cascade
|
|
798
823
|
return formatOrdinal(num, precision, multiPrecision)
|
|
799
824
|
}
|
|
800
825
|
|
|
@@ -887,17 +912,24 @@ function formatLayer(num, precision, precision2, precision3, precision4) {
|
|
|
887
912
|
return innerStr + "ε" + commaFormat(num.layer)
|
|
888
913
|
}
|
|
889
914
|
|
|
915
|
+
// issue #19: the 10{ω^n}10 cascade at a symbol layer — the stored form of
|
|
916
|
+
// @Aa<n> (layer 1), #Aa<n> (layer 2), … ONE symbol per value: the symbol
|
|
917
|
+
// index is the total ω^-layer count (layer 0 → "!", 1 → "@", 2 → "#"),
|
|
918
|
+
// never a stack ("@!…" is invalid). The body is the same binary diagonal
|
|
919
|
+
// the layer-0 form uses, so the display stays isomorphic to !Aa<n>.
|
|
920
|
+
let cascadeStr = formatAaCascade(inner, precision4)
|
|
921
|
+
if (cascadeStr !== null) {
|
|
922
|
+
let body = cascadeStr.slice(1) // strip the layer-0 "!"
|
|
923
|
+
if (num.layer < SYMBOLS.length) return SYMBOLS[num.layer] + body
|
|
924
|
+
return body + "ε" + commaFormat(num.layer + 1)
|
|
925
|
+
}
|
|
926
|
+
|
|
890
927
|
// Compact diagonal: the symbol row [1,0…0,1] with m=compactBase zeros is
|
|
891
|
-
// 10{ω^m}10 — a DIAGONAL letter (A + m a's) at argument 10
|
|
892
|
-
//
|
|
893
|
-
//
|
|
894
|
-
//
|
|
895
|
-
//
|
|
896
|
-
// multiLetterLimit symbol carry: once the diagonal letter would be longer
|
|
897
|
-
// than the limit (m+1 letters) it switches to one more symbol and the Aa
|
|
898
|
-
// argument takes over the exponent — 10{ω^10}10 → !2.000Aa10, and layer 1
|
|
899
|
-
// on top stacks the symbols (no-symbol → ! → @ → # …):
|
|
900
|
-
// apix(3,10) = 10{ω^(ω^10)}10 → @2.000Aa10.
|
|
928
|
+
// 10{ω^m}10 — a DIAGONAL letter (A + m a's) at argument 10, with the pure
|
|
929
|
+
// dlsdl α=2·5^f ∈ [2,10) convention (integer m anchors mantissa 2). For
|
|
930
|
+
// layers above ! the symbol of the layer below prefixes the same inner
|
|
931
|
+
// form (!Aa3 = 2.000Aaaa10, @Aa3 = !2.000Aaaa10); past multiLetterLimit the
|
|
932
|
+
// Aa argument takes over the exponent (10{ω^10}10 → !2.000Aa10).
|
|
901
933
|
if (canCompact && compactBase >= 2) {
|
|
902
934
|
let mInt = Math.floor(compactBase)
|
|
903
935
|
let frac = compactBase - mInt
|
|
@@ -914,11 +946,11 @@ function formatLayer(num, precision, precision2, precision3, precision4) {
|
|
|
914
946
|
if (total <= SYMBOLS.length) return SYMBOLS[total - 1] + body
|
|
915
947
|
return body + "ε" + commaFormat(total)
|
|
916
948
|
}
|
|
917
|
-
// Stored layer L
|
|
918
|
-
//
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
return
|
|
949
|
+
// Stored layer L: exactly ONE symbol per ω^ layer (symbolName(L));
|
|
950
|
+
// stacking symbols ("@!…") is invalid (issue #19). The body is the
|
|
951
|
+
// diagonal letter A(a×m)10 at the smooth mantissa. (Layers past the
|
|
952
|
+
// symbol list already returned through the ε branch above.)
|
|
953
|
+
return symbolName(num.layer) + regularFormat(mant, precision4) +
|
|
922
954
|
"A" + "a".repeat(mInt) + "10"
|
|
923
955
|
}
|
|
924
956
|
|
|
@@ -972,10 +1004,9 @@ function formatR0Arg(value, precision) {
|
|
|
972
1004
|
|
|
973
1005
|
// ─── Gamma-Arg Recovery ─────────────────────────────────────────
|
|
974
1006
|
// Recover the real argument x with 10{level}x = v (the Γ-canonical argument of
|
|
975
|
-
// v at letter `level`)
|
|
976
|
-
//
|
|
977
|
-
//
|
|
978
|
-
// ~45 doublings before the bracket closes.
|
|
1007
|
+
// v at letter `level`) by bisection on the engine's smooth arrow curve. null
|
|
1008
|
+
// when x exceeds the double-precision bisect range; the doubling guard runs to
|
|
1009
|
+
// 200 (hardy(1120)'s F-arg ≈ 4.4e13 needs ~45 doublings).
|
|
979
1010
|
function gammaArgOf(v, level, iters) {
|
|
980
1011
|
if (iters === undefined) iters = 60
|
|
981
1012
|
let G = function (x) { return MetaNum(10).arrow(level)(x) }
|
|
@@ -1034,14 +1065,11 @@ function distinctLetterTypes(str) {
|
|
|
1034
1065
|
}
|
|
1035
1066
|
|
|
1036
1067
|
// ─── Format r0 as Chain ────────────────────────────────────────
|
|
1037
|
-
// Formats r0 = [base, e, f, g, ...] as a dlsdl
|
|
1038
|
-
//
|
|
1039
|
-
//
|
|
1040
|
-
//
|
|
1041
|
-
//
|
|
1042
|
-
// diagonal letter (Aa = ω, Ba = ω·2, Aaa = ω², …) and its binary form has
|
|
1043
|
-
// α = 2·5^f ∈ [2,10) — the diagonal 10{23}10 reads "2.000Aa23", never
|
|
1044
|
-
// "1.000Aa23". Every other letter keeps the ordinary [1,10) mantissa.
|
|
1068
|
+
// Formats r0 = [base, e, f, g, ...] as a dlsdl chain: outerLetters + α +
|
|
1069
|
+
// lastLetter + β, with α = 10^(base-floor(base)) and β = floor(base)
|
|
1070
|
+
// (EE200 → "E1.000E200", FE400 → "F1.000E400"). A letter ending in "a" is a
|
|
1071
|
+
// diagonal letter (Aa = ω, Ba = ω·2, Aaa = ω², …) and its binary form uses
|
|
1072
|
+
// α = 2·5^f ∈ [2,10) — 10{23}10 reads "2.000Aa23", never "1.000Aa23".
|
|
1045
1073
|
function diagonalMantissa(letter, mantissa) {
|
|
1046
1074
|
if (letter && letter.charAt(letter.length - 1) === 'a') {
|
|
1047
1075
|
let f = mantissa - Math.floor(mantissa)
|
|
@@ -1084,17 +1112,14 @@ function formatR0AsChain(r0, precision, used) {
|
|
|
1084
1112
|
}
|
|
1085
1113
|
|
|
1086
1114
|
// ── ≤2-letter-types rule ──
|
|
1087
|
-
// When the full
|
|
1088
|
-
//
|
|
1089
|
-
//
|
|
1090
|
-
//
|
|
1091
|
-
//
|
|
1092
|
-
//
|
|
1093
|
-
//
|
|
1094
|
-
//
|
|
1095
|
-
// 5{9}5 → "LLLKK4.669K4" (user: "LLLKK…K…")
|
|
1096
|
-
// A top count ≥ repeatLetterThreshold+1 carries to the next single
|
|
1097
|
-
// letter instead (6{9}6 → "5.760M5" via the collapse paths below).
|
|
1115
|
+
// When the full spelling would use MORE than two letter types, spell only
|
|
1116
|
+
// the top two levels' letters and compress everything below into the
|
|
1117
|
+
// second letter's binary-canonical form "bottom Γ₂ repeation" (the
|
|
1118
|
+
// polarize triple; bisect fails there — the arg exceeds double range):
|
|
1119
|
+
// 3{9}3 → "L2.376K2", 3{10}3 → "M2.376L2",
|
|
1120
|
+
// 4{9}4 → "LLK3.550K3", 5{9}5 → "LLLKK4.669K4".
|
|
1121
|
+
// A top count ≥ repeatLetterThreshold+1 carries to the next single letter
|
|
1122
|
+
// (6{9}6 → "5.760M5").
|
|
1098
1123
|
if (maxLevel >= 2 && maxLevel <= 22 && count <= effThreshold) {
|
|
1099
1124
|
let spellTypes = 0
|
|
1100
1125
|
for (let s = 2; s <= maxLevel; s++) {
|
|
@@ -1209,17 +1234,14 @@ function formatR0AsChain(r0, precision, used) {
|
|
|
1209
1234
|
}
|
|
1210
1235
|
|
|
1211
1236
|
// ── Γ-canonical recovery (2-letter rule) ──
|
|
1212
|
-
// Two rules, both driven by the engine's own smooth arrow curve:
|
|
1213
1237
|
// (a) structural top count < threshold AND inner top < maxLevel: keep
|
|
1214
|
-
// the
|
|
1215
|
-
//
|
|
1216
|
-
// VαEβ → VαFβ → … → VαVβ, never a mixed "VFαEβ").
|
|
1238
|
+
// the top letter Γᵀ bare and format the inner chain recursively (at
|
|
1239
|
+
// most 2 letter types: VαEβ → VαFβ → … → VαVβ, never "VFαEβ").
|
|
1217
1240
|
// (b) otherwise: collapse to the single letter Γ = the HIGHEST level L
|
|
1218
|
-
// whose recovered argument
|
|
1219
|
-
//
|
|
1220
|
-
//
|
|
1221
|
-
//
|
|
1222
|
-
// to ONE Γ^{L+1} with arg+n (F^4(G(1.3796)) = G(5.3796) — bisect-exact).
|
|
1241
|
+
// whose recovered argument (bisect 10{L}x = v) is ≥ 2, in binary form
|
|
1242
|
+
// αΓβ (hardy(4166) → "2.397G5", arrow(3,4.3,3) → "1.285H8").
|
|
1243
|
+
// Verified law: n ops of level L on a Γ^{L+1}-structured value collapse to
|
|
1244
|
+
// ONE Γ^{L+1} with arg+n (F^4(G(1.3796)) = G(5.3796)).
|
|
1223
1245
|
let r0Num = new MetaNum({ sign: 1, layer: 0, array: [r0.slice(0)] })
|
|
1224
1246
|
|
|
1225
1247
|
if (count < effThreshold && maxLevel >= 2 && runLen <= effThreshold) {
|
|
@@ -1248,12 +1270,11 @@ function formatR0AsChain(r0, precision, used) {
|
|
|
1248
1270
|
if (innerR0[it] > 0) { innerTop = it; break }
|
|
1249
1271
|
}
|
|
1250
1272
|
if (innerTop < maxLevel) {
|
|
1251
|
-
// ≤2 letter types rule: count the distinct letter
|
|
1252
|
-
//
|
|
1253
|
-
//
|
|
1254
|
-
//
|
|
1255
|
-
// "
|
|
1256
|
-
// spells only L and K, the M..J part collapses into K's arg).
|
|
1273
|
+
// ≤2 letter types rule: count the distinct letter types the
|
|
1274
|
+
// peeled prefix + innerStr would use. If the inner chain spells a
|
|
1275
|
+
// THIRD type, collapse it to the binary form at maxLevel-1 —
|
|
1276
|
+
// VαEβ → VαFβ → … → VαVβ, never a mixed "VFαEβ" (arrow(3,9,3) →
|
|
1277
|
+
// "L2.376K2": the M..J part collapses into K's arg).
|
|
1257
1278
|
let topLetter = letterName(maxLevel)
|
|
1258
1279
|
let innerTypes = distinctLetterTypes(innerStr)
|
|
1259
1280
|
if (innerTypes.length >= 2
|
|
@@ -1290,12 +1311,11 @@ function formatR0AsChain(r0, precision, used) {
|
|
|
1290
1311
|
}
|
|
1291
1312
|
}
|
|
1292
1313
|
|
|
1293
|
-
// (b) collapse: the structural chain (n repeats of the top letter Γᵀ on
|
|
1294
|
-
//
|
|
1295
|
-
// compresses to ONE Γᵀ⁺¹ with arg+n — bisect at the
|
|
1296
|
-
//
|
|
1297
|
-
//
|
|
1298
|
-
// arrow(3,4.3,3) → "1.285H8")
|
|
1314
|
+
// (b) collapse: the structural chain (n repeats of the top letter Γᵀ on an
|
|
1315
|
+
// inner value whose canonical letter is Γᵀ⁺¹, e.g. F^895(G(2.06)))
|
|
1316
|
+
// compresses to ONE Γᵀ⁺¹ with arg+n — bisect at the structural next letter
|
|
1317
|
+
// first (maxLevel+1); if its arg falls below 2, search upward for the
|
|
1318
|
+
// highest level whose arg ≥ 2 (hardy(4166) → "2.397G5").
|
|
1299
1319
|
let structuralNext = Math.min(maxLevel + 1, 22)
|
|
1300
1320
|
let sx = gammaArgOf(r0Num, structuralNext, 40)
|
|
1301
1321
|
if (sx !== null && isFinite(sx) && sx >= 2) {
|
|
@@ -1334,12 +1354,11 @@ function formatR0AsChain(r0, precision, used) {
|
|
|
1334
1354
|
// bare letter + canonical argument (single α at the innermost value)
|
|
1335
1355
|
return newLetter + formatR0Arg(newTop + Math.log10(bottom < 1 ? Math.pow(10, bottom) : bottom), precision)
|
|
1336
1356
|
}
|
|
1337
|
-
// Format: α + letter + β.
|
|
1338
|
-
//
|
|
1339
|
-
//
|
|
1340
|
-
//
|
|
1341
|
-
//
|
|
1342
|
-
// (issues.md: hardy(4150) → "2.300G5", not "1.000G5")
|
|
1357
|
+
// Format: α + letter + β. Canonical all-8s arrays (from the 10^10
|
|
1358
|
+
// base: G600, ZZ10, …) carry no recoverable mantissa below 10^10, so
|
|
1359
|
+
// α = 1.000 by construction; every other value recovers its real α by
|
|
1360
|
+
// stripping newTop slog's — the residue in [1,10) is exactly the α of
|
|
1361
|
+
// αΓβ = Γ(β+log α) (hardy(4150) → "2.300G5").
|
|
1343
1362
|
let alpha = 1.0
|
|
1344
1363
|
let all8s = (r0[0] === 10000000000)
|
|
1345
1364
|
for (let ai = 2; ai < pol.height && all8s; ai++) {
|
|
@@ -1406,15 +1425,14 @@ function formatR0AsChain(r0, precision, used) {
|
|
|
1406
1425
|
|
|
1407
1426
|
// ─── Format with Ordinal Rows ────────────────────────────────────
|
|
1408
1427
|
|
|
1409
|
-
// finite-row chain display (≤2-letter-types rule):
|
|
1410
|
-
//
|
|
1411
|
-
// top level ≥ 23 (Aa region): the αAaβ diagonal
|
|
1412
|
-
//
|
|
1413
|
-
//
|
|
1414
|
-
// 10{10000}10 → "1.000Aa10,000" (bottom 1, repeation 10 carries).
|
|
1428
|
+
// finite-row chain display (≤2-letter-types rule): r0 cols + [count, level]
|
|
1429
|
+
// rows form one hyperoperation cascade.
|
|
1430
|
+
// top level ≥ 23 (Aa region): the αAaβ diagonal from polarizeFiniteChain,
|
|
1431
|
+
// mantissa normalized into [1,10) carrying decades into β:
|
|
1432
|
+
// 3{24}3 → "2.376Aa23", 3{100}3 → "2.376Aa99", 10{10000}10 → "1.000Aa10,000".
|
|
1415
1433
|
// top level ≤ 22 (single letters): the structural two-letter form
|
|
1416
1434
|
// Γ_top×c₁ + Γ_second×(c₂−1) + bottom + Γ_second + repeation:
|
|
1417
|
-
// 3{22}3 → "Y2.376X2", 3{23}3 → "Z2.376Y2"
|
|
1435
|
+
// 3{22}3 → "Y2.376X2", 3{23}3 → "Z2.376Y2".
|
|
1418
1436
|
// c₁ ≥ repeatLetterThreshold+1 carries to the next single letter.
|
|
1419
1437
|
function formatFiniteRowChain(r0, finiteRows, precision) {
|
|
1420
1438
|
function levelCount(lv) {
|
|
@@ -1495,6 +1513,25 @@ function formatFiniteRowChain(r0, finiteRows, precision) {
|
|
|
1495
1513
|
}
|
|
1496
1514
|
}
|
|
1497
1515
|
|
|
1516
|
+
// ── Repeated top letter over a dominant lower level ──
|
|
1517
|
+
// When the top row is only a prefix (count ≤ threshold) but a lower row
|
|
1518
|
+
// holds the real argument, polarizeFiniteChain collapses the chain and the
|
|
1519
|
+
// top argument degenerates (ZZ152416 read "1.000Z3"). Spell the top row as
|
|
1520
|
+
// prefix letters and format the remaining chain on its own, keeping the
|
|
1521
|
+
// real argument (ZZ152416 → "Z1.000Z152,416").
|
|
1522
|
+
let topRow = finiteRows[finiteRows.length - 1]
|
|
1523
|
+
if (finiteRows.length >= 2 && topRow && topRow[1] === topLv &&
|
|
1524
|
+
Number.isInteger(topRow[0]) && topRow[0] >= 1 && topRow[0] <= effThreshold) {
|
|
1525
|
+
let restR0 = r0.slice(0)
|
|
1526
|
+
for (let i = 0; i < finiteRows.length - 1; i++) {
|
|
1527
|
+
let r = finiteRows[i]
|
|
1528
|
+
while (restR0.length <= r[1]) restR0.push(0)
|
|
1529
|
+
restR0[r[1]] = r[0]
|
|
1530
|
+
}
|
|
1531
|
+
let innerStr = formatR0AsChain(restR0, precision)
|
|
1532
|
+
if (innerStr) return letterName(topLv).repeat(topRow[0]) + innerStr
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1498
1535
|
// fallback: single binary at the top letter
|
|
1499
1536
|
let polF = polarizeFiniteChain(r0, finiteRows)
|
|
1500
1537
|
if (polF && isFinite(polF.bottom) && polF.bottom >= 1) {
|
|
@@ -1546,13 +1583,9 @@ function formatOrdinal(num, precision, precision4) {
|
|
|
1546
1583
|
totalAaCount += row[0] || 1
|
|
1547
1584
|
}
|
|
1548
1585
|
if (allAaOnly && totalAaCount > 0) {
|
|
1549
|
-
// Build the
|
|
1550
|
-
//
|
|
1551
|
-
//
|
|
1552
|
-
// 2-letter (Aa): aaZeroCount=1, height=23
|
|
1553
|
-
// 3-letter (Aaa): aaZeroCount=2, height=699
|
|
1554
|
-
// 4-letter (Aaaa): aaZeroCount=3, height=...
|
|
1555
|
-
// Calculate the correct baseHeight for this letter:
|
|
1586
|
+
// Build the letter "A" + "a".repeat(aaZeroCount) (Aa, Aaa, Aaaa, …):
|
|
1587
|
+
// for ordinal rows diag=1 → "A" and each val 0 → "a", so
|
|
1588
|
+
// aaZeroCount = vals length (Aa → 1, height 23; Aaa → 2, height 699).
|
|
1556
1589
|
let baseHeight
|
|
1557
1590
|
if (aaZeroCount === 1) {
|
|
1558
1591
|
baseHeight = 23 // Aa
|
|
@@ -1650,13 +1683,11 @@ function formatOrdinal(num, precision, precision4) {
|
|
|
1650
1683
|
} else {
|
|
1651
1684
|
// Single DIAGONAL letter (the row ends in 'a': Aa, Aaa,
|
|
1652
1685
|
// Ba, …): pure dlsdl convention α=2·5^f ∈ [2,10).
|
|
1653
|
-
//
|
|
1654
|
-
//
|
|
1655
|
-
//
|
|
1656
|
-
// - ordinary letter application: base is the argument β
|
|
1657
|
-
// (Aa100 -> 2.000Aa100)
|
|
1686
|
+
// Decision 1B: the base is the ARGUMENT β (the row zero count
|
|
1687
|
+
// encodes the letter level). !Aa3 = Aaaa3 therefore reads
|
|
1688
|
+
// "2.000Aaaa3" — not the historical anchor-A "2.000Aaaa10".
|
|
1658
1689
|
let diagMant = 2 * Math.pow(5, base - Math.floor(base))
|
|
1659
|
-
let diagBeta =
|
|
1690
|
+
let diagBeta = top
|
|
1660
1691
|
// multiLetterLimit symbol carry: A + aaZeroCount a's is
|
|
1661
1692
|
// aaZeroCount+1 letters — past the limit the diagonal reads as
|
|
1662
1693
|
// one more symbol with the SINGLE letter of the finite level
|
|
@@ -1672,11 +1703,10 @@ function formatOrdinal(num, precision, precision4) {
|
|
|
1672
1703
|
|
|
1673
1704
|
// ── Unnamed-level display (v2.0.2) ──
|
|
1674
1705
|
// The letter grid only names ordinals with coefficients ≤ 25 (top ≤ 26).
|
|
1675
|
-
// When the TOP row's ordinal is above that (ω*2+96, ω*99, ω²*100, …)
|
|
1676
|
-
// row
|
|
1677
|
-
//
|
|
1678
|
-
//
|
|
1679
|
-
// as level-arg: the snapped level with the operation's own argument —
|
|
1706
|
+
// When the TOP row's ordinal is above that (ω*2+96, ω*99, ω²*100, …) every
|
|
1707
|
+
// row snaps up to the SAME next nameable level, and summing their counts
|
|
1708
|
+
// would collapse the letter further (243 Ca's → Cb(244)) — overstating the
|
|
1709
|
+
// level and hiding the argument. Instead the value reads as level-arg:
|
|
1680
1710
|
// 10{ω*2+100}100 → "1.000Ca100", 10{ω*100}100 → "1.000Aaa100",
|
|
1681
1711
|
// 10{ω²*100+ω*100+100}1000 → "1.000Aaaa1,000".
|
|
1682
1712
|
let gapStr = null
|
|
@@ -1703,15 +1733,15 @@ function formatOrdinal(num, precision, precision4) {
|
|
|
1703
1733
|
for (let gj = 0; gj < gvals.length; gj++) gn += gvals[gj] * Math.pow(26, gj)
|
|
1704
1734
|
gh = 23 + goffset + gn
|
|
1705
1735
|
}
|
|
1706
|
-
// β = the fundamental-sequence index
|
|
1707
|
-
// from the snapped level.
|
|
1708
|
-
//
|
|
1736
|
+
// β = the fundamental-sequence index recovering the ordinal
|
|
1737
|
+
// from the snapped level. Carry in the TOP coefficient
|
|
1738
|
+
// (ω^p·c → ω^(p+1)): the index is c+1 —
|
|
1709
1739
|
// 10{ω²·50+ω·100+100}100 → "2.000Aaaa51"
|
|
1710
1740
|
// 10{ω²·100+ω·100+100}100 → "2.000Aaaa101"
|
|
1711
1741
|
// 10{ω²·200+…}100 → "2.000Aaaa201"
|
|
1712
|
-
// (
|
|
1713
|
-
//
|
|
1714
|
-
//
|
|
1742
|
+
// (the largest coefficient collapsed all three into one
|
|
1743
|
+
// string). Carry BELOW the top (ω·2+100 → ω·3): the index is
|
|
1744
|
+
// the operation's argument.
|
|
1715
1745
|
let gbeta = (topRow[0] || 1) + 2
|
|
1716
1746
|
for (let g2 = oc.length - 1; g2 >= 0; g2--) {
|
|
1717
1747
|
let gc2 = Math.round(oc[g2])
|
|
@@ -1946,15 +1976,14 @@ function formatOrdinal(num, precision, precision4) {
|
|
|
1946
1976
|
|
|
1947
1977
|
if (heights.length >= 1) {
|
|
1948
1978
|
// ── Display rules (README "format-metanum rules (v2.0)") ──
|
|
1949
|
-
// * the rows are a COMPOSITION: the top row
|
|
1950
|
-
//
|
|
1951
|
-
//
|
|
1952
|
-
// every lower row compresses into that inner argument);
|
|
1979
|
+
// * the rows are a COMPOSITION: the top row leads and the row
|
|
1980
|
+
// below supplies the single α and β (at most TWO letter
|
|
1981
|
+
// types — lower rows compress into that inner argument);
|
|
1953
1982
|
// * "+count collapse": count >= multiLetterRepeatThreshold+1
|
|
1954
|
-
// repeats
|
|
1955
|
-
//
|
|
1956
|
-
// * stacking the same function
|
|
1957
|
-
// poea(10,poea(10,100))
|
|
1983
|
+
// repeats collapse to ONE next letter with arg count+1
|
|
1984
|
+
// (F⁴(G(1.3796)) = G(5.3796));
|
|
1985
|
+
// * stacking the same function nests the letter:
|
|
1986
|
+
// poea(10,poea(10,100)) → "Ad1.000Ad99";
|
|
1958
1987
|
// * a combination longer than multiLetterLimit carries to the
|
|
1959
1988
|
// symbol notation !αAaβ.
|
|
1960
1989
|
let effTh = Math.max(2, FORMAT_OPTIONS.multiLetterRepeatThreshold)
|