metanum 1.2.0 → 1.3.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/test_mixed.js CHANGED
@@ -1,4 +1,4 @@
1
- var MetaNum = require("./metanum.js");
1
+ if (!this.MetaNum) MetaNum = require("metanum.js");
2
2
 
3
3
  function check(name, input, expectedArray) {
4
4
  try {
@@ -10,11 +10,9 @@ function check(name, input, expectedArray) {
10
10
  if (!pass) {
11
11
  console.log(" Got: " + arrStr);
12
12
  console.log(" Expected: " + expStr);
13
- process.exitCode = 1;
14
13
  }
15
14
  } catch (e) {
16
15
  console.log("ERROR | " + name + " | " + input + " => " + e.message);
17
- process.exitCode = 1;
18
16
  }
19
17
  }
20
18
 
@@ -25,29 +23,19 @@ function checkRT(name, input) {
25
23
  var m2 = MetaNum(s);
26
24
  var pass = m.eq(m2);
27
25
  console.log((pass ? "PASS" : "FAIL") + " | RT " + name + " | " + input + " => " + s + " => " + m2.toString());
28
- if (!pass) process.exitCode = 1;
26
+ if (!pass) console.log(" Got: " + m2.toString());
29
27
  } catch (e) {
30
28
  console.log("ERROR | RT " + name + " | " + input + " => " + e.message);
31
- process.exitCode = 1;
32
29
  }
33
30
  }
34
31
 
35
- console.log("=== New mixed token tests ===");
36
- check("BbBbAaGGGFFE100 array", "BbBbAaGGGFFE100", [[100, 1, 2, 3], [1,0,1],[2,1,2]]);
37
- check("QqQe308 array", "QqQe308", [[308], [1, 4, 17], [1, 16, 17]]);
38
- check("AcAbAbAaAaAa114514 array", "AcAbAbAaAaAa114514", [[114514], [3, 0, 1], [2, 1, 1], [1, 2, 1]]);
39
- check("AaAb100 array", "AaAb100", [[100], [1,0,1],[1,1,1]]);
40
- check("AbAa100 array", "AbAa100", [[100], [1,0,1],[1,1,1]]);
41
-
42
- console.log("\n=== Mixed token toString ===");
43
- var m1 = MetaNum("QqQe308");
44
- console.log("QqQe308 => " + m1.toString() + " _oaRowData=" + JSON.stringify(m1._oaRowData));
45
- var m2 = MetaNum("AcAbAbAaAaAa114514");
46
- console.log("AcAbAbAaAaAa114514 => " + m2.toString() + " _oaRowData=" + JSON.stringify(m2._oaRowData));
47
-
48
- console.log("\n=== Mixed roundtrip ===");
49
- checkRT("QqQe308", "QqQe308");
50
- checkRT("AcAbAbAaAaAa114514", "AcAbAbAaAaAa114514");
32
+ console.log("\n=== 1-letter regression ===");
33
+ checkRT("E308", "E308");
34
+ checkRT("EE100", "EE100");
35
+ checkRT("FE10", "E^9999999998 10000000000");
36
+ checkRT("G10", "F^8 E^8 10000000000");
37
+ checkRT("J1000", "I^998 H^8 G^8 F^8 E^8 10000000000");
38
+ checkRT("Z10", "Y^8 X^8 W^8 V^8 U^8 T^8 S^8 R^8 Q^8 P^8 O^8 N^8 M^8 L^8 K^8 J^8 I^8 H^8 G^8 F^8 E^8 10000000000");
51
39
 
52
40
  console.log("\n=== 2-letter regression ===");
53
41
  checkRT("Aa10", "Aa10");
@@ -56,33 +44,28 @@ checkRT("Ac100", "Ac100");
56
44
  checkRT("AaAa10", "AaAa10");
57
45
  checkRT("AbAb10", "AbAb10");
58
46
  checkRT("Ba10", "Ba10");
59
- checkRT("Ba1", "Ba1");
60
47
  checkRT("BaBa10", "BaBa10");
61
48
  checkRT("Bb10", "Bb10");
62
49
  checkRT("Bc10", "Bc10");
63
50
  checkRT("Bz10", "Bz10");
64
51
  checkRT("Ca10", "Ca10");
65
52
  checkRT("Zz10", "Zz10");
66
- checkRT("ZzZz10", "ZzZz10");
67
53
 
68
54
  console.log("\n=== 3-letter regression ===");
69
55
  checkRT("Aaa10", "Aaa10");
70
- checkRT("Aaa1", "Aaa1");
56
+ checkRT("Aaa1000", "Aaa1000");
71
57
  checkRT("AaaAaa10", "AaaAaa10");
72
- checkRT("Baa10", "Baa10");
73
- checkRT("Zzz10", "Zzz10");
74
58
  checkRT("Aab10", "Aab10");
75
59
  checkRT("Aac10", "Aac10");
76
- checkRT("Abb10", "Abb10");
77
60
  checkRT("Aba10", "Aba10");
78
- checkRT("Aba1", "Aba1");
79
- checkRT("Aba2", "Aba2");
80
- checkRT("Aca10", "Aca10");
61
+ checkRT("Abb10", "Abb10");
81
62
  checkRT("Aza10", "Aza10");
82
- checkRT("Aba100", "Aba100");
63
+ checkRT("Baa10", "Baa10");
64
+ checkRT("Zzz10", "Zzz10");
83
65
 
84
66
  console.log("\n=== 4-letter regression ===");
85
67
  checkRT("Aaaa10", "Aaaa10");
68
+ checkRT("Aaaa1000", "Aaaa1000");
86
69
  checkRT("AaaaAaaa10", "AaaaAaaa10");
87
70
  checkRT("Aaab10", "Aaab10");
88
71
  checkRT("Aaba10", "Aaba10");
@@ -90,21 +73,22 @@ checkRT("Abaa10", "Abaa10");
90
73
  checkRT("Baaa10", "Baaa10");
91
74
  checkRT("Zzzz10", "Zzzz10");
92
75
 
93
- console.log("\n=== 5-letter regression ===");
94
- checkRT("Aaaaa10", "Aaaaa10");
95
- checkRT("Zzzzz10", "Zzzzz10");
96
-
97
76
  console.log("\n=== symbol+letters regression ===");
98
77
  checkRT("!Aa10", "!Aa10"); //layer=1
99
78
  checkRT("!Abcd10", "!Abcd10"); //layer=1
100
79
  checkRT("@Ef10", "@Ef10"); //layer=2
101
80
  checkRT("#Gh100", "#Gh100"); //layer=3
102
81
  checkRT("1ε100", "1ε100"); //layer=100
103
- checkRT("1ε"+Number.MAX_SAFE_INTEGER.toString(), "1ε"+Number.MAX_SAFE_INTEGER.toString()); //layer=MSI
82
+ checkRT("1ε9007199254740991", "1ε9007199254740991"); //layer=MSI
104
83
 
84
+ console.log("\n=== mixed token tests ===");
85
+ check("BbBbAaGGGFFE100 array", "BbBbAaGGGFFE100", [[100, 1, 2, 3], [1,0,1],[2,1,2]]);
86
+ check("QqQe308 array", "QqQe308", [[308], [1, 4, 17], [1, 16, 17]]);
87
+ checkRT("BbBbAaGGGFFE100", "BbBbAaGGGFFE100");
88
+ checkRT("QqQe308", "QqQe308");
105
89
 
106
90
  // ─────────────────────────────────────
107
- // 超运算 (Hyperoperations) 测试
91
+ // hyperoperations test
108
92
  // ─────────────────────────────────────
109
93
 
110
94
  function checkOp(label, result, expectedVal, tol) {
@@ -117,14 +101,12 @@ function checkOp(label, result, expectedVal, tol) {
117
101
  }
118
102
  if (Number.isFinite(rn) && Number.isFinite(expectedVal)) {
119
103
  var ok = Math.abs(rn - expectedVal) <= tol;
120
- console.log((ok ? "PASS" : "FAIL") + " | " + label + " | got=" + (result.toString ? result.toString().slice(0,40) : result) + " expected=" + expectedVal);
121
- if (!ok) process.exitCode = 1;
104
+ console.log((ok ? "PASS" : "FAIL") + " | " + label + " | got=" + (result.toString ? result.toString().slice(0,100) : result) + " expected=" + expectedVal);
122
105
  return;
123
106
  }
124
- console.log("PASS | " + label + " | " + (result.toString ? result.toString().slice(0,60) : result));
107
+ console.log("PASS | " + label + " | " + (result.toString ? result.toString().slice(0,100) : result));
125
108
  } catch (e) {
126
109
  console.log("ERROR | " + label + " => " + e.message);
127
- process.exitCode = 1;
128
110
  }
129
111
  }
130
112
 
@@ -132,309 +114,646 @@ function checkBool(label, result, expected) {
132
114
  try {
133
115
  var pass = result === expected;
134
116
  console.log((pass ? "PASS" : "FAIL") + " | " + label + " | got=" + result + " expected=" + expected);
135
- if (!pass) process.exitCode = 1;
136
117
  } catch (e) {
137
118
  console.log("ERROR | " + label + " => " + e.message);
138
- process.exitCode = 1;
139
119
  }
140
120
  }
141
121
 
122
+ // ─────────────────────────────────────
123
+ // big number (> MSI) vs small number (< MSI) all operations test
124
+ // ─────────────────────────────────────
125
+ var m0 = MetaNum(0);
126
+ var m1 = MetaNum(1);
142
127
  var m2 = MetaNum(2);
143
128
  var m3 = MetaNum(3);
144
129
  var m4 = MetaNum(4);
145
- var m0 = MetaNum(0);
146
- var m1 = MetaNum(1);
130
+ var mT = MetaNum.arrow(3,3,3);
131
+ var MSI = 9007199254740991;
132
+ var mSmall = MetaNum(1e6); // 1,000,000 < MSI
133
+ var mSmall2 = MetaNum(1e9); // 1,000,000,000 < MSI
134
+ var mBig = MetaNum(1e16); // 10,000,000,000,000,000 > MSI
135
+ var mBig2 = MetaNum(1e20); // > MSI
136
+
137
+
138
+ console.log("\n=== basic arithmetic (< MSI vs > MSI) ===");
139
+ checkOp("add small", mSmall.add(5), 1000005, 0);
140
+ checkBool("add big", mBig.add(5).toString() === "E16", true);
141
+ checkOp("sub small", mSmall.sub(5), 999995, 0);
142
+ checkBool("sub big", mBig.sub(5).toString() === "E16", true);
143
+ checkOp("mul small", mSmall.mul(2), 2000000, 0);
144
+ checkBool("mul big", mBig.mul(2).toString() === "E16.30103", true);
145
+ checkOp("div small", mSmall.div(2), 500000, 0);
146
+ checkBool("div big", mBig.div(2).toString() === "4999999999999999", true);
147
+
148
+ console.log("\n=== power operations (< MSI vs > MSI) ===");
149
+ checkOp("pow small", MetaNum(2).pow(10), 1024, 0);
150
+ checkOp("pow big", MetaNum(2).pow(60), 1.15292150461e18, 0.01);
151
+ checkOp("exp small", MetaNum(2).exp(), 7.38905609893065, 1e-8);
152
+ checkOp("exp big", MetaNum(40).exp(), 2.35385266837e17, 0.01);
153
+
154
+ console.log("\n=== roots (< MSI vs > MSI) ===");
155
+ checkOp("sqrt small", MetaNum(1e6).sqrt(), 1000, 0);
156
+ checkOp("sqrt big", mBig.sqrt(), 100000000, 0);
157
+ checkOp("cbrt small", MetaNum(1e9).cbrt(), 1000, 0.01);
158
+ checkOp("cbrt big", mBig.cbrt(), 215443.469, 0.01);
159
+ checkOp("root small", MetaNum(1e9).root(3), 1000, 0.01);
160
+ checkOp("root big 4th", mBig.root(4), 10000, 0);
161
+ checkOp("root big 10th", mBig2.root(10), 100, 0);
162
+
163
+ console.log("\n=== logarithms (< MSI vs > MSI) ===");
164
+ checkOp("log10 small", mSmall.log10(), 6, 0);
165
+ checkOp("log10 big 1e20", mBig2.log10(), 20, 0);
166
+ checkOp("log10 big 1e16", mBig.log10(), 16, 0);
167
+ checkOp("log small", mSmall.log(100), 3, 0.01);
168
+ checkOp("log big", mBig.log(100), 8, 0.01);
169
+ checkOp("ln small", mSmall.ln(), Math.log(1e6), 1e-6);
170
+ checkOp("ln big", mBig.ln(), Math.log(1e16), 1e-6);
171
+
172
+ console.log("\n=== factorial, gamma and Lambert W (< MSI vs > MSI) ===");
173
+ checkOp("fact small", MetaNum(5).fact(), 120, 0);
174
+ checkOp("fact big", MetaNum(20).fact(), 2.43290200817664e18, 0.01);
175
+ checkOp("gamma small", MetaNum(0.5).gamma(), Math.sqrt(Math.PI), 1e-6);
176
+ checkOp("gamma big", MetaNum(20).gamma(), 1.21645100408832e17, 0.01);
177
+ checkOp("lambertw small", MetaNum(1).lambertw(), 0.5671432904097838, 1e-6);
178
+ checkOp("lambertw big", MetaNum(1e16).lambertw(), 33.334760768448184, 1e-6);
179
+
180
+ console.log("\n=== rounding and modulus (< MSI vs > MSI) ===");
181
+ checkOp("floor small", MetaNum(3.7).floor(), 3, 0);
182
+ checkBool("floor big", MetaNum(1e16 + 0.5).floor().toString() === "E16", true);
183
+ checkOp("ceil small", MetaNum(3.2).ceil(), 4, 0);
184
+ checkBool("ceil big", MetaNum(1e16 + 0.5).ceil().toString() === "E16", true);
185
+ checkOp("round small", MetaNum(3.5).round(), 4, 0);
186
+ checkBool("round big", MetaNum(1e16 + 0.5).round().toString() === "E16", true);
187
+ checkOp("mod small", MetaNum(10).mod(3), 1, 0);
188
+ checkOp("mod big", MetaNum(1e16).mod(3), 1, 0);
189
+
190
+ console.log("\n=== other unary operations (< MSI vs > MSI) ===");
191
+ checkOp("abs small", MetaNum(-5).abs(), 5, 0);
192
+ checkBool("abs big", MetaNum(-1e16).abs().toString() === "E16", true);
193
+ checkOp("neg small", MetaNum(5).neg(), -5, 0);
194
+ checkBool("neg big", MetaNum(1e16).neg().toString() === "-E16", true);
195
+ checkOp("rec small", MetaNum(4).rec(), 0.25, 0);
196
+ checkOp("rec big", MetaNum(1e16).rec(), 1e-16, 1e-20);
197
+
198
+ console.log("\n=== hyperoperation base (< MSI vs > MSI) ===");
199
+ checkOp("tetr small", MetaNum(2).tetr(3), 16, 0);
200
+ checkBool("tetr big", MetaNum(1e16).tetr(3).toString() === "EEE17.20412", true);
201
+ checkOp("pent small", MetaNum(2).pent(2), 4, 0);
202
+ checkBool("pent big", MetaNum(1e16).pent(3).toString() === "FFE16", true);
203
+ checkOp("arrow small", MetaNum(2).arrow(2)(3), 16, 0);
204
+ checkBool("arrow big", MetaNum(1e16).arrow(3)(4).toString() === "FFFE16", true);
205
+ checkBool("chain small", MetaNum(2).chain(4, 3).toString() === "E^65532 19727.7804056", true);
206
+ checkBool("chain big", MetaNum(1e16).chain(4, 3).toString() === "FFFE16", true);
207
+ checkOp("ssrt small", MetaNum(27).ssrt(), 3, 0.01);
208
+ checkOp("ssrt big", MetaNum(1e16).ssrt(), 13.97, 0.01);
209
+ checkOp("slog small", MetaNum(16).slog(2), 3, 0.01);
210
+ checkOp("slog big", MetaNum(1e16).slog(2), 4.41, 0.01);
211
+ checkOp("linear_sroot small", MetaNum(100).linear_sroot(3), 2.2128, 0.01);
212
+ checkOp("linear_sroot big", MetaNum(1e16).linear_sroot(3), 3.09, 0.01);
213
+ checkOp("layeradd small", MetaNum(10).layeradd(), 1e10, 0.01);
214
+ checkBool("layeradd big", MetaNum(1e16).layeradd().toString() === "EE16", true);
215
+ checkOp("layeradd10 small", MetaNum(10).layeradd10(), 1e10, 0.01);
216
+ checkBool("layeradd10 big", MetaNum(1e16).layeradd10().toString() === "EE16", true);
147
217
 
148
- // ─── 1. aperiote (ω*2): x{y}x = arrow(x,y,x), arrow(y)(a,a)=a↑^y a ───
149
- console.log("\n=== 1. aperiote (ω) ===");
218
+ // ─────────────────────────────────────
219
+ // (pentate_log/root)
220
+ // ─────────────────────────────────────
221
+ console.log("\n=== pentate_log/root ===");
222
+
223
+ // pentate_log: if pentate(a,b)=c then pentate_log(c,a)=b
224
+ checkOp("pent_log semantic 2^3", MetaNum.pentate(2,3).pentate_log(2), 3, 0.1);
225
+ checkOp("pent_log semantic 3^2", MetaNum.pentate(3,2).pentate_log(3), 2, 0.1);
226
+
227
+ // pentate_root: if pentate(a,b)=c then pentate_root(c,b)≈a
228
+ checkOp("pent_root semantic b=2", MetaNum.pentate_root(MetaNum.pentate(3,2), 2), 3, 0.1);
229
+ checkOp("pent_root semantic b=3", MetaNum.pentate_root(MetaNum.pentate(2,3), 3), 2, 0.1);
230
+
231
+ //hyperoperation definition from https://googology.fandom.com/wiki/Template:ExtendedOps
232
+
233
+ // ─── 1. aperiote (ω): x{y}x = arrow(x,y,x), arrow(y)(a,a)=a↑^y a ───
150
234
  // arrow(0): multiplication → 2*2=4, 3*3=9
151
235
  // arrow(1): exponentiation → 2^2=4, 3^3=27
152
236
  // arrow(2): tetration → 2↑↑2=4, 3↑↑3=3^27=7625597484987
153
- checkOp("aper(2,0)", m2.aperiote(0), 4, 0);
154
- checkOp("aper(2,1)", m2.aperiote(1), 4, 0);
155
- checkOp("aper(2,2)", m2.aperiote(2), 4, 0);
237
+ console.log("\n=== 1. aperiote (ω) ===");
156
238
  checkOp("aper(3,0)", m3.aperiote(0), 9, 0);
157
239
  checkOp("aper(3,1)", m3.aperiote(1), 27, 0);
158
- checkBool("aper NaN", MetaNum.aperiote(m2, MetaNum.NaN).isNaN(), true);
159
- checkBool("aper inv NaN", MetaNum.inv_aperiote(m2, MetaNum.NaN).isNaN(), true);
240
+ checkOp("aper(3,2)", m3.aperiote(2), 7625597484987, 0);
241
+ checkOp("aper(3,4)", m3.aperiote(4)); //3↑↑↑↑3
242
+ checkOp("aper(4,3)", m4.aperiote(3)); //4↑↑↑4
243
+ checkBool("aper NaN", MetaNum.aperiote(m3, MetaNum.NaN).isNaN(), true);
244
+ checkBool("aper inv NaN", MetaNum.inv_aperiote(m3, MetaNum.NaN).isNaN(), true);
160
245
 
161
246
  // ─── 2. expande (ω+1): x{{1}}y ───
247
+ // expande: iterated aperiote, x{{1}}y=x{x{...}x}x where there are y x's from the center out
248
+ // e.g. 3{{1}}2=3{3}3=3↑↑↑3
162
249
  console.log("\n=== 2. expande (ω+1) ===");
163
- checkOp("expa(2,1)", m2.expande(1), 2, 0);
164
- checkOp("expa(2,2)", m2.expande(2), 4, 0);
165
- checkBool("expa y=0 NaN", m2.expande(0).isNaN(), true);
166
- checkBool("expa NaN", MetaNum.expande(m2, MetaNum.NaN).isNaN(), true);
250
+ checkOp("expa(3,1)", m3.expande(1), 3, 0);
251
+ checkOp("expa(3,2)", m3.expande(2)); //3↑↑↑3
252
+ checkOp("expa(3,4)", m3.expande(4)); //3{3{3{3}3}3}3
253
+ checkOp("expa(4,3)", m4.expande(3)); //4{4{4}4}4
254
+ checkBool("expa y=0 NaN", m3.expande(0).isNaN(), true);
255
+ checkBool("expa NaN", MetaNum.expande(m3, MetaNum.NaN).isNaN(), true);
167
256
 
168
257
  // ─── 3. multiexpande (ω+2): x{{2}}y ───
258
+ // multiexpande: iterated expande, x{{2}}y=x{{1}}x{{1}}... with y x's
259
+ // e.g. 3{{2}}2=3{{1}}3=3{3{3}3}3=3↑…(3↑↑↑3 arrows)…↑3
169
260
  console.log("\n=== 3. multiexpande (ω+2) ===");
170
- checkOp("muea(2,1)", m2.multiexpande(1), 2, 0);
171
- checkOp("muea(2,2)", m2.multiexpande(2), 4, 0);
172
- checkBool("muea y=0 NaN", m2.multiexpande(0).isNaN(), true);
173
- checkBool("muea NaN", MetaNum.multiexpande(m2, MetaNum.NaN).isNaN(), true);
261
+ checkOp("muea(3,4)", m3.multiexpande(4));
262
+ checkOp("muea(4,3)", m4.multiexpande(3));
263
+ checkBool("muea y=0 NaN", m3.multiexpande(0).isNaN(), true);
264
+ checkBool("muea NaN", MetaNum.multiexpande(m3, MetaNum.NaN).isNaN(), true);
174
265
 
175
266
  // ─── 4. powerexpande (ω+3): x{{3}}y ───
267
+ // powerexpande: iterated multiexpande, x{{3}}y=x{{2}}x{{2}}... with y x's
268
+ // e.g. 3{{3}}2=3{{2}}3=3{{1}}3{{1}}3
176
269
  console.log("\n=== 4. powerexpande (ω+3) ===");
177
- checkOp("poea(2,1)", m2.powerexpande(1), 2, 0);
178
- checkOp("poea(2,2)", m2.powerexpande(2), 4, 0);
179
- checkBool("poea y=0 NaN", m2.powerexpande(0).isNaN(), true);
180
- checkBool("poea NaN", MetaNum.powerexpande(m2, MetaNum.NaN).isNaN(), true);
270
+ checkOp("poea(3,4)", m3.powerexpande(4));
271
+ checkOp("poea(4,3)", m4.powerexpande(3));
272
+ checkBool("poea y=0 NaN", m3.powerexpande(0).isNaN(), true);
273
+ checkBool("poea NaN", MetaNum.powerexpande(m3, MetaNum.NaN).isNaN(), true);
181
274
 
182
275
  // ─── 5. aperioexpande (ω*2): x{{y}}x ───
276
+ // aperioexpande: diagonalization of ω+y, x{{y}}x
277
+ // e.g. 3{{10}}3=3{{9}}3{{9}}3
183
278
  console.log("\n=== 5. aperioexpande (ω*2) ===");
184
- checkOp("apea(2,1)", m2.aperioexpande(1), 4, 0);
185
- checkBool("apea NaN", MetaNum.aperioexpande(m2, MetaNum.NaN).isNaN(), true);
279
+ checkOp("apea(3,4)", m3.aperioexpande(4));
280
+ checkOp("apea(4,3)", m4.aperioexpande(3));
281
+ checkBool("apea NaN", MetaNum.aperioexpande(m3, MetaNum.NaN).isNaN(), true);
186
282
 
187
283
  // ─── 6. explode (ω*2+1): x{{{1}}}y ───
188
284
  console.log("\n=== 6. explode (ω*2+1) ===");
189
- checkOp("expl(2,1)", m2.explode(1), 2, 0);
190
- checkBool("expl y=0 NaN", m2.explode(0).isNaN(), true);
191
- checkBool("expl NaN", MetaNum.explode(m2, MetaNum.NaN).isNaN(), true);
285
+ checkOp("expl(3,4)", m3.explode(4));
286
+ checkOp("expl(4,3)", m4.explode(3));
287
+ checkBool("expl y=0 NaN", m3.explode(0).isNaN(), true);
288
+ checkBool("expl NaN", MetaNum.explode(m3, MetaNum.NaN).isNaN(), true);
192
289
 
193
290
  // ─── 7. multiexplode (ω*2+2): x{{{2}}}y ───
194
291
  console.log("\n=== 7. multiexplode (ω*2+2) ===");
195
- checkOp("muel(2,1)", m2.multiexplode(1), 2, 0);
196
- checkBool("muel y=0 NaN", m2.multiexplode(0).isNaN(), true);
197
- checkBool("muel NaN", MetaNum.multiexplode(m2, MetaNum.NaN).isNaN(), true);
292
+ checkOp("muel(3,4)", m3.multiexplode(4));
293
+ checkOp("muel(4,3)", m4.multiexplode(3));
294
+ checkBool("muel y=0 NaN", m3.multiexplode(0).isNaN(), true);
295
+ checkBool("muel NaN", MetaNum.multiexplode(m3, MetaNum.NaN).isNaN(), true);
198
296
 
199
297
  // ─── 8. aperioexplode (ω*3): x{{{y}}}x ───
200
298
  console.log("\n=== 8. aperioexplode (ω*3) ===");
201
- checkOp("apel(2,1)", m2.aperioexplode(1), 4, 0);
202
- checkBool("apel NaN", MetaNum.aperioexplode(m2, MetaNum.NaN).isNaN(), true);
299
+ checkOp("apel(3,4)", m3.aperioexplode(4));
300
+ checkOp("apel(4,3)", m4.aperioexplode(3));
301
+ checkBool("apel NaN", MetaNum.aperioexplode(m3, MetaNum.NaN).isNaN(), true);
203
302
 
204
303
  // ─── 9. detonate (ω*3+1): x{{{{1}}}}y ───
205
304
  console.log("\n=== 9. detonate (ω*3+1) ===");
206
- checkOp("deto(2,1)", m2.detonate(1), 2, 0);
207
- checkBool("deto y=0 NaN", m2.detonate(0).isNaN(), true);
208
- checkBool("deto NaN", MetaNum.detonate(m2, MetaNum.NaN).isNaN(), true);
305
+ checkOp("deto(3,4)", m3.detonate(4));
306
+ checkOp("deto(4,3)", m4.detonate(3));
307
+ checkBool("deto y=0 NaN", m3.detonate(0).isNaN(), true);
308
+ checkBool("deto NaN", MetaNum.detonate(m3, MetaNum.NaN).isNaN(), true);
209
309
 
210
310
  // ─── 10. aperiodetonate (ω*4): x{{{{y}}}}x ───
211
311
  console.log("\n=== 10. aperiodetonate (ω*4) ===");
212
- checkOp("apdt(2,1)", m2.aperiodetonate(1), 4, 0);
213
- checkBool("apdt NaN", MetaNum.aperiodetonate(m2, MetaNum.NaN).isNaN(), true);
312
+ checkOp("apdt(3,4)", m3.aperiodetonate(4));
313
+ checkOp("apdt(4,3)", m4.aperiodetonate(3));
314
+ checkBool("apdt NaN", MetaNum.aperiodetonate(m3, MetaNum.NaN).isNaN(), true);
214
315
 
215
- // ─── 11. aperionate (ω^2): 对角化 ω*y ───
316
+ // ─── 11. aperionate (ω^2): diagonalization of ω*y ───
216
317
  console.log("\n=== 11. aperionate (ω^2) ===");
217
- checkOp("apeo(2,1)", m2.aperionate(1), m2.aperiote(2).toNumber(), 0.01);
218
- checkBool("apeo NaN", MetaNum.aperionate(m2, MetaNum.NaN).isNaN(), true);
318
+ checkOp("apeo(3,4)", m3.aperionate(4));
319
+ checkOp("apeo(4,3)", m4.aperionate(3));
320
+ checkBool("apeo NaN", MetaNum.aperionate(m3, MetaNum.NaN).isNaN(), true);
219
321
 
220
322
  // ─── 12. megote (ω^2+1): 迭代 ω^2 ───
221
323
  console.log("\n=== 12. megote (ω^2+1) ===");
222
- checkOp("mego(2,1)", m2.megote(1), 2, 0);
223
- checkBool("mego y=0 NaN", m2.megote(0).isNaN(), true);
224
- checkBool("mego NaN", MetaNum.megote(m2, MetaNum.NaN).isNaN(), true);
324
+ checkOp("mego(3,4)", m3.megote(4));
325
+ checkOp("mego(4,3)", m4.megote(3));
326
+ checkBool("mego y=0 NaN", m3.megote(0).isNaN(), true);
327
+ checkBool("mego NaN", MetaNum.megote(m3, MetaNum.NaN).isNaN(), true);
225
328
 
226
329
  // ─── 13. multimegote (ω^2+2): 迭代 ω^2+1 ───
227
330
  console.log("\n=== 13. multimegote (ω^2+2) ===");
228
- checkOp("mume(2,1)", m2.multimegote(1), 2, 0);
229
- checkBool("mume y=0 NaN", m2.multimegote(0).isNaN(), true);
230
- checkBool("mume NaN", MetaNum.multimegote(m2, MetaNum.NaN).isNaN(), true);
331
+ checkOp("mume(3,4)", m3.multimegote(4));
332
+ checkOp("mume(4,3)", m4.multimegote(3));
333
+ checkBool("mume y=0 NaN", m3.multimegote(0).isNaN(), true);
334
+ checkBool("mume NaN", MetaNum.multimegote(m3, MetaNum.NaN).isNaN(), true);
231
335
 
232
336
  // ─── 14. aperimegote (ω^2+ω): 对角化 ω^2+y ───
233
337
  console.log("\n=== 14. aperimegote (ω^2+ω) ===");
234
- checkOp("apmg(2,1)", m2.aperimegote(1), m2.megote(m2).toNumber(), 0.01);
235
- checkBool("apmg NaN", MetaNum.aperimegote(m2, MetaNum.NaN).isNaN(), true);
338
+ checkOp("apmg(3,4)", m3.aperimegote(4));
339
+ checkOp("apmg(4,3)", m4.aperimegote(3));
340
+ checkBool("apmg NaN", MetaNum.aperimegote(m3, MetaNum.NaN).isNaN(), true);
236
341
 
237
342
  // ─── 15. megoexpande (ω^2+ω+1): 迭代 ω^2+ω ───
238
343
  console.log("\n=== 15. megoexpande (ω^2+ω+1) ===");
239
- checkOp("mgea(2,1)", m2.megoexpande(1), 2, 0);
240
- checkBool("mgea y=0 NaN", m2.megoexpande(0).isNaN(), true);
241
- checkBool("mgea NaN", MetaNum.megoexpande(m2, MetaNum.NaN).isNaN(), true);
344
+ checkOp("mgea(3,4)", m3.megoexpande(4));
345
+ checkOp("mgea(4,3)", m4.megoexpande(3));
346
+ checkBool("mgea y=0 NaN", m3.megoexpande(0).isNaN(), true);
347
+ checkBool("mgea NaN", MetaNum.megoexpande(m3, MetaNum.NaN).isNaN(), true);
242
348
 
243
349
  // ─── 16. aperimegoexpande (ω^2+ω*2): 对角化 ω^2+ω+y ───
244
350
  console.log("\n=== 16. aperimegoexpande (ω^2+ω*2) ===");
245
- checkOp("apme(2,1)", m2.aperimegoexpande(1), m2.megoexpande(m2).toNumber(), 0.01);
246
- checkBool("apme NaN", MetaNum.aperimegoexpande(m2, MetaNum.NaN).isNaN(), true);
351
+ checkOp("apme(3,4)", m3.aperimegoexpande(4));
352
+ checkOp("apme(4,3)", m4.aperimegoexpande(3));
353
+ checkBool("apme NaN", MetaNum.aperimegoexpande(m3, MetaNum.NaN).isNaN(), true);
247
354
 
248
- // ─── 17. megoaperionation (ω^2*2): 对角化 ω^2+ω*y ───
249
- console.log("\n=== 17. megoaperionation (ω^2*2) ===");
250
- checkBool("mgao NaN", MetaNum.megoaperionation(m2, MetaNum.NaN).isNaN(), true);
355
+ // ─── 17. megoaperionate (ω^2*2): 对角化 ω^2+ω*y ───
356
+ console.log("\n=== 17. megoaperionate (ω^2*2) ===");
357
+ checkOp("mgao(3,4)", m3.megoaperionate(4));
358
+ checkOp("mgao(4,3)", m4.megoaperionate(3));
359
+ checkBool("mgao NaN", MetaNum.megoaperionate(m3, MetaNum.NaN).isNaN(), true);
251
360
 
252
361
  // ─── 18. gigote (ω^2*2+1): 迭代 ω^2*2 ───
253
362
  console.log("\n=== 18. gigote (ω^2*2+1) ===");
254
- checkOp("gigo(2,1)", m2.gigote(1), 2, 0);
255
- checkBool("gigo y=0 NaN", m2.gigote(0).isNaN(), true);
256
- checkBool("gigo NaN", MetaNum.gigote(m2, MetaNum.NaN).isNaN(), true);
363
+ checkOp("gigo(3,4)", m3.gigote(4));
364
+ checkOp("gigo(4,3)", m4.gigote(3));
365
+ checkBool("gigo y=0 NaN", m3.gigote(0).isNaN(), true);
366
+ checkBool("gigo NaN", MetaNum.gigote(m3, MetaNum.NaN).isNaN(), true);
257
367
 
258
368
  // ─── 19. aperigigote (ω^2*2+ω): 对角化 ω^2*2+y ───
259
369
  console.log("\n=== 19. aperigigote (ω^2*2+ω) ===");
260
- checkOp("apgg(2,1)", m2.aperigigote(1), m2.gigote(m2).toNumber(), 0.01);
261
- checkBool("apgg NaN", MetaNum.aperigigote(m2, MetaNum.NaN).isNaN(), true);
370
+ checkOp("apgg(3,4)", m3.aperigigote(4));
371
+ checkOp("apgg(4,3)", m4.aperigigote(3));
372
+ checkBool("apgg NaN", MetaNum.aperigigote(m3, MetaNum.NaN).isNaN(), true);
262
373
 
263
374
  // ─── 20. gigoaperionate (ω^2*3): 对角化 ω^2*2+ω*y ───
264
375
  console.log("\n=== 20. gigoaperionate (ω^2*3) ===");
265
- checkOp("ggap(2,1)", m2.gigoaperionate(1), 2, 0);
266
- checkBool("ggap y=0 NaN", m2.gigoaperionate(0).isNaN(), true);
267
- checkBool("ggap NaN", MetaNum.gigoaperionate(m2, MetaNum.NaN).isNaN(), true);
376
+ checkOp("ggap(3,4)", m3.gigoaperionate(4));
377
+ checkOp("ggap(4,3)", m4.gigoaperionate(3));
378
+ checkBool("ggap y=0 NaN", m3.gigoaperionate(0).isNaN(), true);
379
+ checkBool("ggap NaN", MetaNum.gigoaperionate(m3, MetaNum.NaN).isNaN(), true);
268
380
 
269
- // ─── 21. aperiatotion (ω^3): 对角化 ω^2*y ───
270
- console.log("\n=== 21. aperiatotion (ω^3) ===");
271
- checkOp("apat(2,1)", m2.aperiatotion(1), m2.aperionate(m2).toNumber(), 0.01);
272
- checkBool("apat NaN", MetaNum.aperiatotion(m2, MetaNum.NaN).isNaN(), true);
381
+ // ─── 21. aperiatote (ω^3): 对角化 ω^2*y ───
382
+ console.log("\n=== 21. aperiatote (ω^3) ===");
383
+ checkOp("apat(3,4)", m3.aperiatote(4));
384
+ checkOp("apat(4,3)", m4.aperiatote(3));
385
+ checkBool("apat NaN", MetaNum.aperiatote(m3, MetaNum.NaN).isNaN(), true);
273
386
 
274
387
  // ─── 22. powiainate (ω^3+1): 迭代 ω^3 ───
275
388
  console.log("\n=== 22. powiainate (ω^3+1) ===");
276
- checkOp("pwan(2,1)", m2.powiainate(1), 2, 0);
277
- checkBool("pwan y=0 NaN", m2.powiainate(0).isNaN(), true);
278
- checkBool("pwan NaN", MetaNum.powiainate(m2, MetaNum.NaN).isNaN(), true);
389
+ checkOp("pwan(3,4)", m3.powiainate(4));
390
+ checkOp("pwan(4,3)", m4.powiainate(3));
391
+ checkBool("pwan y=0 NaN", m3.powiainate(0).isNaN(), true);
392
+ checkBool("pwan NaN", MetaNum.powiainate(m3, MetaNum.NaN).isNaN(), true);
279
393
 
280
394
  // ─── 23. expandainate (ω^3+ω): ω级别迭代 powiainate ───
281
395
  console.log("\n=== 23. expandainate (ω^3+ω) ===");
282
- checkOp("epan(2,1)", m2.expandainate(1), m2.powiainate(m2).toNumber(), 0.01);
283
- checkBool("epan NaN", MetaNum.expandainate(m2, MetaNum.NaN).isNaN(), true);
396
+ checkOp("epan(3,4)", m3.expandainate(4));
397
+ checkOp("epan(4,3)", m4.expandainate(3));
398
+ checkBool("epan NaN", MetaNum.expandainate(m3, MetaNum.NaN).isNaN(), true);
284
399
 
285
400
  // ─── 24. megodainate (ω^3+ω^2): 迭代 ω^3+ω ───
286
401
  console.log("\n=== 24. megodainate (ω^3+ω^2) ===");
287
- checkOp("mgan(2,1)", m2.megodainate(1), 2, 0);
288
- checkBool("mgan y=0 NaN", m2.megodainate(0).isNaN(), true);
289
- checkBool("mgan NaN", MetaNum.megodainate(m2, MetaNum.NaN).isNaN(), true);
402
+ checkOp("mgan(3,4)", m3.megodainate(4));
403
+ checkOp("mgan(4,3)", m4.megodainate(3));
404
+ checkBool("mgan y=0 NaN", m3.megodainate(0).isNaN(), true);
405
+ checkBool("mgan NaN", MetaNum.megodainate(m3, MetaNum.NaN).isNaN(), true);
290
406
 
291
407
  // ─── 25. powiairate (ω^3*2) ───
292
408
  console.log("\n=== 25. powiairate (ω^3*2) ===");
293
- checkOp("pwar(2,1)", m2.powiairate(1), 2, 0);
294
- checkBool("pwar y=0 NaN", m2.powiairate(0).isNaN(), true);
295
- checkBool("pwar NaN", MetaNum.powiairate(m2, MetaNum.NaN).isNaN(), true);
409
+ checkOp("pwar(3,4)", m3.powiairate(4));
410
+ checkOp("pwar(4,3)", m4.powiairate(0).isNaN(), true);
411
+ checkBool("pwar NaN", MetaNum.powiairate(m3, MetaNum.NaN).isNaN(), true);
296
412
 
297
413
  // ─── 26. aperioguate (ω^4): 对角化 ω^3*y ───
298
414
  console.log("\n=== 26. aperioguate (ω^4) ===");
299
- checkOp("apgu(2,1)", m2.aperioguate(1), m2.aperiatotion(m2).toNumber(), 0.01);
300
- checkBool("apgu NaN", MetaNum.aperioguate(m2, MetaNum.NaN).isNaN(), true);
415
+ checkOp("apgu(3,4)", m3.aperioguate(4));
416
+ checkOp("apgu(4,3)", m4.aperioguate(3));
417
+ checkBool("apgu NaN", MetaNum.aperioguate(m3, MetaNum.NaN).isNaN(), true);
301
418
 
302
419
  // ─── 27. iter (ω^ω): 对角化 ω^x ───
303
420
  console.log("\n=== 27. iter (ω^ω) ===");
304
- checkOp("ite(2,1)", m2.iter(1), 2, 0);
305
- checkBool("ite y=0 NaN", m2.iter(0).isNaN(), true);
306
- checkBool("ite NaN", MetaNum.iter(m2, MetaNum.NaN).isNaN(), true);
421
+ checkOp("ite(3,4)", m3.iter(4));
422
+ checkOp("ite(4,3)", m4.iter(3));
423
+ checkBool("ite y=0 NaN", m3.iter(0).isNaN(), true);
424
+ checkBool("ite NaN", MetaNum.iter(m3, MetaNum.NaN).isNaN(), true);
307
425
 
308
426
  // ─── 28. itermult (ω^ω+1): 迭代 ω^ω ───
309
427
  console.log("\n=== 28. itermult (ω^ω+1) ===");
310
- checkOp("itmu(2,1)", m2.itermult(1), m2.iter(m2).toNumber(), 0.01);
311
- checkBool("itmu y=0 NaN", m2.itermult(0).isNaN(), true);
312
- checkBool("itmu NaN", MetaNum.itermult(m2, MetaNum.NaN).isNaN(), true);
428
+ checkOp("itmu(3,4)", m3.itermult(4));
429
+ checkOp("itmu(4,3)", m4.itermult(3));
430
+ checkBool("itmu y=0 NaN", m3.itermult(0).isNaN(), true);
431
+ checkBool("itmu NaN", MetaNum.itermult(m3, MetaNum.NaN).isNaN(), true);
313
432
 
314
433
  // ─── 29. cuboiter (ω^ω*2) ───
315
434
  console.log("\n=== 29. cuboiter (ω^ω*2) ===");
316
- checkOp("cube(2,1)", m2.cuboiter(1), 2, 0);
317
- checkBool("cube NaN", MetaNum.cuboiter(m2, MetaNum.NaN).isNaN(), true);
435
+ checkOp("cube(3,4)", m3.cuboiter(4));
436
+ checkOp("cube(4,3)", m4.cuboiter(3));
437
+ checkBool("cube NaN", MetaNum.cuboiter(m3, MetaNum.NaN).isNaN(), true);
318
438
 
319
439
  // ─── 30. expoiter (ω^(ω+1)) ───
320
440
  console.log("\n=== 30. expoiter (ω^(ω+1)) ===");
321
- checkOp("expo(2,1)", m2.expoiter(1), m2.iter(m2).toNumber(), 0.01);
322
- checkBool("expo NaN", MetaNum.expoiter(m2, MetaNum.NaN).isNaN(), true);
441
+ checkOp("expo(3,4)", m3.expoiter(4));
442
+ checkOp("expo(4,3)", m4.expoiter(3));
443
+ checkBool("expo NaN", MetaNum.expoiter(m3, MetaNum.NaN).isNaN(), true);
323
444
 
324
445
  // ─── 31. trioterate (ω^(ω*2)) ───
325
446
  console.log("\n=== 31. trioterate (ω^(ω*2)) ===");
326
- checkOp("tria(2,1)", m2.trioterate(1), m2.iter(m2).toNumber(), 0.01);
327
- checkBool("tria NaN", MetaNum.trioterate(m2, MetaNum.NaN).isNaN(), true);
447
+ checkOp("tria(3,4)", m3.trioterate(4));
448
+ checkOp("tria(4,3)", m4.trioterate(3));
449
+ checkBool("tria NaN", MetaNum.trioterate(m3, MetaNum.NaN).isNaN(), true);
328
450
 
329
451
  // ─── 32. trixxate (ω^(ω^2)) ───
330
452
  console.log("\n=== 32. trixxate (ω^(ω^2)) ===");
331
- checkOp("trix(2,1)", m2.trixxate(1), m2.trioterate(m2).toNumber(), 0.01);
332
- checkBool("trix NaN", MetaNum.trixxate(m2, MetaNum.NaN).isNaN(), true);
453
+ checkOp("trix(3,4)", m3.trixxate(4));
454
+ checkOp("trix(4,3)", m4.trixxate(3));
455
+ checkBool("trix NaN", MetaNum.trixxate(m3, MetaNum.NaN).isNaN(), true);
333
456
 
334
457
  // ─── 33. aperixxate (ω^(ω^ω)) ───
335
458
  console.log("\n=== 33. aperixxate (ω^(ω^ω)) ===");
336
- checkOp("apix(2,1)", m2.aperixxate(1), m2.trixxate(m2).toNumber(), 0.01);
337
- checkBool("apix NaN", MetaNum.aperixxate(m2, MetaNum.NaN).isNaN(), true);
459
+ checkOp("apix(3,4)", m3.aperixxate(4));
460
+ checkOp("apix(4,3)", m4.aperixxate(3));
461
+ checkBool("apix NaN", MetaNum.aperixxate(m3, MetaNum.NaN).isNaN(), true);
338
462
 
339
463
  // ─── 34. epsilonate (ε₀) ───
340
464
  console.log("\n=== 34. epsilonate (ε₀) ===");
341
- checkOp("epsl(2,1)", m2.epsilonate(1), m2.aperixxate(m2).toNumber(), 0.01);
342
- checkBool("epsl NaN", MetaNum.epsilonate(m2, MetaNum.NaN).isNaN(), true);
343
-
344
- // ─────────────────────────────────────
345
- // 逆运算 语义验证 (pentate_log/root + 通用)
346
- // ─────────────────────────────────────
347
- console.log("\n=== 逆运算 语义验证 ===");
348
-
349
- // pentate_log: if pentate(a,b)=c then pentate_log(c,a)=b
350
- checkOp("pent_log semantic 2^3", MetaNum.pentate(2,3).pentate_log(2), 3, 0.1);
351
- checkOp("pent_log semantic 3^2", MetaNum.pentate(3,2).pentate_log(3), 2, 0.1);
352
-
353
- // pentate_root: if pentate(a,b)=c then pentate_root(c,b)≈a
354
- checkOp("pent_root semantic b=2", MetaNum.pentate_root(MetaNum.pentate(3,2), 2), 3, 0.1);
355
- checkOp("pent_root semantic b=3", MetaNum.pentate_root(MetaNum.pentate(2,3), 3), 2, 0.1);
465
+ checkOp("epsl(3,4)", m3.epsilonate(4));
466
+ checkOp("epsl(4,3)", m4.epsilonate(3));
467
+ checkBool("epsl NaN", MetaNum.epsilonate(m3, MetaNum.NaN).isNaN(), true);
356
468
 
357
469
  // Same-value tests: op(x,1) produces reasonable results
358
470
  var ops = [
359
471
  "aperiote","expande","multiexpande","powerexpande","aperioexpande",
360
472
  "explode","multiexplode","aperioexplode","detonate","aperiodetonate",
361
473
  "aperionate","megote","multimegote","aperimegote","megoexpande",
362
- "aperimegoexpande","megoaperionation","gigote","aperigigote","gigoaperionate",
363
- "aperiatotion","powiainate","expandainate","megodainate","powiairate","aperioguate","iter",
474
+ "aperimegoexpande","megoaperionate","gigote","aperigigote","gigoaperionate",
475
+ "aperiatote","powiainate","expandainate","megodainate","powiairate","aperioguate","iteration",
364
476
  "itermult","cuboiter","expoiter","trioterate","trixxate","aperixxate","epsilonate"
365
477
  ];
366
478
 
367
- console.log("\n=== 全运算 x=3, y=2 冒烟测试 ===");
479
+ console.log("\n=== all hyperoperations x=1, y=3 test ===");
368
480
  for (var oi = 0; oi < ops.length; oi++) {
369
481
  try {
370
- var res = m3[ops[oi]](2);
371
- console.log("PASS | " + ops[oi] + "(3,2) | " + res.toString().slice(0,60));
482
+ var res = m1[ops[oi]](3);
483
+ if (res.eq(1)) console.log("PASS | " + ops[oi] + "(1,3) | " + res.toString().slice(0,100));
484
+ else console.log("FAIL | " + ops[oi] + "(1,3) => " + res.toString().slice(0,100));
372
485
  } catch (e) {
373
- console.log("FAIL | " + ops[oi] + "(3,2) => " + e.message);
374
- process.exitCode = 1;
486
+ console.log("ERROR | " + ops[oi] + "(1,3) => " + e.message);
375
487
  }
376
488
  }
377
489
 
378
- console.log("\n=== 全运算 x=3, y=1 边界测试 ===");
490
+ console.log("\n=== all hyperoperations x=3, y=1 test ===");
379
491
  for (var oi = 0; oi < ops.length; oi++) {
380
492
  try {
381
493
  var res = m3[ops[oi]](1);
382
- console.log("PASS | " + ops[oi] + "(3,1) | " + res.toString().slice(0,60));
494
+ console.log("PASS | " + ops[oi] + "(3,1) | " + res.toString().slice(0,100));
383
495
  } catch (e) {
384
- console.log("FAIL | " + ops[oi] + "(3,1) => " + e.message);
385
- process.exitCode = 1;
496
+ console.log("ERROR | " + ops[oi] + "(3,1) => " + e.message);
386
497
  }
387
498
  }
388
499
 
389
- // Static Q 方法测试
390
- console.log("\n=== Static Q 方法 ===");
391
- var qOps = {
392
- "aperiote": ["aperiote","aper"], "expande": ["expande","expa"],
393
- "multiexpande": ["multiexpande","muea"], "powerexpande": ["powerexpande","poea"],
394
- "aperioexpande": ["aperioexpande","apea"], "explode": ["explode","expl"],
395
- "multiexplode": ["multiexplode","muel"], "aperioexplode": ["aperioexplode","apel"],
396
- "detonate": ["detonate","deto"], "aperiodetonate": ["aperiodetonate","apdt"],
397
- "aperionate": ["aperionate","apeo"], "megote": ["megote","mego"],
398
- "multimegote": ["multimegote","mume"], "aperimegote": ["aperimegote","apmg"],
399
- "megoexpande": ["megoexpande","mgea"], "aperimegoexpande": ["aperimegoexpande","apme"],
400
- "megoaperionation": ["megoaperionation","mgao"], "gigote": ["gigote","gigo"],
401
- "aperigigote": ["aperigigote","apgg"], "gigoaperionate": ["gigoaperionate","ggap"],
402
- "aperiatotion": ["aperiatotion","apat"], "powiainate": ["powiainate","pwan"],
403
- "expandainate": ["expandainate","epan"], "megodainate": ["megodainate","mgan"],
404
- "powiairate": ["powiairate","pwar"], "aperioguate": ["aperioguate","apgu"],
405
- "iter": ["iter","ite"],
406
- "itermult": ["itermult","itmu"], "cuboiter": ["cuboiter","cube"],
407
- "expoiter": ["expoiter","expo"], "trioterate": ["trioterate","tria"],
408
- "trixxate": ["trixxate","trix"], "aperixxate": ["aperixxate","apix"],
409
- "epsilonate": ["epsilonate","epsl"]
410
- };
411
- for (var key in qOps) {
412
- var f = MetaNum[key]; var s = MetaNum[qOps[key][1]];
500
+ // 逆运算 roundtrip: op(10,x) → inv → 应该 ≈ x
501
+ console.log("\n=== inv hyperoperations roundtrip test ===");
502
+ var m10 = MetaNum(10);
503
+ for (var oi = 0; oi < ops.length; oi++) {
504
+ var opname = ops[oi];
413
505
  try {
414
- var rf = f(2, 2);
415
- var rs = s(2, 2);
416
- var ok = rf.eq(rs);
417
- console.log((ok ? "PASS" : "FAIL") + " | Q." + key + "(2,2)==Q." + qOps[key][1] + "(2,2)");
418
- if (!ok) { console.log(" full=" + rf.toString() + " short=" + rs.toString()); process.exitCode = 1; }
506
+ var fwd = m10[opname](3);
507
+ var invname = "inv_" + opname;
508
+ var back = fwd[invname](m10);
509
+ if(back.eq(m3)) console.log("PASS | " + invname + " | fwd=" + fwd.toString().slice(0,100) + " back=" + back.toString().slice(0,100));
510
+ else console.log("FAIL | " + invname + " | fwd=" + fwd.toString().slice(0,100) + " back=" + back.toString().slice(0,100));
419
511
  } catch (e) {
420
- console.log("ERROR | Q." + key + " => " + e.message);
421
- process.exitCode = 1;
512
+ console.log("ERROR | inv_" + opname + " => " + e.message);
422
513
  }
423
514
  }
424
515
 
425
- // 逆运算 roundtrip: op(x,2) → inv → 应该 ≈ x
426
- console.log("\n=== 逆运算 roundtrip ===");
427
- for (var oi = 0; oi < ops.length; oi++) {
428
- var opname = ops[oi];
516
+ console.log("\n=== hyperoperation (x > MSI) (not fully implemented) ===");
517
+ var mBigBase = MetaNum(1e16);
518
+ var hyperOps = [
519
+ "aperiote","expande","multiexpande","powerexpande","aperioexpande",
520
+ "explode","multiexplode","aperioexplode","detonate","aperiodetonate",
521
+ "aperionate","megote","multimegote","aperimegote","megoexpande",
522
+ "aperimegoexpande","megoaperionation","gigote","aperigigote","gigoaperionate",
523
+ "aperiatote","powiainate","expandainate","megodainate","powiairate","aperioguate","iteration",
524
+ "itermult","cuboiter","expoiter","trioterate","trixxate","aperixxate","epsilonate"
525
+ ];
526
+ for (var oi = 0; oi < hyperOps.length; oi++) {
429
527
  try {
430
- var fwd = m3[opname](2);
431
- var invname = "inv_" + opname;
432
- var back = fwd[invname](fwd);
433
- console.log("PASS | " + invname + " | fwd=" + fwd.toString().slice(0,40) + " back=" + back.toString().slice(0,40));
528
+ var res = mBigBase[hyperOps[oi]](1);
529
+ console.log("PASS | " + hyperOps[oi] + "(1e16,3) | " + res.toString().slice(0,100));
530
+ } catch (e) {
531
+ console.log("FAIL | " + hyperOps[oi] + "(1e16,3) => " + e.message);
532
+ }
533
+ }
534
+
535
+ console.log("\n=== hyperoperation (y > MSI) ===");
536
+ for (var oi = 0; oi < hyperOps.length; oi++) {
537
+ try {
538
+ var res = mBigBase[hyperOps[oi]](2);
539
+ console.log("PASS | " + hyperOps[oi] + "(3,1e16) | " + res.toString().slice(0,100));
434
540
  } catch (e) {
435
- console.log("FAIL | inv_" + opname + " => " + e.message);
436
- process.exitCode = 1;
541
+ console.log("FAIL | " + hyperOps[oi] + "(3,1e16) => " + e.message);
437
542
  }
438
543
  }
439
544
 
545
+ console.log("\n=== inverse operation (> MSI) roundtrip ===");
546
+ var invOps = [
547
+ "inv_aperiote","inv_expande","inv_multiexpande","inv_powerexpande","inv_aperioexpande",
548
+ "inv_explode","inv_multiexplode","inv_aperioexplode","inv_detonate","inv_aperiodetonate",
549
+ "inv_aperionate","inv_megote","inv_multimegote","inv_aperimegote","inv_megoexpande",
550
+ "inv_aperimegoexpande","inv_megoaperionate","inv_gigote","inv_aperigigote","inv_gigoaperionate",
551
+ "inv_aperiatote","inv_powiainate","inv_expandainate","inv_megodainate","inv_powiairate","inv_aperioguate","inv_iteration",
552
+ "inv_itermult","inv_cuboiter","inv_expoiter","inv_trioterate","inv_trixxate","inv_aperixxate","inv_epsilonate"
553
+ ];
554
+ for (var oi = 0; oi < invOps.length; oi++) {
555
+ try {
556
+ var fwd = mBigBase[hyperOps[oi]](2);
557
+ var back = fwd[invOps[oi]](fwd);
558
+ console.log("PASS | " + invOps[oi] + " | fwd=" + fwd.toString().slice(0,100) + " back=" + back.toString().slice(0,100));
559
+ } catch (e) {
560
+ console.log("FAIL | " + invOps[oi] + " => " + e.message);
561
+ }
562
+ }
563
+
564
+ // ─────────────────────────────────────
565
+ // hyperoperation iteration tests (嵌套超运算)
566
+ // ─────────────────────────────────────
567
+ console.log("\n=== hyperoperation iteration tests (not fully implemented) ===");
568
+
569
+ // aperiote (ω): x{y}x nested
570
+ checkOp("aper(3,aper(3,0))", m3.aperiote(m3.aperiote(0).toNumber()), m3.aperiote(9));
571
+ checkOp("aper(3,aper(3,1))", m3.aperiote(m3.aperiote(1).toNumber()), m3.aperiote(27));
572
+ checkOp("aper(3,aper(3,2))", m3.aperiote(m3.aperiote(2)));
573
+
574
+ // expande (ω+1): x{{1}}y nested
575
+ checkOp("expa(3,expa(3,1))", m3.expande(m3.expande(1)));
576
+ checkOp("expa(3,expa(3,2))", m3.expande(m3.expande(2)));
577
+ checkOp("expa(4,expa(4,1))", m4.expande(m4.expande(1)));
578
+
579
+ // multiexpande (ω+2): x{{2}}y nested
580
+ checkOp("muea(3,muea(3,1))", m3.multiexpande(m3.multiexpande(1)));
581
+ checkOp("muea(3,muea(3,2))", m3.multiexpande(m3.multiexpande(2)));
582
+ checkOp("muea(4,muea(4,1))", m4.multiexpande(m4.multiexpande(1)));
583
+
584
+ // powerexpande (ω+3): x{{3}}y nested
585
+ checkOp("poea(3,poea(3,1))", m3.powerexpande(m3.powerexpande(1)));
586
+ checkOp("poea(3,poea(3,2))", m3.powerexpande(m3.powerexpande(2)));
587
+ checkOp("poea(4,poea(4,1))", m4.powerexpande(m4.powerexpande(1)));
588
+
589
+ // aperioexpande (ω*2): x{{y}}x nested
590
+ checkOp("apea(3,apea(3,1))", m3.aperioexpande(m3.aperioexpande(1)));
591
+ checkOp("apea(3,apea(3,2))", m3.aperioexpande(m3.aperioexpande(2)));
592
+ checkOp("apea(4,apea(4,1))", m4.aperioexpande(m4.aperioexpande(1)));
593
+
594
+ // explode (ω*2+1): x{{{1}}}y nested
595
+ checkOp("expl(3,expl(3,1))", m3.explode(m3.explode(1)));
596
+ checkOp("expl(3,expl(3,2))", m3.explode(m3.explode(2)));
597
+ checkOp("expl(4,expl(4,1))", m4.explode(m4.explode(1)));
598
+
599
+ // multiexplode (ω*2+2): x{{{2}}}y nested
600
+ checkOp("muel(3,muel(3,1))", m3.multiexplode(m3.multiexplode(1)));
601
+ checkOp("muel(3,muel(3,2))", m3.multiexplode(m3.multiexplode(2)));
602
+ checkOp("muel(4,muel(4,1))", m4.multiexplode(m4.multiexplode(1)));
603
+
604
+ // aperioexplode (ω*3): x{{{y}}}x nested
605
+ checkOp("apel(3,apel(3,1))", m3.aperioexplode(m3.aperioexplode(1)));
606
+ checkOp("apel(3,apel(3,2))", m3.aperioexplode(m3.aperioexplode(2)));
607
+ checkOp("apel(4,apel(4,1))", m4.aperioexplode(m4.aperioexplode(1)));
608
+
609
+ // detonate (ω*3+1): x{{{{1}}}}y nested
610
+ checkOp("deto(3,deto(3,1))", m3.detonate(m3.detonate(1)));
611
+ checkOp("deto(3,deto(3,2))", m3.detonate(m3.detonate(2)));
612
+ checkOp("deto(4,deto(4,1))", m4.detonate(m4.detonate(1)));
613
+
614
+ // aperiodetonate (ω*4): x{{{{y}}}}x nested
615
+ checkOp("apdt(3,apdt(3,1))", m3.aperiodetonate(m3.aperiodetonate(1)));
616
+ checkOp("apdt(3,apdt(3,2))", m3.aperiodetonate(m3.aperiodetonate(2)));
617
+ checkOp("apdt(4,apdt(4,1))", m4.aperiodetonate(m4.aperiodetonate(1)));
618
+
619
+ // aperionate (ω^2): diagonalization nested
620
+ checkOp("apeo(3,apeo(3,1))", m3.aperionate(m3.aperionate(1)));
621
+ checkOp("apeo(3,apeo(3,2))", m3.aperionate(m3.aperionate(2)));
622
+ checkOp("apeo(4,apeo(4,1))", m4.aperionate(m4.aperionate(1)));
623
+
624
+ // megote (ω^2+1): nested
625
+ checkOp("mego(3,mego(3,1))", m3.megote(m3.megote(1)));
626
+ checkOp("mego(3,mego(3,2))", m3.megote(m3.megote(2)));
627
+ checkOp("mego(3,mego(3,3))", m3.megote(m3.megote(3)));
628
+
629
+ // multimegote (ω^2+2): nested
630
+ checkOp("mume(3,mume(3,1))", m3.multimegote(m3.multimegote(1)));
631
+ checkOp("mume(3,mume(3,2))", m3.multimegote(m3.multimegote(2)));
632
+ checkOp("mume(4,mume(4,1))", m4.multimegote(m4.multimegote(1)));
633
+
634
+ // aperimegote (ω^2+ω): nested
635
+ checkOp("apmg(3,apmg(3,1))", m3.aperimegote(m3.aperimegote(1)));
636
+ checkOp("apmg(3,apmg(3,2))", m3.aperimegote(m3.aperimegote(2)));
637
+ checkOp("apmg(4,apmg(4,1))", m4.aperimegote(m4.aperimegote(1)));
638
+
639
+ // megoexpande (ω^2+ω+1): nested
640
+ checkOp("mgea(3,mgea(3,1))", m3.megoexpande(m3.megoexpande(1)));
641
+ checkOp("mgea(3,mgea(3,2))", m3.megoexpande(m3.megoexpande(2)));
642
+ checkOp("mgea(4,mgea(4,1))", m4.megoexpande(m4.megoexpande(1)));
643
+
644
+ // aperimegoexpande (ω^2+ω*2): nested
645
+ checkOp("apme(3,apme(3,1))", m3.aperimegoexpande(m3.aperimegoexpande(1)));
646
+ checkOp("apme(3,apme(3,2))", m3.aperimegoexpande(m3.aperimegoexpande(2)));
647
+ checkOp("apme(4,apme(4,1))", m4.aperimegoexpande(m4.aperimegoexpande(1)));
648
+
649
+ // megoaperionate (ω^2*2): nested
650
+ checkOp("mgao(3,mgao(3,1))", m3.megoaperionate(m3.megoaperionate(1)));
651
+ checkOp("mgao(3,mgao(3,2))", m3.megoaperionate(m3.megoaperionate(2)));
652
+ checkOp("mgao(4,mgao(4,1))", m4.megoaperionate(m4.megoaperionate(1)));
653
+
654
+ // gigote (ω^2*2+1): nested
655
+ checkOp("gigo(3,gigo(3,1))", m3.gigote(m3.gigote(1)));
656
+ checkOp("gigo(3,gigo(3,2))", m3.gigote(m3.gigote(2)));
657
+ checkOp("gigo(4,gigo(4,1))", m4.gigote(m4.gigote(1)));
658
+
659
+ // aperigigote (ω^2*2+ω): nested
660
+ checkOp("apgg(3,apgg(3,1))", m3.aperigigote(m3.aperigigote(1)));
661
+ checkOp("apgg(3,apgg(3,2))", m3.aperigigote(m3.aperigigote(2)));
662
+ checkOp("apgg(4,apgg(4,1))", m4.aperigigote(m4.aperigigote(1)));
663
+
664
+ // gigoaperionate (ω^2*3): nested
665
+ checkOp("ggap(3,ggap(3,1))", m3.gigoaperionate(m3.gigoaperionate(1)));
666
+ checkOp("ggap(3,ggap(3,2))", m3.gigoaperionate(m3.gigoaperionate(2)));
667
+ checkOp("ggap(4,ggap(4,1))", m4.gigoaperionate(m4.gigoaperionate(1)));
668
+
669
+ // aperiatote (ω^3): nested
670
+ checkOp("apat(3,apat(3,1))", m3.aperiatote(m3.aperiatote(1)));
671
+ checkOp("apat(3,apat(3,2))", m3.aperiatote(m3.aperiatote(2)));
672
+ checkOp("apat(4,apat(4,1))", m4.aperiatote(m4.aperiatote(1)));
673
+
674
+ // powiainate (ω^3+1): nested
675
+ checkOp("pwan(3,pwan(3,1))", m3.powiainate(m3.powiainate(1)));
676
+ checkOp("pwan(3,pwan(3,2))", m3.powiainate(m3.powiainate(2)));
677
+ checkOp("pwan(4,pwan(4,1))", m4.powiainate(m4.powiainate(1)));
678
+
679
+ // expandainate (ω^3+ω): nested
680
+ checkOp("epan(3,epan(3,1))", m3.expandainate(m3.expandainate(1)));
681
+ checkOp("epan(3,epan(3,2))", m3.expandainate(m3.expandainate(2)));
682
+ checkOp("epan(4,epan(4,1))", m4.expandainate(m4.expandainate(1)));
683
+
684
+ // megodainate (ω^3+ω^2): nested
685
+ checkOp("mgan(3,mgan(3,1))", m3.megodainate(m3.megodainate(1)));
686
+ checkOp("mgan(3,mgan(3,2))", m3.megodainate(m3.megodainate(2)));
687
+ checkOp("mgan(4,mgan(4,1))", m4.megodainate(m4.megodainate(1)));
688
+
689
+ // powiairate (ω^3*2): nested
690
+ checkOp("pwar(3,pwar(3,1))", m3.powiairate(m3.powiairate(1)));
691
+ checkOp("pwar(3,pwar(3,2))", m3.powiairate(m3.powiairate(2)));
692
+ checkOp("pwar(4,pwar(4,1))", m4.powiairate(m4.powiairate(1)));
693
+
694
+ // aperioguate (ω^4): nested
695
+ checkOp("apgu(3,apgu(3,1))", m3.aperioguate(m3.aperioguate(1)));
696
+ checkOp("apgu(3,apgu(3,2))", m3.aperioguate(m3.aperioguate(2)));
697
+ checkOp("apgu(4,apgu(4,1))", m4.aperioguate(m4.aperioguate(1)));
698
+
699
+ // iter (ω^ω): nested
700
+ checkOp("iter(3,iter(3,1))", m3.iter(m3.iter(1)));
701
+ checkOp("iter(3,iter(3,2))", m3.iter(m3.iter(2)));
702
+ checkOp("iter(4,iter(4,1))", m4.iter(m4.iter(1)));
703
+
704
+ // itermult (ω^ω+1): nested
705
+ checkOp("itmu(3,itmu(3,1))", m3.itermult(m3.itermult(1)));
706
+ checkOp("itmu(3,itmu(3,2))", m3.itermult(m3.itermult(2)));
707
+ checkOp("itmu(4,itmu(4,1))", m4.itermult(m4.itermult(1)));
708
+
709
+ // cuboiter (ω^ω*2): nested
710
+ checkOp("cube(3,cube(3,1))", m3.cuboiter(m3.cuboiter(1)));
711
+ checkOp("cube(3,cube(3,2))", m3.cuboiter(m3.cuboiter(2)));
712
+ checkOp("cube(4,cube(4,1))", m4.cuboiter(m4.cuboiter(1)));
713
+
714
+ // expoiter (ω^(ω+1)): nested
715
+ checkOp("expo(3,expo(3,1))", m3.expoiter(m3.expoiter(1)));
716
+ checkOp("expo(3,expo(3,2))", m3.expoiter(m3.expoiter(2)));
717
+ checkOp("expo(4,expo(4,1))", m4.expoiter(m4.expoiter(1)));
718
+
719
+ // trioterate (ω^(ω*2)): nested
720
+ checkOp("tria(3,tria(3,1))", m3.trioterate(m3.trioterate(1)));
721
+ checkOp("tria(3,tria(3,2))", m3.trioterate(m3.trioterate(2)));
722
+ checkOp("tria(4,tria(4,1))", m4.trioterate(m4.trioterate(1)));
723
+
724
+ // trixxate (ω^(ω^2)): nested
725
+ checkOp("trix(3,trix(3,1))", m3.trixxate(m3.trixxate(1)));
726
+ checkOp("trix(3,trix(3,2))", m3.trixxate(m3.trixxate(2)));
727
+ checkOp("trix(4,trix(4,1))", m4.trixxate(m4.trixxate(1)));
728
+
729
+ // aperixxate (ω^(ω^ω)): nested
730
+ checkOp("apix(3,apix(3,1))", m3.aperixxate(m3.aperixxate(1)));
731
+ checkOp("apix(3,apix(3,2))", m3.aperixxate(m3.aperixxate(2)));
732
+ checkOp("apix(4,apix(4,1))", m4.aperixxate(m4.aperixxate(1)));
733
+
734
+ // epsilonate (ε₀): nested
735
+ checkOp("epsl(3,epsl(3,1))", m3.epsilonate(m3.epsilonate(1)));
736
+ checkOp("epsl(3,epsl(3,2))", m3.epsilonate(m3.epsilonate(2)));
737
+ checkOp("epsl(4,epsl(4,1))", m4.epsilonate(m4.epsilonate(1)));
738
+
739
+ // ─── triple nested iteration ───
740
+ console.log("\n=== triple nested hyperoperation tests ===");
741
+ checkOp("aper(3,aper(3,aper(3,1)))", m3.aperiote(m3.aperiote(m3.aperiote(1))));
742
+ checkOp("expa(3,expa(3,expa(3,1)))", m3.expande(m3.expande(m3.expande(1))));
743
+ checkOp("expl(3,expl(3,expl(3,1)))", m3.explode(m3.explode(m3.explode(1))));
744
+ checkOp("deto(3,deto(3,deto(3,1)))", m3.detonate(m3.detonate(m3.detonate(1))));
745
+ checkOp("mego(3,mego(3,mego(3,1)))", m3.megote(m3.megote(m3.megote(1))));
746
+ checkOp("iter(3,iter(3,iter(3,1)))", m3.iter(m3.iter(m3.iter(1))));
747
+ checkOp("epsl(3,epsl(3,epsl(3,1)))", m3.epsilonate(m3.epsilonate(m3.epsilonate(1))));
748
+
749
+ // ─── cross-operation iteration (跨运算嵌套) ───
750
+ console.log("\n=== cross-operation iteration tests ===");
751
+ checkOp("aper(3,expa(3,1))", m3.aperiote(m3.expande(1)));
752
+ checkOp("expa(3,aper(3,1))", m3.expande(m3.aperiote(1)));
753
+ checkOp("expl(3,apea(3,1))", m3.explode(m3.aperioexpande(1)));
754
+ checkOp("deto(3,apel(3,1))", m3.detonate(m3.aperioexplode(1)));
755
+ checkOp("mego(3,apeo(3,1))", m3.megote(m3.aperionate(1)));
756
+ checkOp("iter(3,apgu(3,1))", m3.iter(m3.aperioguate(1)));
757
+ checkOp("epsl(3,apix(3,1))", m3.epsilonate(m3.aperixxate(1)));
758
+
440
759
  console.log("\n=== Done ===");