powiaina_num.js 0.2.0-alpha.3.4 → 0.2.0-alpha.4

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 CHANGED
@@ -19,7 +19,7 @@ If arrow count or expans count is Infinite, the count replaces to the next opera
19
19
 
20
20
  Some codes snippet from [ExpantaNum.js by Naruyoko](https://github.com/Naruyoko/ExpantaNum.js)
21
21
 
22
- Functions are as follows `abs, neg, add, sub, mul, div, rec, pow, pow10, pow_base, sqrt, cbrt, root, log10, log, cmp, rec, gamma, mod, exp, ln, slog, factorial, tetrate_10, isFinite, isInfinite, isNaN, tetrate, lambertw, toString, toJSON, floor, ceil, round, trunc, clampMax, clampMin`(some missing items that have not been fully developed)
22
+ Functions are as follows `abs, neg, add, sub, mul, div, rec, pow, pow10, pow_base, sqrt, cbrt, root, log10, log, cmp, rec, gamma, mod, exp, ln, slog, factorial, tetrate_10, isFinite, isInfinite, isNaN, tetrate, lambertw, toString, toJSON, floor, ceil, round, trunc, clampMax, clampMin, arrow, expansion, expansionArrow, multiExpansion, powerExpansion`(some missing items that have not been fully developed)
23
23
 
24
24
  ## Using
25
25
 
@@ -219,37 +219,29 @@ function countLeadingZerosAfterDecimal(numStr) {
219
219
  // fail to converge, or can end up on the wrong branch.
220
220
  // Evaluates W(x, 0) if principal is true, W(x, -1) if principal is false
221
221
  function d_lambertw(z) {
222
- var tol = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1e-10;
222
+ var tol = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1e10;
223
223
  var principal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
224
+ z = new PowiainaNum(z);
224
225
  var w;
225
- var ew, wewz, wn;
226
- if (z.isInfiNaN()) return z;
226
+ if (!z.isFinite()) return z;
227
227
  if (principal) {
228
- if (z.eq(PowiainaNum.ZERO)) {
229
- return PowiainaNum.ZERO.clone();
230
- }
231
- if (z.eq(PowiainaNum.ONE)) {
232
- //Split out this case because the asymptotic series blows up
233
- return PowiainaNum.fromNumber(OMEGA);
234
- } //Get an initial guess for Halley's method
235
- w = z.log();
228
+ if (z.eq(PowiainaNum.ZERO)) return z;
229
+ if (z.eq(PowiainaNum.ONE)) return new PowiainaNum(OMEGA);
230
+ w = PowiainaNum.log(z);
236
231
  } else {
237
- if (z.eq(PowiainaNum.ZERO)) {
238
- return PowiainaNum.NEGATIVE_INFINITY.clone();
239
- } //Get an initial guess for Halley's method
240
- w = z.neg().log();
241
- } //Halley's method; see 5.9 in [1]
232
+ if (z.eq(PowiainaNum.ZERO)) return PowiainaNum.NEGATIVE_INFINITY.clone();
233
+ w = PowiainaNum.log(z.neg());
234
+ }
242
235
  for (var i = 0; i < 100; ++i) {
243
- ew = w.neg().exp();
244
- wewz = w.sub(z.mul(ew));
245
- wn = w.sub(wewz.div(w.add(1).sub(w.add(2).mul(wewz).div(w.mul(2).add(2)))));
246
- if (wn.sub(w).abs().lt(wn.abs().mul(tol))) {
247
- return wn;
248
- } else {
249
- w = wn;
250
- }
236
+ var ew = w.neg().exp();
237
+ var wewz = w.sub(z.mul(ew));
238
+ var dd = w.add(PowiainaNum.ONE).sub(w.add(2).mul(wewz).div(PowiainaNum.mul(2, w).add(2)));
239
+ if (dd.eq(PowiainaNum.ZERO)) return w;
240
+ var wn = w.sub(wewz.div(dd));
241
+ if (PowiainaNum.abs(wn.sub(w)).lt(PowiainaNum.abs(wn).mul(tol))) return wn;
242
+ w = wn;
251
243
  }
252
- throw Error("Iteration failed to converge: ".concat(z.toString())); //return Decimal.dNaN;
244
+ throw Error("Iteration failed to converge: " + z);
253
245
  }
254
246
  var PowiainaNum = /*#__PURE__*/function () {
255
247
  /**
@@ -438,7 +430,7 @@ var PowiainaNum = /*#__PURE__*/function () {
438
430
  var a = this.toNumber();
439
431
  var b = other.toNumber();
440
432
  var t = Math.pow(a, b);
441
- if (isFinite(t)) {
433
+ if (isFinite(t) && t !== 0) {
442
434
  // optimize?
443
435
  return PowiainaNum.fromNumber(t);
444
436
  }
@@ -885,9 +877,154 @@ var PowiainaNum = /*#__PURE__*/function () {
885
877
  value: function chain(other, arrows) {
886
878
  return this.arrow(arrows)(other);
887
879
  }
880
+ }, {
881
+ key: "pentate",
882
+ value: function pentate(other) {
883
+ return this.arrow(3)(other);
884
+ }
885
+ }, {
886
+ key: "hexate",
887
+ value: function hexate(other) {
888
+ return this.arrow(4)(other);
889
+ }
888
890
  /**
889
- * Select the largest number of arguments.
891
+ * Expansion, which is `this`{{1}}`other2`.
892
+ *
893
+ * Expansion refers to the binary function a{{1}}b = a{a{...a{b}a...}a}a where there are b a's from the center out. It is {a,b,1,2} in BEAF and a{X+1}b in X-Sequence Hyper-Exponential Notation. The notation a{c}b means {a,b,c}, which is a "c + 2"-ated to b, using the bracket operator.
894
+ *
895
+ * @url https://googology.fandom.com/wiki/Expansion
890
896
  */
897
+ }, {
898
+ key: "expansion",
899
+ value: function expansion(other2) {
900
+ var other = new PowiainaNum(other2);
901
+ var t = this.clone();
902
+ if (other.lt(PowiainaNum.ZERO) || !other.isInt()) return PowiainaNum.NaN.clone();
903
+ if (other.eq(PowiainaNum.ONE)) return this.clone();
904
+ if (this.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
905
+ if (!this.isInt()) return PowiainaNum.NaN.clone();
906
+ if (this.eq(2)) return new PowiainaNum(4);
907
+ if (other.eq(0)) return PowiainaNum.ONE.clone();
908
+ var r;
909
+ // I don't know is this added partrs work correctly...
910
+ if (t.gt("10{1,2}".concat(MSI)) || other.gt(MSI)) {
911
+ if (t.gt("10{1,2}".concat(MSI))) {
912
+ r = t.clone();
913
+ r.setOperator(r.getOperator(1, 2) - 1, 1, 2);
914
+ r.normalize();
915
+ } else if (t.gt("10{".concat(MSI, "}10"))) {
916
+ r = new PowiainaNum(t.getOperator(Infinity));
917
+ } else {
918
+ r = PowiainaNum.ZERO;
919
+ }
920
+ var j = r.add(other);
921
+ j.setOperator(j.getOperator(1, 2) + 1, 1, 2);
922
+ j.normalize();
923
+ return j;
924
+ }
925
+ var f = other.toNumber() - 1;
926
+ r = t.clone();
927
+ var i;
928
+ for (i = 0; f !== 0 && r.lt(MSI) && i < 100; ++i) {
929
+ if (f > 0) {
930
+ r = t.arrow(r)(t);
931
+ --f;
932
+ }
933
+ }
934
+ if (i == 100) f = 0;
935
+ r.setOperator(r.getOperator(Infinity) + f, Infinity);
936
+ r.normalize();
937
+ return r;
938
+ }
939
+ }, {
940
+ key: "expansionArrow",
941
+ value: function expansionArrow(arrow2) {
942
+ var arrow = new PowiainaNum(arrow2);
943
+ var t = this.clone();
944
+ if (arrow.lt(0) || !arrow.isInt() || arrow.isNaN() || this.isNaN()) return function () {
945
+ return PowiainaNum.NaN.clone();
946
+ };
947
+ if (arrow.eq(0)) return function (other) {
948
+ return t.arrow(other)(t);
949
+ };
950
+ if (arrow.eq(1)) return function (other) {
951
+ return t.expansion(other);
952
+ };
953
+ var arrows = arrow;
954
+ return function (other2) {
955
+ var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
956
+ var other = new PowiainaNum(other2);
957
+ var r;
958
+ if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
959
+ if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
960
+ if (t.eq(PowiainaNum.ZERO)) {
961
+ if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
962
+ return PowiainaNum.NaN.clone();
963
+ }
964
+ if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
965
+ if (other.eq(PowiainaNum.ZERO)) return PowiainaNum.ONE.clone();
966
+ if (other.eq(PowiainaNum.ONE)) return t.clone();
967
+ // arrow > 9e15, that using 10{x,2}, x=arrow;
968
+ if (arrows.gt(PowiainaNum.MSI)) {
969
+ r = arrows.clone();
970
+ r.setOperator(r.getOperator(Infinity, 2) + 1, Infinity, 2);
971
+ return r;
972
+ }
973
+ var arrowsNum = arrows.toNumber();
974
+ // arrow < 9e15
975
+ // 10{x}2 = 10{x-1}10
976
+ if (other.eq(2)) return t.expansionArrow(arrowsNum - 1)(t, depth + 1);
977
+ if (t.max(other).gt("10{".concat(arrowsNum + 1, ",2}").concat(MSI))) return t.max(other);
978
+ if (t.gt("10{".concat(arrowsNum, ",2}").concat(MSI)) || other.gt(MSI)) {
979
+ if (t.gt("10{".concat(arrowsNum, ",2}").concat(MSI))) {
980
+ r = t.clone();
981
+ r.setOperator(r.getOperator(arrowsNum, 2) - 1, arrowsNum, 2);
982
+ r.normalize();
983
+ } else if (t.gt("10{".concat(arrowsNum - 1, ",2}").concat(MSI))) {
984
+ r = new PowiainaNum(t.getOperator(arrowsNum - 1, 2));
985
+ } else {
986
+ r = PowiainaNum.ZERO;
987
+ }
988
+ var j = r.add(other);
989
+ j.setOperator(j.getOperator(arrowsNum, 2) + 1, arrowsNum, 2);
990
+ j.normalize();
991
+ return j;
992
+ }
993
+ if (depth >= PowiainaNum.maxOps + 10) {
994
+ return new PowiainaNum({
995
+ small: false,
996
+ sign: 1,
997
+ layer: 0,
998
+ array: [newOperator(10, 0), newOperator(1, arrowsNum, 2)]
999
+ });
1000
+ }
1001
+ var y = other.toNumber();
1002
+ var f = Math.floor(y);
1003
+ var arrows_m1 = arrows.sub(PowiainaNum.ONE);
1004
+ r = t.expansionArrow(arrows_m1)(y - f, depth + 1);
1005
+ var i = 0;
1006
+ for (var m = new PowiainaNum("10{".concat(arrowsNum - 1, ",2}").concat(MSI)); f !== 0 && r.lt(m) && i < 100; i++) {
1007
+ if (f > 0) {
1008
+ r = t.expansionArrow(arrows_m1)(r, depth + 1);
1009
+ --f;
1010
+ }
1011
+ }
1012
+ if (i == 100) f = 0;
1013
+ r.setOperator(r.getOperator(arrowsNum - 1, 2) + f, arrowsNum - 1, 2);
1014
+ r.normalize();
1015
+ return r;
1016
+ };
1017
+ }
1018
+ }, {
1019
+ key: "multiExpansion",
1020
+ value: function multiExpansion(other) {
1021
+ return this.expansionArrow(2)(other);
1022
+ }
1023
+ }, {
1024
+ key: "powerExpansion",
1025
+ value: function powerExpansion(other) {
1026
+ return this.expansionArrow(3)(other);
1027
+ }
891
1028
  }, {
892
1029
  key: "max",
893
1030
  value: function max() {
@@ -1220,12 +1357,12 @@ var PowiainaNum = /*#__PURE__*/function () {
1220
1357
  }
1221
1358
  if (x.array.length > PowiainaNum.maxOps) x.array.splice(1, x.array.length - PowiainaNum.maxOps); // max operators check
1222
1359
  // for any 10^a but a >log10(MSI), replace to regular 10^a
1223
- if (this.array[1].arrow == 1 && this.array[1].repeat >= 1 && this.array[0].repeat < MSI_LOG10) {
1360
+ if (this.array.length >= 2 && this.array[1].arrow == 1 && this.array[1].repeat >= 1 && this.array[0].repeat < MSI_LOG10) {
1224
1361
  this.setOperator(this.array[1].repeat - 1, 1);
1225
1362
  this.setOperator(Math.pow(10, this.array[0].repeat), 0);
1226
1363
  renormalize = true;
1227
1364
  }
1228
- if (this.getOperator(0) > MSI && !isFinite(this.getOperator(0))) {
1365
+ if (this.getOperator(0) > MSI && isFinite(this.getOperator(0))) {
1229
1366
  this.setOperator(this.getOperator(1) + 1, 1);
1230
1367
  this.setOperator(Math.log10(this.getOperator(0)), 0);
1231
1368
  renormalize = true;
@@ -1258,12 +1395,20 @@ var PowiainaNum = /*#__PURE__*/function () {
1258
1395
  renormalize = true;
1259
1396
  }
1260
1397
  // for any (10{A=2})^1e16 10, turn into (10{A+1}) 1e16
1261
- if (x.array.length >= 2 && x.array[1].repeat > MSI) {
1398
+ if (x.array.length >= 2 && x.array[1].repeat > MSI && x.array[1].arrow !== Infinity) {
1262
1399
  x.array[1].arrow++;
1263
1400
  x.array[0].repeat = x.array[1].repeat;
1264
1401
  x.array[1].repeat = 1;
1265
1402
  renormalize = true;
1266
1403
  }
1404
+ // for any (10{x})^1e16 10, turn into (10{1,2}) 1e16
1405
+ if (x.array.length >= 2 && x.array[1].repeat > MSI && x.array[1].arrow === Infinity) {
1406
+ x.array[1].arrow = 1;
1407
+ x.array[1].expans++;
1408
+ x.array[0].repeat = x.array[1].repeat;
1409
+ x.array[1].repeat = 1;
1410
+ renormalize = true;
1411
+ }
1267
1412
  } while (renormalize);
1268
1413
  return this;
1269
1414
  }
@@ -1474,6 +1619,11 @@ var PowiainaNum = /*#__PURE__*/function () {
1474
1619
  var payload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
1475
1620
  return new PowiainaNum(t).tetrate(other2, payload);
1476
1621
  }
1622
+ }, {
1623
+ key: "abs",
1624
+ value: function abs(x) {
1625
+ return new PowiainaNum(x).abs();
1626
+ }
1477
1627
  }, {
1478
1628
  key: "log10",
1479
1629
  value: function log10(t) {
@@ -1553,6 +1703,24 @@ var PowiainaNum = /*#__PURE__*/function () {
1553
1703
  // 2--3, 1e10-<e1e10, 10^10^10^0->1
1554
1704
  return PowiainaNum.NaN.clone();*/
1555
1705
  }
1706
+ }, {
1707
+ key: "expansion",
1708
+ value: function expansion(t, other) {
1709
+ return new PowiainaNum(t).expansion(other);
1710
+ }
1711
+ }, {
1712
+ key: "multiExpansion",
1713
+ value: function multiExpansion(t, other) {
1714
+ return new PowiainaNum(t).multiExpansion(other);
1715
+ }
1716
+ }, {
1717
+ key: "powerExpansion",
1718
+ value: function powerExpansion(t, other) {
1719
+ return new PowiainaNum(t).powerExpansion(other);
1720
+ }
1721
+ /**
1722
+ * Select the largest number of arguments.
1723
+ */
1556
1724
  }, {
1557
1725
  key: "max",
1558
1726
  value: function max() {
@@ -217,37 +217,29 @@ function countLeadingZerosAfterDecimal(numStr) {
217
217
  // fail to converge, or can end up on the wrong branch.
218
218
  // Evaluates W(x, 0) if principal is true, W(x, -1) if principal is false
219
219
  function d_lambertw(z) {
220
- var tol = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1e-10;
220
+ var tol = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1e10;
221
221
  var principal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
222
+ z = new PowiainaNum(z);
222
223
  var w;
223
- var ew, wewz, wn;
224
- if (z.isInfiNaN()) return z;
224
+ if (!z.isFinite()) return z;
225
225
  if (principal) {
226
- if (z.eq(PowiainaNum.ZERO)) {
227
- return PowiainaNum.ZERO.clone();
228
- }
229
- if (z.eq(PowiainaNum.ONE)) {
230
- //Split out this case because the asymptotic series blows up
231
- return PowiainaNum.fromNumber(OMEGA);
232
- } //Get an initial guess for Halley's method
233
- w = z.log();
226
+ if (z.eq(PowiainaNum.ZERO)) return z;
227
+ if (z.eq(PowiainaNum.ONE)) return new PowiainaNum(OMEGA);
228
+ w = PowiainaNum.log(z);
234
229
  } else {
235
- if (z.eq(PowiainaNum.ZERO)) {
236
- return PowiainaNum.NEGATIVE_INFINITY.clone();
237
- } //Get an initial guess for Halley's method
238
- w = z.neg().log();
239
- } //Halley's method; see 5.9 in [1]
230
+ if (z.eq(PowiainaNum.ZERO)) return PowiainaNum.NEGATIVE_INFINITY.clone();
231
+ w = PowiainaNum.log(z.neg());
232
+ }
240
233
  for (var i = 0; i < 100; ++i) {
241
- ew = w.neg().exp();
242
- wewz = w.sub(z.mul(ew));
243
- wn = w.sub(wewz.div(w.add(1).sub(w.add(2).mul(wewz).div(w.mul(2).add(2)))));
244
- if (wn.sub(w).abs().lt(wn.abs().mul(tol))) {
245
- return wn;
246
- } else {
247
- w = wn;
248
- }
234
+ var ew = w.neg().exp();
235
+ var wewz = w.sub(z.mul(ew));
236
+ var dd = w.add(PowiainaNum.ONE).sub(w.add(2).mul(wewz).div(PowiainaNum.mul(2, w).add(2)));
237
+ if (dd.eq(PowiainaNum.ZERO)) return w;
238
+ var wn = w.sub(wewz.div(dd));
239
+ if (PowiainaNum.abs(wn.sub(w)).lt(PowiainaNum.abs(wn).mul(tol))) return wn;
240
+ w = wn;
249
241
  }
250
- throw Error("Iteration failed to converge: ".concat(z.toString())); //return Decimal.dNaN;
242
+ throw Error("Iteration failed to converge: " + z);
251
243
  }
252
244
  var PowiainaNum = /*#__PURE__*/function () {
253
245
  /**
@@ -436,7 +428,7 @@ var PowiainaNum = /*#__PURE__*/function () {
436
428
  var a = this.toNumber();
437
429
  var b = other.toNumber();
438
430
  var t = Math.pow(a, b);
439
- if (isFinite(t)) {
431
+ if (isFinite(t) && t !== 0) {
440
432
  // optimize?
441
433
  return PowiainaNum.fromNumber(t);
442
434
  }
@@ -883,9 +875,154 @@ var PowiainaNum = /*#__PURE__*/function () {
883
875
  value: function chain(other, arrows) {
884
876
  return this.arrow(arrows)(other);
885
877
  }
878
+ }, {
879
+ key: "pentate",
880
+ value: function pentate(other) {
881
+ return this.arrow(3)(other);
882
+ }
883
+ }, {
884
+ key: "hexate",
885
+ value: function hexate(other) {
886
+ return this.arrow(4)(other);
887
+ }
886
888
  /**
887
- * Select the largest number of arguments.
889
+ * Expansion, which is `this`{{1}}`other2`.
890
+ *
891
+ * Expansion refers to the binary function a{{1}}b = a{a{...a{b}a...}a}a where there are b a's from the center out. It is {a,b,1,2} in BEAF and a{X+1}b in X-Sequence Hyper-Exponential Notation. The notation a{c}b means {a,b,c}, which is a "c + 2"-ated to b, using the bracket operator.
892
+ *
893
+ * @url https://googology.fandom.com/wiki/Expansion
888
894
  */
895
+ }, {
896
+ key: "expansion",
897
+ value: function expansion(other2) {
898
+ var other = new PowiainaNum(other2);
899
+ var t = this.clone();
900
+ if (other.lt(PowiainaNum.ZERO) || !other.isInt()) return PowiainaNum.NaN.clone();
901
+ if (other.eq(PowiainaNum.ONE)) return this.clone();
902
+ if (this.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
903
+ if (!this.isInt()) return PowiainaNum.NaN.clone();
904
+ if (this.eq(2)) return new PowiainaNum(4);
905
+ if (other.eq(0)) return PowiainaNum.ONE.clone();
906
+ var r;
907
+ // I don't know is this added partrs work correctly...
908
+ if (t.gt("10{1,2}".concat(MSI)) || other.gt(MSI)) {
909
+ if (t.gt("10{1,2}".concat(MSI))) {
910
+ r = t.clone();
911
+ r.setOperator(r.getOperator(1, 2) - 1, 1, 2);
912
+ r.normalize();
913
+ } else if (t.gt("10{".concat(MSI, "}10"))) {
914
+ r = new PowiainaNum(t.getOperator(Infinity));
915
+ } else {
916
+ r = PowiainaNum.ZERO;
917
+ }
918
+ var j = r.add(other);
919
+ j.setOperator(j.getOperator(1, 2) + 1, 1, 2);
920
+ j.normalize();
921
+ return j;
922
+ }
923
+ var f = other.toNumber() - 1;
924
+ r = t.clone();
925
+ var i;
926
+ for (i = 0; f !== 0 && r.lt(MSI) && i < 100; ++i) {
927
+ if (f > 0) {
928
+ r = t.arrow(r)(t);
929
+ --f;
930
+ }
931
+ }
932
+ if (i == 100) f = 0;
933
+ r.setOperator(r.getOperator(Infinity) + f, Infinity);
934
+ r.normalize();
935
+ return r;
936
+ }
937
+ }, {
938
+ key: "expansionArrow",
939
+ value: function expansionArrow(arrow2) {
940
+ var arrow = new PowiainaNum(arrow2);
941
+ var t = this.clone();
942
+ if (arrow.lt(0) || !arrow.isInt() || arrow.isNaN() || this.isNaN()) return function () {
943
+ return PowiainaNum.NaN.clone();
944
+ };
945
+ if (arrow.eq(0)) return function (other) {
946
+ return t.arrow(other)(t);
947
+ };
948
+ if (arrow.eq(1)) return function (other) {
949
+ return t.expansion(other);
950
+ };
951
+ var arrows = arrow;
952
+ return function (other2) {
953
+ var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
954
+ var other = new PowiainaNum(other2);
955
+ var r;
956
+ if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
957
+ if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
958
+ if (t.eq(PowiainaNum.ZERO)) {
959
+ if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
960
+ return PowiainaNum.NaN.clone();
961
+ }
962
+ if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
963
+ if (other.eq(PowiainaNum.ZERO)) return PowiainaNum.ONE.clone();
964
+ if (other.eq(PowiainaNum.ONE)) return t.clone();
965
+ // arrow > 9e15, that using 10{x,2}, x=arrow;
966
+ if (arrows.gt(PowiainaNum.MSI)) {
967
+ r = arrows.clone();
968
+ r.setOperator(r.getOperator(Infinity, 2) + 1, Infinity, 2);
969
+ return r;
970
+ }
971
+ var arrowsNum = arrows.toNumber();
972
+ // arrow < 9e15
973
+ // 10{x}2 = 10{x-1}10
974
+ if (other.eq(2)) return t.expansionArrow(arrowsNum - 1)(t, depth + 1);
975
+ if (t.max(other).gt("10{".concat(arrowsNum + 1, ",2}").concat(MSI))) return t.max(other);
976
+ if (t.gt("10{".concat(arrowsNum, ",2}").concat(MSI)) || other.gt(MSI)) {
977
+ if (t.gt("10{".concat(arrowsNum, ",2}").concat(MSI))) {
978
+ r = t.clone();
979
+ r.setOperator(r.getOperator(arrowsNum, 2) - 1, arrowsNum, 2);
980
+ r.normalize();
981
+ } else if (t.gt("10{".concat(arrowsNum - 1, ",2}").concat(MSI))) {
982
+ r = new PowiainaNum(t.getOperator(arrowsNum - 1, 2));
983
+ } else {
984
+ r = PowiainaNum.ZERO;
985
+ }
986
+ var j = r.add(other);
987
+ j.setOperator(j.getOperator(arrowsNum, 2) + 1, arrowsNum, 2);
988
+ j.normalize();
989
+ return j;
990
+ }
991
+ if (depth >= PowiainaNum.maxOps + 10) {
992
+ return new PowiainaNum({
993
+ small: false,
994
+ sign: 1,
995
+ layer: 0,
996
+ array: [newOperator(10, 0), newOperator(1, arrowsNum, 2)]
997
+ });
998
+ }
999
+ var y = other.toNumber();
1000
+ var f = Math.floor(y);
1001
+ var arrows_m1 = arrows.sub(PowiainaNum.ONE);
1002
+ r = t.expansionArrow(arrows_m1)(y - f, depth + 1);
1003
+ var i = 0;
1004
+ for (var m = new PowiainaNum("10{".concat(arrowsNum - 1, ",2}").concat(MSI)); f !== 0 && r.lt(m) && i < 100; i++) {
1005
+ if (f > 0) {
1006
+ r = t.expansionArrow(arrows_m1)(r, depth + 1);
1007
+ --f;
1008
+ }
1009
+ }
1010
+ if (i == 100) f = 0;
1011
+ r.setOperator(r.getOperator(arrowsNum - 1, 2) + f, arrowsNum - 1, 2);
1012
+ r.normalize();
1013
+ return r;
1014
+ };
1015
+ }
1016
+ }, {
1017
+ key: "multiExpansion",
1018
+ value: function multiExpansion(other) {
1019
+ return this.expansionArrow(2)(other);
1020
+ }
1021
+ }, {
1022
+ key: "powerExpansion",
1023
+ value: function powerExpansion(other) {
1024
+ return this.expansionArrow(3)(other);
1025
+ }
889
1026
  }, {
890
1027
  key: "max",
891
1028
  value: function max() {
@@ -1218,12 +1355,12 @@ var PowiainaNum = /*#__PURE__*/function () {
1218
1355
  }
1219
1356
  if (x.array.length > PowiainaNum.maxOps) x.array.splice(1, x.array.length - PowiainaNum.maxOps); // max operators check
1220
1357
  // for any 10^a but a >log10(MSI), replace to regular 10^a
1221
- if (this.array[1].arrow == 1 && this.array[1].repeat >= 1 && this.array[0].repeat < MSI_LOG10) {
1358
+ if (this.array.length >= 2 && this.array[1].arrow == 1 && this.array[1].repeat >= 1 && this.array[0].repeat < MSI_LOG10) {
1222
1359
  this.setOperator(this.array[1].repeat - 1, 1);
1223
1360
  this.setOperator(Math.pow(10, this.array[0].repeat), 0);
1224
1361
  renormalize = true;
1225
1362
  }
1226
- if (this.getOperator(0) > MSI && !isFinite(this.getOperator(0))) {
1363
+ if (this.getOperator(0) > MSI && isFinite(this.getOperator(0))) {
1227
1364
  this.setOperator(this.getOperator(1) + 1, 1);
1228
1365
  this.setOperator(Math.log10(this.getOperator(0)), 0);
1229
1366
  renormalize = true;
@@ -1256,12 +1393,20 @@ var PowiainaNum = /*#__PURE__*/function () {
1256
1393
  renormalize = true;
1257
1394
  }
1258
1395
  // for any (10{A=2})^1e16 10, turn into (10{A+1}) 1e16
1259
- if (x.array.length >= 2 && x.array[1].repeat > MSI) {
1396
+ if (x.array.length >= 2 && x.array[1].repeat > MSI && x.array[1].arrow !== Infinity) {
1260
1397
  x.array[1].arrow++;
1261
1398
  x.array[0].repeat = x.array[1].repeat;
1262
1399
  x.array[1].repeat = 1;
1263
1400
  renormalize = true;
1264
1401
  }
1402
+ // for any (10{x})^1e16 10, turn into (10{1,2}) 1e16
1403
+ if (x.array.length >= 2 && x.array[1].repeat > MSI && x.array[1].arrow === Infinity) {
1404
+ x.array[1].arrow = 1;
1405
+ x.array[1].expans++;
1406
+ x.array[0].repeat = x.array[1].repeat;
1407
+ x.array[1].repeat = 1;
1408
+ renormalize = true;
1409
+ }
1265
1410
  } while (renormalize);
1266
1411
  return this;
1267
1412
  }
@@ -1472,6 +1617,11 @@ var PowiainaNum = /*#__PURE__*/function () {
1472
1617
  var payload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
1473
1618
  return new PowiainaNum(t).tetrate(other2, payload);
1474
1619
  }
1620
+ }, {
1621
+ key: "abs",
1622
+ value: function abs(x) {
1623
+ return new PowiainaNum(x).abs();
1624
+ }
1475
1625
  }, {
1476
1626
  key: "log10",
1477
1627
  value: function log10(t) {
@@ -1551,6 +1701,24 @@ var PowiainaNum = /*#__PURE__*/function () {
1551
1701
  // 2--3, 1e10-<e1e10, 10^10^10^0->1
1552
1702
  return PowiainaNum.NaN.clone();*/
1553
1703
  }
1704
+ }, {
1705
+ key: "expansion",
1706
+ value: function expansion(t, other) {
1707
+ return new PowiainaNum(t).expansion(other);
1708
+ }
1709
+ }, {
1710
+ key: "multiExpansion",
1711
+ value: function multiExpansion(t, other) {
1712
+ return new PowiainaNum(t).multiExpansion(other);
1713
+ }
1714
+ }, {
1715
+ key: "powerExpansion",
1716
+ value: function powerExpansion(t, other) {
1717
+ return new PowiainaNum(t).powerExpansion(other);
1718
+ }
1719
+ /**
1720
+ * Select the largest number of arguments.
1721
+ */
1554
1722
  }, {
1555
1723
  key: "max",
1556
1724
  value: function max() {