mathjs 11.6.0 → 11.8.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.
Files changed (63) hide show
  1. package/HISTORY.md +23 -0
  2. package/README.md +0 -26
  3. package/lib/browser/math.js +1 -1
  4. package/lib/browser/math.js.LICENSE.txt +2 -2
  5. package/lib/browser/math.js.map +1 -1
  6. package/lib/cjs/core/function/typed.js +1 -1
  7. package/lib/cjs/expression/embeddedDocs/function/matrix/partitionSelect.js +1 -1
  8. package/lib/cjs/expression/node/FunctionAssignmentNode.js +1 -1
  9. package/lib/cjs/expression/node/OperatorNode.js +1 -3
  10. package/lib/cjs/expression/operators.js +19 -4
  11. package/lib/cjs/factoriesNumber.js +18 -0
  12. package/lib/cjs/function/algebra/rationalize.js +1 -3
  13. package/lib/cjs/function/algebra/simplifyConstant.js +1 -1
  14. package/lib/cjs/function/algebra/sparse/csAmd.js +1 -3
  15. package/lib/cjs/function/algebra/sparse/csLeaf.js +1 -3
  16. package/lib/cjs/function/arithmetic/expm1.js +1 -1
  17. package/lib/cjs/function/arithmetic/gcd.js +35 -12
  18. package/lib/cjs/function/arithmetic/nthRoots.js +2 -1
  19. package/lib/cjs/function/arithmetic/round.js +1 -1
  20. package/lib/cjs/function/arithmetic/sign.js +1 -1
  21. package/lib/cjs/function/bitwise/rightArithShift.js +1 -1
  22. package/lib/cjs/function/geometry/distance.js +13 -15
  23. package/lib/cjs/function/matrix/det.js +7 -1
  24. package/lib/cjs/function/matrix/diff.js +3 -3
  25. package/lib/cjs/function/matrix/eigs/complexEigs.js +3 -3
  26. package/lib/cjs/function/matrix/matrixFromColumns.js +1 -1
  27. package/lib/cjs/function/matrix/matrixFromRows.js +1 -1
  28. package/lib/cjs/function/matrix/partitionSelect.js +7 -2
  29. package/lib/cjs/function/set/setIsSubset.js +1 -1
  30. package/lib/cjs/function/set/setSize.js +3 -2
  31. package/lib/cjs/header.js +2 -2
  32. package/lib/cjs/type/matrix/DenseMatrix.js +41 -45
  33. package/lib/cjs/type/matrix/SparseMatrix.js +39 -41
  34. package/lib/cjs/type/unit/Unit.js +2 -0
  35. package/lib/cjs/utils/lruQueue.js +2 -6
  36. package/lib/cjs/utils/map.js +1 -1
  37. package/lib/cjs/utils/snapshot.js +7 -1
  38. package/lib/cjs/version.js +1 -1
  39. package/lib/esm/core/function/typed.js +1 -1
  40. package/lib/esm/expression/embeddedDocs/function/matrix/partitionSelect.js +1 -1
  41. package/lib/esm/expression/node/OperatorNode.js +1 -3
  42. package/lib/esm/expression/operators.js +1 -3
  43. package/lib/esm/function/algebra/rationalize.js +1 -3
  44. package/lib/esm/function/algebra/sparse/csAmd.js +1 -3
  45. package/lib/esm/function/algebra/sparse/csLeaf.js +1 -3
  46. package/lib/esm/function/arithmetic/expm1.js +1 -1
  47. package/lib/esm/function/arithmetic/gcd.js +27 -10
  48. package/lib/esm/function/arithmetic/nthRoots.js +2 -1
  49. package/lib/esm/function/arithmetic/round.js +1 -1
  50. package/lib/esm/function/arithmetic/sign.js +1 -1
  51. package/lib/esm/function/bitwise/rightArithShift.js +1 -1
  52. package/lib/esm/function/geometry/distance.js +13 -15
  53. package/lib/esm/function/matrix/det.js +7 -1
  54. package/lib/esm/function/matrix/diff.js +3 -3
  55. package/lib/esm/function/matrix/eigs/complexEigs.js +2 -2
  56. package/lib/esm/function/matrix/partitionSelect.js +7 -2
  57. package/lib/esm/function/set/setIsSubset.js +1 -1
  58. package/lib/esm/function/set/setSize.js +3 -2
  59. package/lib/esm/type/unit/Unit.js +2 -0
  60. package/lib/esm/utils/lruQueue.js +2 -6
  61. package/lib/esm/version.js +1 -1
  62. package/package.json +14 -14
  63. package/types/index.d.ts +251 -475
package/types/index.d.ts CHANGED
@@ -585,7 +585,7 @@ declare namespace math {
585
585
  * @returns The created bignumber
586
586
  */
587
587
  bignumber(
588
- x?: number | string | Fraction | BigNumber | boolean | Fraction | null
588
+ x?: number | string | Fraction | BigNumber | Unit | boolean | null
589
589
  ): BigNumber
590
590
  bignumber<T extends MathCollection>(x: T): T
591
591
 
@@ -664,12 +664,12 @@ declare namespace math {
664
664
 
665
665
  /**
666
666
  * Create a fraction convert a value to a fraction.
667
- * @param args Arguments specifying the numerator and denominator of the
667
+ * @param value Arguments specifying the numerator and denominator of the
668
668
  * fraction
669
669
  * @returns Returns a fraction
670
670
  */
671
671
  fraction(
672
- value: number | string | BigNumber | Fraction | FractionDefinition
672
+ value: number | string | BigNumber | Unit | Fraction | FractionDefinition
673
673
  ): Fraction
674
674
  fraction(values: MathCollection): MathCollection
675
675
  /**
@@ -776,7 +776,7 @@ declare namespace math {
776
776
  * @param unit The unit to be created
777
777
  * @returns The created unit
778
778
  */
779
- unit(value: number | BigNumber | Fraction | Complex, unit: string): Unit
779
+ unit(value: MathNumericType, unit: string): Unit
780
780
  unit(value: MathCollection, unit: string): Unit[]
781
781
 
782
782
  /*************************************************************************
@@ -859,8 +859,8 @@ declare namespace math {
859
859
  * @param b A column vector with the b values
860
860
  * @returns A column vector with the linear system solution (x)
861
861
  */
862
- lsolve(L: Matrix, b: Matrix | MathArray): Matrix
863
- lsolve(L: MathArray, b: Matrix | MathArray): MathArray
862
+ lsolve(L: Matrix, b: MathCollection): Matrix
863
+ lsolve(L: MathArray, b: MathCollection): MathArray
864
864
 
865
865
  /**
866
866
  * Calculate the Matrix LU decomposition with partial pivoting. Matrix A
@@ -871,7 +871,7 @@ declare namespace math {
871
871
  * @returns The lower triangular matrix, the upper triangular matrix and
872
872
  * the permutation matrix.
873
873
  */
874
- lup(A?: Matrix | MathArray): LUDecomposition
874
+ lup(A?: MathCollection): LUDecomposition
875
875
 
876
876
  /**
877
877
  * Solves the linear system A * x = b where A is an [n x n] matrix and b
@@ -887,19 +887,19 @@ declare namespace math {
887
887
  */
888
888
  lusolve(
889
889
  A: Matrix,
890
- b: Matrix | MathArray,
890
+ b: MathCollection,
891
891
  order?: number,
892
892
  threshold?: number
893
893
  ): Matrix
894
894
 
895
895
  lusolve(
896
896
  A: MathArray,
897
- b: Matrix | MathArray,
897
+ b: MathCollection,
898
898
  order?: number,
899
899
  threshold?: number
900
900
  ): MathArray
901
901
 
902
- lusolve(A: LUDecomposition, b: Matrix | MathArray): Matrix
902
+ lusolve(A: LUDecomposition, b: MathCollection): Matrix
903
903
 
904
904
  /* Finds the roots of a polynomial of degree three or less. Coefficients are given constant first
905
905
  * followed by linear and higher powers in order; coefficients beyond the degree of the polynomial
@@ -925,7 +925,7 @@ declare namespace math {
925
925
  * decomposition.
926
926
  * @returns Q: the orthogonal matrix and R: the upper triangular matrix
927
927
  */
928
- qr(A: Matrix | MathArray): QRDecomposition
928
+ qr(A: MathCollection): QRDecomposition
929
929
 
930
930
  rationalize(
931
931
  expr: MathNode | string,
@@ -1016,8 +1016,8 @@ declare namespace math {
1016
1016
  * @param b A column vector with the b values
1017
1017
  * @returns A column vector with the linear system solution (x)
1018
1018
  */
1019
- usolve(U: Matrix, b: Matrix | MathArray): Matrix
1020
- usolve(U: MathArray, b: Matrix | MathArray): MathArray
1019
+ usolve(U: Matrix, b: MathCollection): Matrix
1020
+ usolve(U: MathArray, b: MathCollection): MathArray
1021
1021
 
1022
1022
  /*************************************************************************
1023
1023
  * Arithmetic functions
@@ -1029,13 +1029,7 @@ declare namespace math {
1029
1029
  * @param x A number or matrix for which to get the absolute value
1030
1030
  * @returns Absolute value of x
1031
1031
  */
1032
- abs(x: number): number
1033
- abs(x: BigNumber): BigNumber
1034
- abs(x: Fraction): Fraction
1035
- abs(x: Complex): Complex
1036
- abs(x: MathArray): MathArray
1037
- abs(x: Matrix): Matrix
1038
- abs(x: Unit): Unit
1032
+ abs<T extends MathType>(x: T): T
1039
1033
 
1040
1034
  /**
1041
1035
  * Add two values, x + y. For matrices, the function is evaluated
@@ -1055,10 +1049,8 @@ declare namespace math {
1055
1049
  * if false (default) the principal root is returned.
1056
1050
  * @returns Returns the cubic root of x
1057
1051
  */
1058
- cbrt(x: number, allRoots?: boolean): number
1059
- cbrt(x: BigNumber): BigNumber
1060
1052
  cbrt(x: Complex, allRoots?: boolean): Complex
1061
- cbrt(x: Unit): Unit
1053
+ cbrt<T extends number | BigNumber | Unit>(x: T): T
1062
1054
 
1063
1055
  // Rounding functions, grouped for similarity, even though it breaks
1064
1056
  // the alphabetic order among arithmetic functions.
@@ -1124,11 +1116,7 @@ declare namespace math {
1124
1116
  * @param x Number for which to calculate the cube
1125
1117
  * @returns Cube of x
1126
1118
  */
1127
- cube(x: number): number
1128
- cube(x: BigNumber): BigNumber
1129
- cube(x: Fraction): Fraction
1130
- cube(x: Complex): Complex
1131
- cube(x: Unit): Unit
1119
+ cube<T extends MathNumericType | Unit>(x: T): T
1132
1120
 
1133
1121
  /**
1134
1122
  * Divide two values, x / y. To divide matrices, x is multiplied with
@@ -1182,9 +1170,7 @@ declare namespace math {
1182
1170
  * @param x A number or matrix to exponentiate
1183
1171
  * @returns Exponent of x
1184
1172
  */
1185
- exp(x: number): number
1186
- exp(x: BigNumber): BigNumber
1187
- exp(x: Complex): Complex
1173
+ exp<T extends number | BigNumber | Complex>(x: T): T
1188
1174
 
1189
1175
  /**
1190
1176
  * Calculate the value of subtracting 1 from the exponential value. For
@@ -1192,9 +1178,7 @@ declare namespace math {
1192
1178
  * @param x A number or matrix to apply expm1
1193
1179
  * @returns Exponent of x
1194
1180
  */
1195
- expm1(x: number): number
1196
- expm1(x: BigNumber): BigNumber
1197
- expm1(x: Complex): Complex
1181
+ expm1<T extends number | BigNumber | Complex>(x: T): T
1198
1182
 
1199
1183
  /**
1200
1184
  * Calculate the greatest common divisor for two or more values or
@@ -1202,11 +1186,10 @@ declare namespace math {
1202
1186
  * @param args Two or more integer numbers
1203
1187
  * @returns The greatest common divisor
1204
1188
  */
1205
- gcd(...args: number[]): number
1206
- gcd(...args: BigNumber[]): BigNumber
1207
- gcd(...args: Fraction[]): Fraction
1208
- gcd(...args: MathArray[]): MathArray
1209
- gcd(...args: Matrix[]): Matrix
1189
+ gcd<T extends number | BigNumber | Fraction | MathCollection>(
1190
+ ...args: T[]
1191
+ ): T
1192
+ gcd<T extends number | BigNumber | Fraction | Matrix>(args: T[]): T
1210
1193
 
1211
1194
  /**
1212
1195
  * Calculate the hypotenusa of a list with values. The hypotenusa is
@@ -1218,8 +1201,7 @@ declare namespace math {
1218
1201
  * whole matrix.
1219
1202
  * @returns Returns the hypothenuse of the input values.
1220
1203
  */
1221
- hypot(...args: number[]): number
1222
- hypot(...args: BigNumber[]): BigNumber
1204
+ hypot<T extends (number | BigNumber)[]>(...args: T[]): T
1223
1205
 
1224
1206
  /**
1225
1207
  * Calculate the least common multiple for two or more values or arrays.
@@ -1229,10 +1211,7 @@ declare namespace math {
1229
1211
  * @param b An integer number
1230
1212
  * @returns The least common multiple
1231
1213
  */
1232
- lcm(a: number, b: number): number
1233
- lcm(a: BigNumber, b: BigNumber): BigNumber
1234
- lcm(a: MathArray, b: MathArray): MathArray
1235
- lcm(a: Matrix, b: Matrix): Matrix
1214
+ lcm<T extends number | BigNumber | MathCollection>(a: T, b: T): T
1236
1215
 
1237
1216
  /**
1238
1217
  * Calculate the logarithm of a value.
@@ -1252,11 +1231,7 @@ declare namespace math {
1252
1231
  * @param x Value for which to calculate the logarithm.
1253
1232
  * @returns Returns the 10-base logarithm of x
1254
1233
  */
1255
- log10(x: number): number
1256
- log10(x: BigNumber): BigNumber
1257
- log10(x: Complex): Complex
1258
- log10(x: MathArray): MathArray
1259
- log10(x: Matrix): Matrix
1234
+ log10<T extends number | BigNumber | Complex | MathCollection>(x: T): T
1260
1235
 
1261
1236
  /**
1262
1237
  * Calculate the logarithm of a value+1. For matrices, the function is
@@ -1264,11 +1239,10 @@ declare namespace math {
1264
1239
  * @param x Value for which to calculate the logarithm.
1265
1240
  * @returns Returns the logarithm of x+1
1266
1241
  */
1267
- log1p(x: number, base?: number | BigNumber | Complex): number
1268
- log1p(x: BigNumber, base?: number | BigNumber | Complex): BigNumber
1269
- log1p(x: Complex, base?: number | BigNumber | Complex): Complex
1270
- log1p(x: MathArray, base?: number | BigNumber | Complex): MathArray
1271
- log1p(x: Matrix, base?: number | BigNumber | Complex): Matrix
1242
+ log1p<T extends number | BigNumber | Complex | MathCollection>(
1243
+ x: T,
1244
+ base?: number | BigNumber | Complex
1245
+ ): T
1272
1246
 
1273
1247
  /**
1274
1248
  * Calculate the 2-base of a value. This is the same as calculating
@@ -1276,11 +1250,7 @@ declare namespace math {
1276
1250
  * @param x Value for which to calculate the logarithm.
1277
1251
  * @returns Returns the 2-base logarithm of x
1278
1252
  */
1279
- log2(x: number): number
1280
- log2(x: BigNumber): BigNumber
1281
- log2(x: Complex): Complex
1282
- log2(x: MathArray): MathArray
1283
- log2(x: Matrix): Matrix
1253
+ log2<T extends number | BigNumber | Complex | MathCollection>(x: T): T
1284
1254
 
1285
1255
  /**
1286
1256
  * Calculates the modulus, the remainder of an integer division. For
@@ -1309,9 +1279,7 @@ declare namespace math {
1309
1279
 
1310
1280
  multiply<T extends MathNumericType[]>(x: T, y: T[]): T
1311
1281
  multiply<T extends MathNumericType[]>(x: T[], y: T): T
1312
-
1313
1282
  multiply<T extends MathArray>(x: T, y: T): T
1314
-
1315
1283
  multiply(x: Unit, y: Unit): Unit
1316
1284
  multiply(x: number, y: number): number
1317
1285
  multiply(x: MathType, y: MathType): MathType
@@ -1359,13 +1327,7 @@ declare namespace math {
1359
1327
  * @param x The number for which to determine the sign
1360
1328
  * @returns The sign of x
1361
1329
  */
1362
- sign(x: number): number
1363
- sign(x: BigNumber): BigNumber
1364
- sign(x: Fraction): Fraction
1365
- sign(x: Complex): Complex
1366
- sign(x: MathArray): MathArray
1367
- sign(x: Matrix): Matrix
1368
- sign(x: Unit): Unit
1330
+ sign<T extends MathType>(x: T): T
1369
1331
 
1370
1332
  /**
1371
1333
  * Calculate the square root of a value. For matrices, use either
@@ -1375,20 +1337,14 @@ declare namespace math {
1375
1337
  * @returns Returns the square root of x
1376
1338
  */
1377
1339
  sqrt(x: number): number | Complex
1378
- sqrt(x: BigNumber): BigNumber
1379
- sqrt(x: Complex): Complex
1380
- sqrt(x: Unit): Unit
1340
+ sqrt<T extends BigNumber | Complex | Unit>(x: T): T
1381
1341
 
1382
1342
  /**
1383
1343
  * Compute the square of a value, x * x.
1384
1344
  * @param x Number for which to calculate the square
1385
1345
  * @returns Squared value
1386
1346
  */
1387
- square(x: number): number
1388
- square(x: BigNumber): BigNumber
1389
- square(x: Fraction): Fraction
1390
- square(x: Complex): Complex
1391
- square(x: Unit): Unit
1347
+ square<T extends MathNumericType | Unit>(x: T): T
1392
1348
 
1393
1349
  /**
1394
1350
  * Subtract two values, x - y. For matrices, the function is evaluated
@@ -1408,13 +1364,7 @@ declare namespace math {
1408
1364
  * @param x Number to be inverted
1409
1365
  * @returns Retursn the value with inverted sign
1410
1366
  */
1411
- unaryMinus(x: number): number
1412
- unaryMinus(x: BigNumber): BigNumber
1413
- unaryMinus(x: Fraction): Fraction
1414
- unaryMinus(x: Complex): Complex
1415
- unaryMinus(x: MathArray): MathArray
1416
- unaryMinus(x: Matrix): Matrix
1417
- unaryMinus(x: Unit): Unit
1367
+ unaryMinus<T extends MathType>(x: T): T
1418
1368
 
1419
1369
  /**
1420
1370
  * Unary plus operation. Boolean values and strings will be converted to
@@ -1424,14 +1374,7 @@ declare namespace math {
1424
1374
  * @returns Returns the input value when numeric, converts to a number
1425
1375
  * when input is non-numeric.
1426
1376
  */
1427
- unaryPlus(x: number): number
1428
- unaryPlus(x: BigNumber): BigNumber
1429
- unaryPlus(x: Fraction): Fraction
1430
- unaryPlus(x: string): string
1431
- unaryPlus(x: Complex): Complex
1432
- unaryPlus(x: MathArray): MathArray
1433
- unaryPlus(x: Matrix): Matrix
1434
- unaryPlus(x: Unit): Unit
1377
+ unaryPlus<T extends string | MathType>(x: T): T
1435
1378
 
1436
1379
  /**
1437
1380
  * Calculate the extended greatest common divisor for two values. See
@@ -1466,10 +1409,7 @@ declare namespace math {
1466
1409
  * @param x Value to not
1467
1410
  * @returns NOT of x
1468
1411
  */
1469
- bitNot(x: number): number
1470
- bitNot(x: BigNumber): BigNumber
1471
- bitNot(x: MathArray): MathArray
1472
- bitNot(x: Matrix): Matrix
1412
+ bitNot<T extends number | BigNumber | MathCollection>(x: T): T
1473
1413
 
1474
1414
  /**
1475
1415
  * Bitwise OR two values, x | y. For matrices, the function is evaluated
@@ -1479,10 +1419,7 @@ declare namespace math {
1479
1419
  * @param y Second value to or
1480
1420
  * @returns OR of x and y
1481
1421
  */
1482
- bitOr(x: number, y: number): number
1483
- bitOr(x: BigNumber, y: BigNumber): BigNumber
1484
- bitOr(x: MathArray, y: MathArray): MathArray
1485
- bitOr(x: Matrix, y: Matrix): Matrix
1422
+ bitOr<T extends number | BigNumber | MathCollection>(x: T, y: T): T
1486
1423
 
1487
1424
  /**
1488
1425
  * Bitwise XOR two values, x ^ y. For matrices, the function is
@@ -1547,8 +1484,7 @@ declare namespace math {
1547
1484
  * @param n Total number of objects in the set
1548
1485
  * @returns B(n)
1549
1486
  */
1550
- bellNumbers(n: number): number
1551
- bellNumbers(n: BigNumber): BigNumber
1487
+ bellNumbers<T extends number | BigNumber>(n: T): T
1552
1488
 
1553
1489
  /**
1554
1490
  * The Catalan Numbers enumerate combinatorial structures of many
@@ -1557,8 +1493,7 @@ declare namespace math {
1557
1493
  * @param n nth Catalan number
1558
1494
  * @returns Cn(n)
1559
1495
  */
1560
- catalan(n: number): number
1561
- catalan(n: BigNumber): BigNumber
1496
+ catalan<T extends number | BigNumber>(n: T): T
1562
1497
 
1563
1498
  /**
1564
1499
  * The composition counts of n into k parts. Composition only takes
@@ -1600,8 +1535,7 @@ declare namespace math {
1600
1535
  */
1601
1536
  arg(x: number | Complex): number
1602
1537
  arg(x: BigNumber | Complex): BigNumber
1603
- arg(x: MathArray): MathArray
1604
- arg(x: Matrix): Matrix
1538
+ arg<T extends MathCollection>(x: T): T
1605
1539
 
1606
1540
  /**
1607
1541
  * Compute the complex conjugate of a complex value. If x = a+bi, the
@@ -1622,8 +1556,7 @@ declare namespace math {
1622
1556
  * @returns The imaginary part of x
1623
1557
  */
1624
1558
  im(x: MathJsChain<number | Complex>): MathJsChain<number>
1625
- im(x: MathJsChain<BigNumber>): MathJsChain<BigNumber>
1626
- im(x: MathJsChain<MathCollection>): MathJsChain<MathCollection>
1559
+ im<T extends BigNumber | MathCollection>(x: MathJsChain<T>): MathJsChain<T>
1627
1560
 
1628
1561
  /**
1629
1562
  * Get the real part of a complex number. For a complex number a + bi,
@@ -1633,8 +1566,7 @@ declare namespace math {
1633
1566
  * @returns The real part of x
1634
1567
  */
1635
1568
  re(x: MathJsChain<number | Complex>): MathJsChain<number>
1636
- re(x: MathJsChain<BigNumber>): MathJsChain<BigNumber>
1637
- re(x: MathJsChain<MathCollection>): MathJsChain<MathCollection>
1569
+ re<T extends BigNumber | MathCollection>(x: MathJsChain<T>): MathJsChain<T>
1638
1570
 
1639
1571
  /*************************************************************************
1640
1572
  * Geometry functions
@@ -1773,7 +1705,7 @@ declare namespace math {
1773
1705
  * @param y Second vector
1774
1706
  * @returns Returns the cross product of x and y
1775
1707
  */
1776
- cross(x: MathCollection, y: MathCollection): Matrix | MathArray
1708
+ cross(x: MathCollection, y: MathCollection): MathCollection
1777
1709
 
1778
1710
  /**
1779
1711
  * Calculate the determinant of a matrix.
@@ -1801,7 +1733,7 @@ declare namespace math {
1801
1733
  X: MathCollection,
1802
1734
  k: number | BigNumber,
1803
1735
  format?: string
1804
- ): Matrix | MathArray
1736
+ ): MathCollection
1805
1737
 
1806
1738
  /**
1807
1739
  * Calculate the dot product of two vectors. The dot product of A = [a1,
@@ -1853,10 +1785,10 @@ declare namespace math {
1853
1785
  * @returns Matrix X, solving the Sylvester equation
1854
1786
  */
1855
1787
  sylvester(
1856
- A: Matrix | MathArray,
1857
- B: Matrix | MathArray,
1858
- C: Matrix | MathArray
1859
- ): Matrix | MathArray
1788
+ A: MathCollection,
1789
+ B: MathCollection,
1790
+ C: MathCollection
1791
+ ): MathCollection
1860
1792
 
1861
1793
  /**
1862
1794
  * Performs a real Schur decomposition of the real matrix A = UTU' where U is orthogonal
@@ -1865,7 +1797,7 @@ declare namespace math {
1865
1797
  * @param A Matrix A
1866
1798
  * @returns Object containing both matrix U and T of the Schur Decomposition A=UTU'
1867
1799
  */
1868
- schur(A: Matrix | MathArray): SchurDecomposition
1800
+ schur(A: MathCollection): SchurDecomposition
1869
1801
 
1870
1802
  /**
1871
1803
  * Solves the Continuous-time Lyapunov equation AP+PA'=Q for P, where Q is a positive semidefinite
@@ -1875,7 +1807,7 @@ declare namespace math {
1875
1807
  * @param Q Matrix Q
1876
1808
  * @returns Matrix P solution to the Continuous-time Lyapunov equation AP+PA'=Q
1877
1809
  */
1878
- lyap(A: Matrix | MathArray, Q: Matrix | MathArray): Matrix | MathArray
1810
+ lyap(A: MathCollection, Q: MathCollection): MathCollection
1879
1811
 
1880
1812
  /**
1881
1813
  * Create a 2-dimensional identity matrix with size m x n or n x n. The
@@ -1885,16 +1817,16 @@ declare namespace math {
1885
1817
  * @returns A matrix with ones on the diagonal
1886
1818
  */
1887
1819
  identity(
1888
- size: number | number[] | Matrix | MathArray,
1820
+ size: number | number[] | MathCollection,
1889
1821
  format?: string
1890
- ): Matrix | MathArray | number
1822
+ ): MathCollection | number
1891
1823
  /**
1892
1824
  * @param m The x dimension for the matrix
1893
1825
  * @param n The y dimension for the matrix
1894
1826
  * @param format The Matrix storage format
1895
1827
  * @returns A matrix with ones on the diagonal
1896
1828
  */
1897
- identity(m: number, n: number, format?: string): Matrix | MathArray | number
1829
+ identity(m: number, n: number, format?: string): MathCollection | number
1898
1830
 
1899
1831
  /**
1900
1832
  * Filter the items in an array or one dimensional matrix.
@@ -1906,17 +1838,17 @@ declare namespace math {
1906
1838
  * traversed. The function must return a boolean.
1907
1839
  */
1908
1840
  filter(
1909
- x: Matrix | MathArray | string[],
1841
+ x: MathCollection | string[],
1910
1842
  test:
1911
1843
  | ((
1912
1844
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1913
1845
  value: any,
1914
1846
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1915
1847
  index: any,
1916
- matrix: Matrix | MathArray | string[]
1848
+ matrix: MathCollection | string[]
1917
1849
  ) => boolean)
1918
1850
  | RegExp
1919
- ): Matrix | MathArray
1851
+ ): MathCollection
1920
1852
 
1921
1853
  /**
1922
1854
  * Flatten a multi dimensional matrix into a single dimensional matrix.
@@ -1933,7 +1865,7 @@ declare namespace math {
1933
1865
  * parameters: the value of the element, the index of the element, and
1934
1866
  * the Matrix/array being traversed.
1935
1867
  */
1936
- forEach<T extends Matrix | MathArray>(
1868
+ forEach<T extends MathCollection>(
1937
1869
  x: T,
1938
1870
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1939
1871
  callback: (value: any, index: any, matrix: T) => void
@@ -1952,7 +1884,7 @@ declare namespace math {
1952
1884
  * @param y Second vector
1953
1885
  * @returns Returns the kronecker product of x and y
1954
1886
  */
1955
- kron(x: Matrix | MathArray, y: Matrix | MathArray): Matrix
1887
+ kron(x: MathCollection, y: MathCollection): Matrix
1956
1888
 
1957
1889
  /**
1958
1890
  * Iterate over all elements of a matrix/array, and executes the given
@@ -1963,7 +1895,7 @@ declare namespace math {
1963
1895
  * the Matrix/array being traversed.
1964
1896
  * @returns Transformed map of x
1965
1897
  */
1966
- map<T extends Matrix | MathArray>(
1898
+ map<T extends MathCollection>(
1967
1899
  x: T,
1968
1900
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1969
1901
  callback: (value: any, index: any, matrix: T) => MathType | string
@@ -2141,7 +2073,7 @@ declare namespace math {
2141
2073
  * b, and 0 when a == b. Default value: ‘asc’
2142
2074
  * @returns Returns the sorted matrix
2143
2075
  */
2144
- sort<T extends Matrix | MathArray>(
2076
+ sort<T extends MathCollection>(
2145
2077
  x: T,
2146
2078
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2147
2079
  compare: ((a: any, b: any) => number) | 'asc' | 'desc' | 'natural'
@@ -2422,10 +2354,7 @@ declare namespace math {
2422
2354
  * @returns Returns true when the input matrices have the same size and
2423
2355
  * each of their elements is equal.
2424
2356
  */
2425
- deepEqual(
2426
- x: MathType,
2427
- y: MathType
2428
- ): number | BigNumber | Fraction | Complex | Unit | MathCollection
2357
+ deepEqual(x: MathType, y: MathType): MathType
2429
2358
 
2430
2359
  /**
2431
2360
  * Test whether two values are equal.
@@ -2594,10 +2523,7 @@ declare namespace math {
2594
2523
  * @returns The number of how many times the multiset contains the
2595
2524
  * element
2596
2525
  */
2597
- setMultiplicity(
2598
- e: number | BigNumber | Fraction | Complex,
2599
- a: MathCollection
2600
- ): number
2526
+ setMultiplicity(e: MathNumericType, a: MathCollection): number
2601
2527
 
2602
2528
  /**
2603
2529
  * Create the powerset of a (multi)set. (The powerset contains very
@@ -2970,8 +2896,7 @@ declare namespace math {
2970
2896
  * @returns The arc cosine of x
2971
2897
  */
2972
2898
  acos(x: number): number | Complex
2973
- acos(x: BigNumber): BigNumber
2974
- acos(x: Complex): Complex
2899
+ acos<T extends BigNumber | Complex>(x: T): T
2975
2900
 
2976
2901
  /**
2977
2902
  * Calculate the hyperbolic arccos of a value, defined as acosh(x) =
@@ -2980,8 +2905,7 @@ declare namespace math {
2980
2905
  * @returns The hyperbolic arccosine of x
2981
2906
  */
2982
2907
  acosh(x: number): number | Complex
2983
- acosh(x: BigNumber): BigNumber
2984
- acosh(x: Complex): Complex
2908
+ acosh<T extends BigNumber | Complex>(x: T): T
2985
2909
 
2986
2910
  /**
2987
2911
  * Calculate the inverse cotangent of a value.
@@ -2989,8 +2913,7 @@ declare namespace math {
2989
2913
  * @returns The arc cotangent of x
2990
2914
  */
2991
2915
  acot(x: number): number
2992
- acot(x: BigNumber): BigNumber
2993
- acot(x: Complex): Complex
2916
+ acot<T extends BigNumber | Complex>(x: T): T
2994
2917
 
2995
2918
  /**
2996
2919
  * Calculate the hyperbolic arccotangent of a value, defined as acoth(x)
@@ -2999,8 +2922,7 @@ declare namespace math {
2999
2922
  * @returns The hyperbolic arccotangent of x
3000
2923
  */
3001
2924
  acoth(x: number): number
3002
- acoth(x: BigNumber): BigNumber
3003
- acoth(x: Complex): Complex
2925
+ acoth<T extends BigNumber | Complex>(x: T): T
3004
2926
 
3005
2927
  /**
3006
2928
  * Calculate the inverse cosecant of a value.
@@ -3008,8 +2930,7 @@ declare namespace math {
3008
2930
  * @returns The arc cosecant of x
3009
2931
  */
3010
2932
  acsc(x: number): number | Complex
3011
- acsc(x: BigNumber): BigNumber
3012
- acsc(x: Complex): Complex
2933
+ acsc<T extends BigNumber | Complex>(x: T): T
3013
2934
 
3014
2935
  /**
3015
2936
  * Calculate the hyperbolic arccosecant of a value, defined as acsch(x)
@@ -3018,8 +2939,7 @@ declare namespace math {
3018
2939
  * @returns The hyperbolic arccosecant of x
3019
2940
  */
3020
2941
  acsch(x: number): number
3021
- acsch(x: BigNumber): BigNumber
3022
- acsch(x: Complex): Complex
2942
+ acsch<T extends BigNumber | Complex>(x: T): T
3023
2943
 
3024
2944
  /**
3025
2945
  * Calculate the inverse secant of a value.
@@ -3027,8 +2947,7 @@ declare namespace math {
3027
2947
  * @returns The arc secant of x
3028
2948
  */
3029
2949
  asec(x: number): number | Complex
3030
- asec(x: BigNumber): BigNumber
3031
- asec(x: Complex): Complex
2950
+ asec<T extends BigNumber | Complex>(x: T): T
3032
2951
 
3033
2952
  /**
3034
2953
  * Calculate the hyperbolic arcsecant of a value, defined as asech(x) =
@@ -3037,8 +2956,7 @@ declare namespace math {
3037
2956
  * @returns The hyperbolic arcsecant of x
3038
2957
  */
3039
2958
  asech(x: number): number | Complex
3040
- asech(x: BigNumber): BigNumber
3041
- asech(x: Complex): Complex
2959
+ asech<T extends BigNumber | Complex>(x: T): T
3042
2960
 
3043
2961
  /**
3044
2962
  * Calculate the inverse sine of a value.
@@ -3046,8 +2964,7 @@ declare namespace math {
3046
2964
  * @returns The arc sine of x
3047
2965
  */
3048
2966
  asin(x: number): number | Complex
3049
- asin(x: BigNumber): BigNumber
3050
- asin(x: Complex): Complex
2967
+ asin<T extends BigNumber | Complex>(x: T): T
3051
2968
 
3052
2969
  /**
3053
2970
  * Calculate the hyperbolic arcsine of a value, defined as asinh(x) =
@@ -3055,18 +2972,14 @@ declare namespace math {
3055
2972
  * @param x Function input
3056
2973
  * @returns The hyperbolic arcsine of x
3057
2974
  */
3058
- asinh(x: number): number
3059
- asinh(x: BigNumber): BigNumber
3060
- asinh(x: Complex): Complex
2975
+ asinh<T extends number | BigNumber | Complex>(x: T): T
3061
2976
 
3062
2977
  /**
3063
2978
  * Calculate the inverse tangent of a value.
3064
2979
  * @param x Function input
3065
2980
  * @returns The arc tangent of x
3066
2981
  */
3067
- atan(x: number): number
3068
- atan(x: BigNumber): BigNumber
3069
- atan(x: Complex): Complex
2982
+ atan<T extends number | BigNumber | Complex>(x: T): T
3070
2983
 
3071
2984
  /**
3072
2985
  * Calculate the inverse tangent function with two arguments, y/x. By
@@ -3075,8 +2988,7 @@ declare namespace math {
3075
2988
  * @param x Function input
3076
2989
  * @returns Four quadrant inverse tangent
3077
2990
  */
3078
- atan2(y: number, x: number): number
3079
- atan2(y: MathCollection, x: MathCollection): MathCollection
2991
+ atan2<T extends number | MathCollection>(y: T, x: T): T
3080
2992
 
3081
2993
  /**
3082
2994
  * Calculate the hyperbolic arctangent of a value, defined as atanh(x) =
@@ -3085,8 +2997,7 @@ declare namespace math {
3085
2997
  * @returns The hyperbolic arctangent of x
3086
2998
  */
3087
2999
  atanh(x: number): number | Complex
3088
- atanh(x: BigNumber): BigNumber
3089
- atanh(x: Complex): Complex
3000
+ atanh<T extends BigNumber | Complex>(x: T): T
3090
3001
 
3091
3002
  /**
3092
3003
  * Calculate the cosine of a value.
@@ -3094,8 +3005,7 @@ declare namespace math {
3094
3005
  * @returns The cosine of x
3095
3006
  */
3096
3007
  cos(x: number | Unit): number
3097
- cos(x: BigNumber): BigNumber
3098
- cos(x: Complex): Complex
3008
+ cos<T extends BigNumber | Complex>(x: T): T
3099
3009
 
3100
3010
  /**
3101
3011
  * Calculate the hyperbolic cosine of a value, defined as cosh(x) = 1/2
@@ -3104,8 +3014,7 @@ declare namespace math {
3104
3014
  * @returns The hyperbolic cosine of x
3105
3015
  */
3106
3016
  cosh(x: number | Unit): number
3107
- cosh(x: BigNumber): BigNumber
3108
- cosh(x: Complex): Complex
3017
+ cosh<T extends BigNumber | Complex>(x: T): T
3109
3018
 
3110
3019
  /**
3111
3020
  * Calculate the cotangent of a value. cot(x) is defined as 1 / tan(x).
@@ -3113,8 +3022,7 @@ declare namespace math {
3113
3022
  * @returns The cotangent of x
3114
3023
  */
3115
3024
  cot(x: number | Unit): number
3116
- cot(x: BigNumber): BigNumber
3117
- cot(x: Complex): Complex
3025
+ cot<T extends BigNumber | Complex>(x: T): T
3118
3026
 
3119
3027
  /**
3120
3028
  * Calculate the hyperbolic cotangent of a value, defined as coth(x) = 1
@@ -3123,8 +3031,7 @@ declare namespace math {
3123
3031
  * @returns The hyperbolic cotangent of x
3124
3032
  */
3125
3033
  coth(x: number | Unit): number
3126
- coth(x: BigNumber): BigNumber
3127
- coth(x: Complex): Complex
3034
+ coth<T extends BigNumber | Complex>(x: T): T
3128
3035
 
3129
3036
  /**
3130
3037
  * Calculate the cosecant of a value, defined as csc(x) = 1/sin(x).
@@ -3132,8 +3039,7 @@ declare namespace math {
3132
3039
  * @returns The cosecant hof x
3133
3040
  */
3134
3041
  csc(x: number | Unit): number
3135
- csc(x: BigNumber): BigNumber
3136
- csc(x: Complex): Complex
3042
+ csc<T extends BigNumber | Complex>(x: T): T
3137
3043
 
3138
3044
  /**
3139
3045
  * Calculate the hyperbolic cosecant of a value, defined as csch(x) = 1
@@ -3142,8 +3048,7 @@ declare namespace math {
3142
3048
  * @returns The hyperbolic cosecant of x
3143
3049
  */
3144
3050
  csch(x: number | Unit): number
3145
- csch(x: BigNumber): BigNumber
3146
- csch(x: Complex): Complex
3051
+ csch<T extends BigNumber | Complex>(x: T): T
3147
3052
 
3148
3053
  /**
3149
3054
  * Calculate the secant of a value, defined as sec(x) = 1/cos(x).
@@ -3151,8 +3056,7 @@ declare namespace math {
3151
3056
  * @returns The secant of x
3152
3057
  */
3153
3058
  sec(x: number | Unit): number
3154
- sec(x: BigNumber): BigNumber
3155
- sec(x: Complex): Complex
3059
+ sec<T extends BigNumber | Complex>(x: T): T
3156
3060
 
3157
3061
  /**
3158
3062
  * Calculate the hyperbolic secant of a value, defined as sech(x) = 1 /
@@ -3161,8 +3065,7 @@ declare namespace math {
3161
3065
  * @returns The hyperbolic secant of x
3162
3066
  */
3163
3067
  sech(x: number | Unit): number
3164
- sech(x: BigNumber): BigNumber
3165
- sech(x: Complex): Complex
3068
+ sech<T extends BigNumber | Complex>(x: T): T
3166
3069
 
3167
3070
  /**
3168
3071
  * Calculate the sine of a value.
@@ -3170,8 +3073,7 @@ declare namespace math {
3170
3073
  * @returns The sine of x
3171
3074
  */
3172
3075
  sin(x: number | Unit): number
3173
- sin(x: BigNumber): BigNumber
3174
- sin(x: Complex): Complex
3076
+ sin<T extends BigNumber | Complex>(x: T): T
3175
3077
 
3176
3078
  /**
3177
3079
  * Calculate the hyperbolic sine of a value, defined as sinh(x) = 1/2 *
@@ -3180,8 +3082,7 @@ declare namespace math {
3180
3082
  * @returns The hyperbolic sine of x
3181
3083
  */
3182
3084
  sinh(x: number | Unit): number
3183
- sinh(x: BigNumber): BigNumber
3184
- sinh(x: Complex): Complex
3085
+ sinh<T extends BigNumber | Complex>(x: T): T
3185
3086
 
3186
3087
  /**
3187
3088
  * Calculate the tangent of a value. tan(x) is equal to sin(x) / cos(x).
@@ -3189,8 +3090,7 @@ declare namespace math {
3189
3090
  * @returns The tangent of x
3190
3091
  */
3191
3092
  tan(x: number | Unit): number
3192
- tan(x: BigNumber): BigNumber
3193
- tan(x: Complex): Complex
3093
+ tan<T extends BigNumber | Complex>(x: T): T
3194
3094
 
3195
3095
  /**
3196
3096
  * Calculate the hyperbolic tangent of a value, defined as tanh(x) =
@@ -3199,8 +3099,7 @@ declare namespace math {
3199
3099
  * @returns The hyperbolic tangent of x
3200
3100
  */
3201
3101
  tanh(x: number | Unit): number
3202
- tanh(x: BigNumber): BigNumber
3203
- tanh(x: Complex): Complex
3102
+ tanh<T extends BigNumber | Complex>(x: T): T
3204
3103
 
3205
3104
  /*************************************************************************
3206
3105
  * Unit functions
@@ -3396,9 +3295,7 @@ declare namespace math {
3396
3295
  * @returns Returns true when x is zero. Throws an error in case of an
3397
3296
  * unknown data type.
3398
3297
  */
3399
- isZero(
3400
- x: number | BigNumber | Fraction | MathCollection | Unit | Complex
3401
- ): boolean
3298
+ isZero(x: MathType): boolean
3402
3299
 
3403
3300
  /**
3404
3301
  * Determine the type of a variable.
@@ -3784,7 +3681,7 @@ declare namespace math {
3784
3681
  apply(
3785
3682
  dim: number,
3786
3683
  callback: (array: MathCollection) => number
3787
- ): Matrix | MathArray
3684
+ ): MathCollection
3788
3685
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3789
3686
  get(index: number[]): any
3790
3687
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -4251,7 +4148,7 @@ declare namespace math {
4251
4148
  */
4252
4149
  bignumber(
4253
4150
  this: MathJsChain<
4254
- number | string | Fraction | BigNumber | boolean | Fraction | null
4151
+ number | string | Fraction | BigNumber | Unit | boolean | null
4255
4152
  >
4256
4153
  ): MathJsChain<BigNumber>
4257
4154
  bignumber<T extends MathCollection>(this: MathJsChain<T>): MathJsChain<T>
@@ -4317,7 +4214,7 @@ declare namespace math {
4317
4214
  */
4318
4215
  fraction(
4319
4216
  this: MathJsChain<
4320
- number | string | BigNumber | Fraction | FractionDefinition
4217
+ number | string | BigNumber | Unit | Fraction | FractionDefinition
4321
4218
  >,
4322
4219
  denominator?: number
4323
4220
  ): MathJsChain<Fraction>
@@ -4395,11 +4292,7 @@ declare namespace math {
4395
4292
  * @param unit The unit to be created
4396
4293
  */
4397
4294
  unit(this: MathJsChain<string>, unit?: string): MathJsChain<Unit>
4398
- unit(this: MathJsChain<Unit>, unit?: string): MathJsChain<Unit>
4399
- unit(
4400
- this: MathJsChain<number | BigNumber | Fraction | Complex>,
4401
- unit?: string
4402
- ): MathJsChain<Unit>
4295
+ unit(this: MathJsChain<MathNumericType>, unit?: string): MathJsChain<Unit>
4403
4296
  unit(this: MathJsChain<MathCollection>, unit?: string): MathJsChain<Unit[]>
4404
4297
 
4405
4298
  /*************************************************************************
@@ -4488,13 +4381,10 @@ declare namespace math {
4488
4381
  * must be a lower triangular matrix.
4489
4382
  * @param b A column vector with the b values
4490
4383
  */
4491
- lsolve(
4492
- this: MathJsChain<Matrix>,
4493
- b: Matrix | MathArray
4494
- ): MathJsChain<Matrix>
4384
+ lsolve(this: MathJsChain<Matrix>, b: MathCollection): MathJsChain<Matrix>
4495
4385
  lsolve(
4496
4386
  this: MathJsChain<MathArray>,
4497
- b: Matrix | MathArray
4387
+ b: MathCollection
4498
4388
  ): MathJsChain<MathArray>
4499
4389
 
4500
4390
  /**
@@ -4502,7 +4392,7 @@ declare namespace math {
4502
4392
  * is decomposed in two matrices (L, U) and a row permutation vector p
4503
4393
  * where A[p,:] = L * U
4504
4394
  */
4505
- lup(this: MathJsChain<Matrix | MathArray>): MathJsChain<LUDecomposition>
4395
+ lup(this: MathJsChain<MathCollection>): MathJsChain<LUDecomposition>
4506
4396
 
4507
4397
  /**
4508
4398
  * Solves the linear system A * x = b where A is an [n x n] matrix and b
@@ -4515,21 +4405,21 @@ declare namespace math {
4515
4405
  */
4516
4406
  lusolve(
4517
4407
  this: MathJsChain<Matrix>,
4518
- b: Matrix | MathArray,
4408
+ b: MathCollection,
4519
4409
  order?: number,
4520
4410
  threshold?: number
4521
4411
  ): MathJsChain<Matrix>
4522
4412
 
4523
4413
  lusolve(
4524
4414
  this: MathJsChain<MathArray>,
4525
- b: Matrix | MathArray,
4415
+ b: MathCollection,
4526
4416
  order?: number,
4527
4417
  threshold?: number
4528
4418
  ): MathJsChain<MathArray>
4529
4419
 
4530
4420
  lusolve(
4531
4421
  this: MathJsChain<LUDecomposition>,
4532
- b: Matrix | MathArray
4422
+ b: MathCollection
4533
4423
  ): MathJsChain<Matrix>
4534
4424
 
4535
4425
  /**
@@ -4537,7 +4427,7 @@ declare namespace math {
4537
4427
  * matrices (Q, R) where Q is an orthogonal matrix and R is an upper
4538
4428
  * triangular matrix.
4539
4429
  */
4540
- qr(this: MathJsChain<Matrix | MathArray>): MathJsChain<QRDecomposition>
4430
+ qr(this: MathJsChain<MathCollection>): MathJsChain<QRDecomposition>
4541
4431
 
4542
4432
  /**
4543
4433
  * Transform a rationalizable expression in a rational fraction. If
@@ -4606,13 +4496,10 @@ declare namespace math {
4606
4496
  * must be an upper triangular matrix. U * x = b
4607
4497
  * @param b A column vector with the b values
4608
4498
  */
4609
- usolve(
4610
- this: MathJsChain<Matrix>,
4611
- b: Matrix | MathArray
4612
- ): MathJsChain<Matrix>
4499
+ usolve(this: MathJsChain<Matrix>, b: MathCollection): MathJsChain<Matrix>
4613
4500
  usolve(
4614
4501
  this: MathJsChain<MathArray>,
4615
- b: Matrix | MathArray
4502
+ b: MathCollection
4616
4503
  ): MathJsChain<MathArray>
4617
4504
 
4618
4505
  /*************************************************************************
@@ -4623,13 +4510,7 @@ declare namespace math {
4623
4510
  * Calculate the absolute value of a number. For matrices, the function
4624
4511
  * is evaluated element wise.
4625
4512
  */
4626
- abs(this: MathJsChain<number>): MathJsChain<number>
4627
- abs(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
4628
- abs(this: MathJsChain<Fraction>): MathJsChain<Fraction>
4629
- abs(this: MathJsChain<Complex>): MathJsChain<Complex>
4630
- abs(this: MathJsChain<MathArray>): MathJsChain<MathArray>
4631
- abs(this: MathJsChain<Matrix>): MathJsChain<Matrix>
4632
- abs(this: MathJsChain<Unit>): MathJsChain<Unit>
4513
+ abs<T extends MathType>(this: MathJsChain<T>): MathJsChain<T>
4633
4514
 
4634
4515
  /**
4635
4516
  * Add two values, x + y. For matrices, the function is evaluated
@@ -4661,10 +4542,10 @@ declare namespace math {
4661
4542
  * a number or complex number. If true, all complex roots are returned,
4662
4543
  * if false (default) the principal root is returned.
4663
4544
  */
4664
- cbrt(this: MathJsChain<number>, allRoots?: boolean): MathJsChain<number>
4665
- cbrt(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
4666
- cbrt(this: MathJsChain<Complex>, allRoots?: boolean): MathJsChain<Complex>
4667
- cbrt(this: MathJsChain<Unit>, allRoots?: boolean): MathJsChain<Unit>
4545
+ cbrt<T extends number | BigNumber | Complex | Unit>(
4546
+ this: MathJsChain<T>,
4547
+ allRoots?: boolean
4548
+ ): MathJsChain<T>
4668
4549
 
4669
4550
  // Rounding functions grouped for similarity
4670
4551
 
@@ -4674,56 +4555,40 @@ declare namespace math {
4674
4555
  * function is evaluated element wise.
4675
4556
  * @param n Number of decimals Default value: 0.
4676
4557
  */
4677
- ceil(
4678
- this: MathJsChain<MathNumericType>,
4679
- n?: number | BigNumber | MathCollection
4680
- ): MathJsChain<MathNumericType>
4681
- ceil(
4682
- this: MathJsChain<MathCollection>,
4558
+ ceil<T extends MathNumericType | MathCollection>(
4559
+ this: MathJsChain<T>,
4683
4560
  n?: number | BigNumber | MathCollection
4684
- ): MathJsChain<MathCollection>
4561
+ ): MathJsChain<T>
4685
4562
 
4686
4563
  /**
4687
4564
  * Round a value towards zero. For matrices, the function is evaluated
4688
4565
  * element wise.
4689
4566
  * @param n Number of decimals Default value: 0.
4690
4567
  */
4691
- fix(
4692
- this: MathJsChain<MathNumericType>,
4693
- n?: number | BigNumber | MathCollection
4694
- ): MathJsChain<MathNumericType>
4695
- fix(
4696
- this: MathJsChain<MathCollection>,
4568
+ fix<T extends MathNumericType | MathCollection>(
4569
+ this: MathJsChain<T>,
4697
4570
  n?: number | BigNumber | MathCollection
4698
- ): MathJsChain<MathCollection>
4571
+ ): MathJsChain<T>
4699
4572
 
4700
4573
  /**
4701
4574
  * Round a value towards minus infinity. For matrices, the function is
4702
4575
  * evaluated element wise.
4703
4576
  * @param n Number of decimals Default value: 0.
4704
4577
  */
4705
- floor(
4706
- this: MathJsChain<MathNumericType>,
4707
- n?: number | BigNumber | MathCollection
4708
- ): MathJsChain<MathNumericType>
4709
- floor(
4710
- this: MathJsChain<MathCollection>,
4578
+ floor<T extends MathNumericType | MathCollection>(
4579
+ this: MathJsChain<T>,
4711
4580
  n?: number | BigNumber | MathCollection
4712
- ): MathJsChain<MathCollection>
4581
+ ): MathJsChain<T>
4713
4582
 
4714
4583
  /**
4715
4584
  * Round a value towards the nearest integer. For matrices, the function
4716
4585
  * is evaluated element wise.
4717
4586
  * @param n Number of decimals Default value: 0.
4718
4587
  */
4719
- round(
4720
- this: MathJsChain<MathNumericType>,
4721
- n?: number | BigNumber | MathCollection
4722
- ): MathJsChain<MathNumericType>
4723
- round(
4724
- this: MathJsChain<MathCollection>,
4588
+ round<T extends MathNumericType | MathCollection>(
4589
+ this: MathJsChain<T>,
4725
4590
  n?: number | BigNumber | MathCollection
4726
- ): MathJsChain<MathCollection>
4591
+ ): MathJsChain<T>
4727
4592
 
4728
4593
  // End of rounding group
4729
4594
 
@@ -4731,11 +4596,7 @@ declare namespace math {
4731
4596
  * Compute the cube of a value, x * x * x. For matrices, the function is
4732
4597
  * evaluated element wise.
4733
4598
  */
4734
- cube(this: MathJsChain<number>): MathJsChain<number>
4735
- cube(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
4736
- cube(this: MathJsChain<Fraction>): MathJsChain<Fraction>
4737
- cube(this: MathJsChain<Complex>): MathJsChain<Complex>
4738
- cube(this: MathJsChain<Unit>): MathJsChain<Unit>
4599
+ cube<T extends MathNumericType | Unit>(this: MathJsChain<T>): MathJsChain<T>
4739
4600
 
4740
4601
  /**
4741
4602
  * Divide two values, x / y. To divide matrices, x is multiplied with
@@ -4800,33 +4661,26 @@ declare namespace math {
4800
4661
  * Calculate the exponent of a value. For matrices, the function is
4801
4662
  * evaluated element wise.
4802
4663
  */
4803
- exp(this: MathJsChain<number>): MathJsChain<number>
4804
- exp(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
4805
- exp(this: MathJsChain<Complex>): MathJsChain<Complex>
4664
+ exp<T extends number | BigNumber | Complex>(
4665
+ this: MathJsChain<T>
4666
+ ): MathJsChain<T>
4806
4667
 
4807
4668
  /**
4808
4669
  * Calculate the value of subtracting 1 from the exponential value. For
4809
4670
  * matrices, the function is evaluated element wise.
4810
4671
  */
4811
- expm1(this: MathJsChain<number>): MathJsChain<number>
4812
- expm1(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
4813
- expm1(this: MathJsChain<Complex>): MathJsChain<Complex>
4672
+ expm1<T extends number | BigNumber | Complex>(
4673
+ this: MathJsChain<T>
4674
+ ): MathJsChain<T>
4814
4675
 
4815
4676
  /**
4816
4677
  * Calculate the greatest common divisor for two or more values or
4817
4678
  * arrays. For matrices, the function is evaluated element wise.
4818
4679
  */
4819
- gcd(this: MathJsChain<number[]>, ...args: number[]): MathJsChain<number>
4820
- gcd(
4821
- this: MathJsChain<BigNumber[]>,
4822
- ...args: BigNumber[]
4823
- ): MathJsChain<BigNumber>
4824
- gcd(this: MathJsChain<Complex[]>, ...args: Fraction[]): MathJsChain<Complex>
4825
- gcd(
4826
- this: MathJsChain<MathArray[]>,
4827
- ...args: MathArray[]
4828
- ): MathJsChain<MathArray>
4829
- gcd(this: MathJsChain<Matrix[]>, ...args: Matrix[]): MathJsChain<Matrix>
4680
+ gcd<T extends number | BigNumber | Fraction | Matrix>(
4681
+ this: MathJsChain<T[]>,
4682
+ ...args: T[]
4683
+ ): MathJsChain<T>
4830
4684
 
4831
4685
  /**
4832
4686
  * Calculate the hypotenusa of a list with values. The hypotenusa is
@@ -4834,8 +4688,7 @@ declare namespace math {
4834
4688
  * matrix input, the hypotenusa is calculated for all values in the
4835
4689
  * matrix.
4836
4690
  */
4837
- hypot(this: MathJsChain<number[]>): MathJsChain<number>
4838
- hypot(this: MathJsChain<BigNumber[]>): MathJsChain<BigNumber>
4691
+ hypot<T extends number | BigNumber>(this: MathJsChain<T[]>): MathJsChain<T>
4839
4692
 
4840
4693
  /**
4841
4694
  * Calculate the least common multiple for two or more values or arrays.
@@ -4843,10 +4696,10 @@ declare namespace math {
4843
4696
  * the function is evaluated element wise.
4844
4697
  * @param b An integer number
4845
4698
  */
4846
- lcm(this: MathJsChain<number>, b: number): MathJsChain<number>
4847
- lcm(this: MathJsChain<BigNumber>, b: BigNumber): MathJsChain<BigNumber>
4848
- lcm(this: MathJsChain<MathArray>, b: MathArray): MathJsChain<MathArray>
4849
- lcm(this: MathJsChain<Matrix>, b: Matrix): MathJsChain<Matrix>
4699
+ lcm<T extends number | BigNumber | MathCollection>(
4700
+ this: MathJsChain<T>,
4701
+ b: T
4702
+ ): MathJsChain<T>
4850
4703
 
4851
4704
  /**
4852
4705
  * Calculate the logarithm of a value. For matrices, the function is
@@ -4864,11 +4717,9 @@ declare namespace math {
4864
4717
  * log(x, 10). For matrices, the function is evaluated element wise.
4865
4718
  */
4866
4719
 
4867
- log10(this: MathJsChain<number>): MathJsChain<number>
4868
- log10(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
4869
- log10(this: MathJsChain<Complex>): MathJsChain<Complex>
4870
- log10(this: MathJsChain<MathArray>): MathJsChain<MathArray>
4871
- log10(this: MathJsChain<Matrix>): MathJsChain<Matrix>
4720
+ log10<T extends number | BigNumber | Complex | MathCollection>(
4721
+ this: MathJsChain<T>
4722
+ ): MathJsChain<T>
4872
4723
 
4873
4724
  /**
4874
4725
  * Calculate the logarithm of a value+1. For matrices, the function is
@@ -4900,11 +4751,9 @@ declare namespace math {
4900
4751
  * log(x, 2). For matrices, the function is evaluated element wise.
4901
4752
  */
4902
4753
 
4903
- log2(this: MathJsChain<number>): MathJsChain<number>
4904
- log2(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
4905
- log2(this: MathJsChain<Complex>): MathJsChain<Complex>
4906
- log2(this: MathJsChain<MathArray>): MathJsChain<MathArray>
4907
- log2(this: MathJsChain<Matrix>): MathJsChain<Matrix>
4754
+ log2<T extends number | BigNumber | Complex | MathCollection>(
4755
+ this: MathJsChain<T>
4756
+ ): MathJsChain<T>
4908
4757
 
4909
4758
  /**
4910
4759
  * Calculates the modulus, the remainder of an integer division. For
@@ -4923,7 +4772,7 @@ declare namespace math {
4923
4772
  * matrix product is calculated.
4924
4773
  * @param y The second value to multiply
4925
4774
  */
4926
- multiply<T extends Matrix | MathArray>(
4775
+ multiply<T extends MathCollection>(
4927
4776
  this: MathJsChain<T>,
4928
4777
  y: MathType
4929
4778
  ): MathJsChain<T>
@@ -4971,38 +4820,23 @@ declare namespace math {
4971
4820
  * @param x The number for which to determine the sign
4972
4821
  * @returns The sign of x
4973
4822
  */
4974
- sign(this: MathJsChain<number>): MathJsChain<number>
4975
- sign(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
4976
- sign(this: MathJsChain<Fraction>): MathJsChain<Fraction>
4977
- sign(this: MathJsChain<Complex>): MathJsChain<Complex>
4978
- sign(this: MathJsChain<MathArray>): MathJsChain<MathArray>
4979
- sign(this: MathJsChain<Matrix>): MathJsChain<Matrix>
4980
- sign(this: MathJsChain<Unit>): MathJsChain<Unit>
4823
+ sign<T extends MathType>(this: MathJsChain<T>): MathJsChain<T>
4981
4824
 
4982
4825
  /**
4983
4826
  * Calculate the square root of a value. For matrices, the function is
4984
4827
  * evaluated element wise.
4985
4828
  */
4986
4829
 
4987
- sqrt(this: MathJsChain<number>): MathJsChain<number>
4988
- sqrt(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
4989
- sqrt(this: MathJsChain<Complex>): MathJsChain<Complex>
4990
- sqrt(this: MathJsChain<MathArray>): MathJsChain<MathArray>
4991
- sqrt(this: MathJsChain<Matrix>): MathJsChain<Matrix>
4992
- sqrt(this: MathJsChain<Unit>): MathJsChain<Unit>
4830
+ sqrt<T extends number | BigNumber | Complex | MathCollection | Unit>(
4831
+ this: MathJsChain<T>
4832
+ ): MathJsChain<T>
4993
4833
 
4994
4834
  /**
4995
4835
  * Compute the square of a value, x * x. For matrices, the function is
4996
4836
  * evaluated element wise.
4997
4837
  */
4998
4838
 
4999
- square(this: MathJsChain<number>): MathJsChain<number>
5000
- square(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
5001
- square(this: MathJsChain<Fraction>): MathJsChain<Fraction>
5002
- square(this: MathJsChain<Complex>): MathJsChain<Complex>
5003
- square(this: MathJsChain<MathArray>): MathJsChain<MathArray>
5004
- square(this: MathJsChain<Matrix>): MathJsChain<Matrix>
5005
- square(this: MathJsChain<Unit>): MathJsChain<Unit>
4839
+ square<T extends MathType>(this: MathJsChain<T>): MathJsChain<T>
5006
4840
 
5007
4841
  /**
5008
4842
  * Subtract two values, x - y. For matrices, the function is evaluated
@@ -5010,7 +4844,6 @@ declare namespace math {
5010
4844
  * @param y Value to subtract from x
5011
4845
  */
5012
4846
  subtract<T extends MathType>(this: MathJsChain<T>, y: T): MathJsChain<T>
5013
- subtract(this: MathJsChain<MathType>, y: MathType): MathJsChain<MathType>
5014
4847
 
5015
4848
  /**
5016
4849
  * Inverse the sign of a value, apply a unary minus operation. For
@@ -5019,13 +4852,7 @@ declare namespace math {
5019
4852
  * and complex value are inverted.
5020
4853
  */
5021
4854
 
5022
- unaryMinus(this: MathJsChain<number>): MathJsChain<number>
5023
- unaryMinus(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
5024
- unaryMinus(this: MathJsChain<Fraction>): MathJsChain<Fraction>
5025
- unaryMinus(this: MathJsChain<Complex>): MathJsChain<Complex>
5026
- unaryMinus(this: MathJsChain<MathArray>): MathJsChain<MathArray>
5027
- unaryMinus(this: MathJsChain<Matrix>): MathJsChain<Matrix>
5028
- unaryMinus(this: MathJsChain<Unit>): MathJsChain<Unit>
4855
+ unaryMinus<T extends MathType>(this: MathJsChain<T>): MathJsChain<T>
5029
4856
 
5030
4857
  /**
5031
4858
  * Unary plus operation. Boolean values and strings will be converted to
@@ -5033,14 +4860,7 @@ declare namespace math {
5033
4860
  * function is evaluated element wise.
5034
4861
  */
5035
4862
 
5036
- unaryPlus(this: MathJsChain<number>): MathJsChain<number>
5037
- unaryPlus(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
5038
- unaryPlus(this: MathJsChain<Fraction>): MathJsChain<Fraction>
5039
- unaryPlus(this: MathJsChain<string>): MathJsChain<string>
5040
- unaryPlus(this: MathJsChain<Complex>): MathJsChain<Complex>
5041
- unaryPlus(this: MathJsChain<MathArray>): MathJsChain<MathArray>
5042
- unaryPlus(this: MathJsChain<Matrix>): MathJsChain<Matrix>
5043
- unaryPlus(this: MathJsChain<Unit>): MathJsChain<Unit>
4863
+ unaryPlus<T extends string | MathType>(this: MathJsChain<T>): MathJsChain<T>
5044
4864
 
5045
4865
  /**
5046
4866
  * Calculate the extended greatest common divisor for two values. See
@@ -5087,10 +4907,9 @@ declare namespace math {
5087
4907
  * base.
5088
4908
  */
5089
4909
 
5090
- bitNot(this: MathJsChain<number>): MathJsChain<number>
5091
- bitNot(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
5092
- bitNot(this: MathJsChain<MathArray>): MathJsChain<MathArray>
5093
- bitNot(this: MathJsChain<Matrix>): MathJsChain<Matrix>
4910
+ bitNot<T extends number | BigNumber | MathCollection>(
4911
+ this: MathJsChain<T>
4912
+ ): MathJsChain<T>
5094
4913
 
5095
4914
  /**
5096
4915
  * Bitwise OR two values, x | y. For matrices, the function is evaluated
@@ -5098,10 +4917,10 @@ declare namespace math {
5098
4917
  * print base.
5099
4918
  * @param y Second value to or
5100
4919
  */
5101
- bitOr(this: MathJsChain<number>, y: number): MathJsChain<number>
5102
- bitOr(this: MathJsChain<BigNumber>, y: BigNumber): MathJsChain<BigNumber>
5103
- bitOr(this: MathJsChain<MathArray>, y: MathArray): MathJsChain<MathArray>
5104
- bitOr(this: MathJsChain<Matrix>, y: Matrix): MathJsChain<Matrix>
4920
+ bitOr<T extends number | BigNumber | MathCollection>(
4921
+ this: MathJsChain<T>,
4922
+ y: T
4923
+ ): MathJsChain<T>
5105
4924
 
5106
4925
  /**
5107
4926
  * Bitwise XOR two values, x ^ y. For matrices, the function is
@@ -5342,7 +5161,7 @@ declare namespace math {
5342
5161
  cross(
5343
5162
  this: MathJsChain<MathCollection>,
5344
5163
  y: MathCollection
5345
- ): MathJsChain<Matrix | MathArray>
5164
+ ): MathJsChain<MathCollection>
5346
5165
 
5347
5166
  /**
5348
5167
  * Calculate the determinant of a matrix.
@@ -5369,7 +5188,7 @@ declare namespace math {
5369
5188
  this: MathJsChain<MathCollection>,
5370
5189
  k: number | BigNumber,
5371
5190
  format?: string
5372
- ): MathJsChain<Matrix | MathArray>
5191
+ ): MathJsChain<MathCollection>
5373
5192
 
5374
5193
  /**
5375
5194
  * Calculate the dot product of two vectors. The dot product of A = [a1,
@@ -5398,7 +5217,7 @@ declare namespace math {
5398
5217
  * https://en.wikipedia.org/wiki/Schur_decomposition
5399
5218
  * @returns Object containing both matrix U and T of the Schur Decomposition A=UTU'
5400
5219
  */
5401
- schur(this: MathJsChain<Matrix | MathArray>): SchurDecomposition
5220
+ schur(this: MathJsChain<MathCollection>): SchurDecomposition
5402
5221
 
5403
5222
  /**
5404
5223
  * Solves the Continuous-time Lyapunov equation AP+PA'=Q for P, where Q is a positive semidefinite
@@ -5408,9 +5227,9 @@ declare namespace math {
5408
5227
  * @returns Matrix P solution to the Continuous-time Lyapunov equation AP+PA'=Q
5409
5228
  */
5410
5229
  lyap(
5411
- this: MathJsChain<Matrix | MathArray>,
5412
- Q: Matrix | MathArray
5413
- ): MathJsChain<Matrix | MathArray>
5230
+ this: MathJsChain<MathCollection>,
5231
+ Q: MathCollection
5232
+ ): MathJsChain<MathCollection>
5414
5233
 
5415
5234
  /**
5416
5235
  * Create a 2-dimensional identity matrix with size m x n or n x n. The
@@ -5418,9 +5237,9 @@ declare namespace math {
5418
5237
  * @param format The Matrix storage format
5419
5238
  */
5420
5239
  identity(
5421
- this: MathJsChain<number | number[] | Matrix | MathArray>,
5240
+ this: MathJsChain<number | number[] | MathCollection>,
5422
5241
  format?: string
5423
- ): MathJsChain<Matrix | MathArray | number>
5242
+ ): MathJsChain<MathCollection | number>
5424
5243
 
5425
5244
  /**
5426
5245
  * @param n The y dimension for the matrix
@@ -5430,23 +5249,23 @@ declare namespace math {
5430
5249
  this: MathJsChain<number>,
5431
5250
  n: number,
5432
5251
  format?: string
5433
- ): MathJsChain<Matrix | MathArray | number>
5252
+ ): MathJsChain<MathCollection | number>
5434
5253
 
5435
5254
  /**
5436
5255
  * Filter the items in an array or one dimensional matrix.
5437
5256
  */
5438
5257
  filter(
5439
- this: MathJsChain<Matrix | MathArray | string[]>,
5258
+ this: MathJsChain<MathCollection | string[]>,
5440
5259
  test:
5441
5260
  | ((
5442
5261
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5443
5262
  value: any,
5444
5263
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5445
5264
  index: any,
5446
- matrix: Matrix | MathArray | string[]
5265
+ matrix: MathCollection | string[]
5447
5266
  ) => boolean)
5448
5267
  | RegExp
5449
- ): MathJsChain<Matrix | MathArray>
5268
+ ): MathJsChain<MathCollection>
5450
5269
 
5451
5270
  /**
5452
5271
  * Flatten a multi dimensional matrix into a single dimensional matrix.
@@ -5458,7 +5277,7 @@ declare namespace math {
5458
5277
  * Iterate over all elements of a matrix/array, and executes the given
5459
5278
  * callback function.
5460
5279
  */
5461
- forEach<T extends Matrix | MathArray>(
5280
+ forEach<T extends MathCollection>(
5462
5281
  this: MathJsChain<T>,
5463
5282
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5464
5283
  callback: (value: any, index: any, matrix: T) => void
@@ -5477,8 +5296,8 @@ declare namespace math {
5477
5296
  * @param y Second vector
5478
5297
  */
5479
5298
  kron(
5480
- this: MathJsChain<Matrix | MathArray>,
5481
- y: Matrix | MathArray
5299
+ this: MathJsChain<MathCollection>,
5300
+ y: MathCollection
5482
5301
  ): MathJsChain<Matrix>
5483
5302
 
5484
5303
  /**
@@ -5488,7 +5307,7 @@ declare namespace math {
5488
5307
  * parameters: the value of the element, the index of the element, and
5489
5308
  * the Matrix/array being traversed.
5490
5309
  */
5491
- map<T extends Matrix | MathArray>(
5310
+ map<T extends MathCollection>(
5492
5311
  this: MathJsChain<T>,
5493
5312
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5494
5313
  callback: (value: any, index: any, matrix: T) => MathType | string
@@ -5578,7 +5397,7 @@ declare namespace math {
5578
5397
  * is called as compare(a, b), and must return 1 when a > b, -1 when a <
5579
5398
  * b, and 0 when a == b. Default value: ‘asc’
5580
5399
  */
5581
- sort<T extends Matrix | MathArray>(
5400
+ sort<T extends MathCollection>(
5582
5401
  this: MathJsChain<T>,
5583
5402
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5584
5403
  compare: ((a: any, b: any) => number) | 'asc' | 'desc' | 'natural'
@@ -5803,12 +5622,7 @@ declare namespace math {
5803
5622
  * accepts both matrices and scalar values.
5804
5623
  * @param y Second amtrix to compare
5805
5624
  */
5806
- deepEqual(
5807
- this: MathJsChain<MathType>,
5808
- y: MathType
5809
- ): MathJsChain<
5810
- number | BigNumber | Fraction | Complex | Unit | MathCollection
5811
- >
5625
+ deepEqual(this: MathJsChain<MathType>, y: MathType): MathJsChain<MathType>
5812
5626
 
5813
5627
  /**
5814
5628
  * Test whether two values are equal.
@@ -5966,7 +5780,7 @@ declare namespace math {
5966
5780
  * @param a A multiset
5967
5781
  */
5968
5782
  setMultiplicity(
5969
- e: MathJsChain<number | BigNumber | Fraction | Complex>,
5783
+ e: MathJsChain<MathNumericType>,
5970
5784
  a: MathCollection
5971
5785
  ): MathJsChain<number>
5972
5786
 
@@ -6268,11 +6082,9 @@ declare namespace math {
6268
6082
  * is evaluated element wise.
6269
6083
  */
6270
6084
 
6271
- acos(this: MathJsChain<number>): MathJsChain<number>
6272
- acos(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6273
- acos(this: MathJsChain<Complex>): MathJsChain<Complex>
6274
- acos(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6275
- acos(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6085
+ acos<T extends number | BigNumber | Complex | MathCollection>(
6086
+ this: MathJsChain<T>
6087
+ ): MathJsChain<T>
6276
6088
 
6277
6089
  /**
6278
6090
  * Calculate the hyperbolic arccos of a value, defined as acosh(x) =
@@ -6280,21 +6092,18 @@ declare namespace math {
6280
6092
  * element wise.
6281
6093
  */
6282
6094
 
6283
- acosh(this: MathJsChain<number>): MathJsChain<number>
6284
- acosh(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6285
- acosh(this: MathJsChain<Complex>): MathJsChain<Complex>
6286
- acosh(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6287
- acosh(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6095
+ acosh<T extends number | BigNumber | Complex | MathCollection>(
6096
+ this: MathJsChain<T>
6097
+ ): MathJsChain<T>
6288
6098
 
6289
6099
  /**
6290
6100
  * Calculate the inverse cotangent of a value. For matrices, the
6291
6101
  * function is evaluated element wise.
6292
6102
  */
6293
6103
 
6294
- acot(this: MathJsChain<number>): MathJsChain<number>
6295
- acot(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6296
- acot(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6297
- acot(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6104
+ acot<T extends number | BigNumber | Complex | MathCollection>(
6105
+ this: MathJsChain<T>
6106
+ ): MathJsChain<T>
6298
6107
 
6299
6108
  /**
6300
6109
  * Calculate the hyperbolic arccotangent of a value, defined as acoth(x)
@@ -6302,20 +6111,18 @@ declare namespace math {
6302
6111
  * evaluated element wise.
6303
6112
  */
6304
6113
 
6305
- acoth(this: MathJsChain<number>): MathJsChain<number>
6306
- acoth(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6307
- acoth(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6308
- acoth(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6114
+ acoth<T extends number | BigNumber | Complex | MathCollection>(
6115
+ this: MathJsChain<T>
6116
+ ): MathJsChain<T>
6309
6117
 
6310
6118
  /**
6311
6119
  * Calculate the inverse cosecant of a value. For matrices, the function
6312
6120
  * is evaluated element wise.
6313
6121
  */
6314
6122
 
6315
- acsc(this: MathJsChain<number>): MathJsChain<number>
6316
- acsc(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6317
- acsc(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6318
- acsc(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6123
+ acsc<T extends number | BigNumber | Complex | MathCollection>(
6124
+ this: MathJsChain<T>
6125
+ ): MathJsChain<T>
6319
6126
 
6320
6127
  /**
6321
6128
  * Calculate the hyperbolic arccosecant of a value, defined as acsch(x)
@@ -6323,20 +6130,18 @@ declare namespace math {
6323
6130
  * element wise.
6324
6131
  */
6325
6132
 
6326
- acsch(this: MathJsChain<number>): MathJsChain<number>
6327
- acsch(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6328
- acsch(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6329
- acsch(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6133
+ acsch<T extends number | BigNumber | Complex | MathCollection>(
6134
+ this: MathJsChain<T>
6135
+ ): MathJsChain<T>
6330
6136
 
6331
6137
  /**
6332
6138
  * Calculate the inverse secant of a value. For matrices, the function
6333
6139
  * is evaluated element wise.
6334
6140
  */
6335
6141
 
6336
- asec(this: MathJsChain<number>): MathJsChain<number>
6337
- asec(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6338
- asec(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6339
- asec(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6142
+ asec<T extends number | BigNumber | Complex | MathCollection>(
6143
+ this: MathJsChain<T>
6144
+ ): MathJsChain<T>
6340
6145
 
6341
6146
  /**
6342
6147
  * Calculate the hyperbolic arcsecant of a value, defined as asech(x) =
@@ -6344,21 +6149,18 @@ declare namespace math {
6344
6149
  * element wise.
6345
6150
  */
6346
6151
 
6347
- asech(this: MathJsChain<number>): MathJsChain<number>
6348
- asech(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6349
- asech(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6350
- asech(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6152
+ asech<T extends number | BigNumber | Complex | MathCollection>(
6153
+ this: MathJsChain<T>
6154
+ ): MathJsChain<T>
6351
6155
 
6352
6156
  /**
6353
6157
  * Calculate the inverse sine of a value. For matrices, the function is
6354
6158
  * evaluated element wise.
6355
6159
  */
6356
6160
 
6357
- asin(this: MathJsChain<number>): MathJsChain<number>
6358
- asin(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6359
- asin(this: MathJsChain<Complex>): MathJsChain<Complex>
6360
- asin(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6361
- asin(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6161
+ asin<T extends number | BigNumber | Complex | MathCollection>(
6162
+ this: MathJsChain<T>
6163
+ ): MathJsChain<T>
6362
6164
 
6363
6165
  /**
6364
6166
  * Calculate the hyperbolic arcsine of a value, defined as asinh(x) =
@@ -6366,20 +6168,18 @@ declare namespace math {
6366
6168
  * element wise.
6367
6169
  */
6368
6170
 
6369
- asinh(this: MathJsChain<number>): MathJsChain<number>
6370
- asinh(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6371
- asinh(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6372
- asinh(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6171
+ asinh<T extends number | BigNumber | Complex | MathCollection>(
6172
+ this: MathJsChain<T>
6173
+ ): MathJsChain<T>
6373
6174
 
6374
6175
  /**
6375
6176
  * Calculate the inverse tangent of a value. For matrices, the function
6376
6177
  * is evaluated element wise.
6377
6178
  */
6378
6179
 
6379
- atan(this: MathJsChain<number>): MathJsChain<number>
6380
- atan(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6381
- atan(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6382
- atan(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6180
+ atan<T extends number | BigNumber | Complex | MathCollection>(
6181
+ this: MathJsChain<T>
6182
+ ): MathJsChain<T>
6383
6183
 
6384
6184
  /**
6385
6185
  * Calculate the inverse tangent function with two arguments, y/x. By
@@ -6387,11 +6187,10 @@ declare namespace math {
6387
6187
  * be determined. For matrices, the function is evaluated element wise.
6388
6188
  */
6389
6189
 
6390
- atan2(this: MathJsChain<number>, x: number): MathJsChain<number>
6391
- atan2(
6392
- this: MathJsChain<MathCollection>,
6393
- x: MathCollection
6394
- ): MathJsChain<MathCollection>
6190
+ atan2<T extends number | BigNumber | Complex | MathCollection>(
6191
+ this: MathJsChain<T>,
6192
+ x: number
6193
+ ): MathJsChain<T>
6395
6194
 
6396
6195
  /**
6397
6196
  * Calculate the hyperbolic arctangent of a value, defined as atanh(x) =
@@ -6399,21 +6198,18 @@ declare namespace math {
6399
6198
  * element wise.
6400
6199
  */
6401
6200
 
6402
- atanh(this: MathJsChain<number>): MathJsChain<number>
6403
- atanh(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6404
- atanh(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6405
- atanh(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6201
+ atanh<T extends number | BigNumber | Complex | MathCollection>(
6202
+ this: MathJsChain<T>
6203
+ ): MathJsChain<T>
6406
6204
 
6407
6205
  /**
6408
6206
  * Calculate the cosine of a value. For matrices, the function is
6409
6207
  * evaluated element wise.
6410
6208
  */
6411
6209
 
6412
- cos(this: MathJsChain<number | Unit>): MathJsChain<number>
6413
- cos(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6414
- cos(this: MathJsChain<Complex>): MathJsChain<Complex>
6415
- cos(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6416
- cos(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6210
+ cos<T extends number | BigNumber | Complex | MathCollection>(
6211
+ this: MathJsChain<T>
6212
+ ): MathJsChain<T>
6417
6213
 
6418
6214
  /**
6419
6215
  * Calculate the hyperbolic cosine of a value, defined as cosh(x) = 1/2
@@ -6421,82 +6217,72 @@ declare namespace math {
6421
6217
  * wise.
6422
6218
  */
6423
6219
 
6424
- cosh(this: MathJsChain<number | Unit>): MathJsChain<number>
6425
- cosh(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6426
- cosh(this: MathJsChain<Complex>): MathJsChain<Complex>
6427
- cosh(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6428
- cosh(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6220
+ cosh<T extends number | BigNumber | Complex | MathCollection>(
6221
+ this: MathJsChain<T>
6222
+ ): MathJsChain<T>
6429
6223
 
6430
6224
  /**
6431
6225
  * Calculate the cotangent of a value. cot(x) is defined as 1 / tan(x).
6432
6226
  * For matrices, the function is evaluated element wise.
6433
6227
  */
6434
6228
 
6435
- cot(this: MathJsChain<number | Unit>): MathJsChain<number>
6436
- cot(this: MathJsChain<Complex>): MathJsChain<Complex>
6437
- cot(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6438
- cot(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6229
+ cot<T extends number | BigNumber | Complex | MathCollection>(
6230
+ this: MathJsChain<T>
6231
+ ): MathJsChain<T>
6439
6232
 
6440
6233
  /**
6441
6234
  * Calculate the hyperbolic cotangent of a value, defined as coth(x) = 1
6442
6235
  * / tanh(x). For matrices, the function is evaluated element wise.
6443
6236
  */
6444
6237
 
6445
- coth(this: MathJsChain<number | Unit>): MathJsChain<number>
6446
- coth(this: MathJsChain<Complex>): MathJsChain<Complex>
6447
- coth(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6448
- coth(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6238
+ coth<T extends number | BigNumber | Complex | MathCollection>(
6239
+ this: MathJsChain<T>
6240
+ ): MathJsChain<T>
6449
6241
 
6450
6242
  /**
6451
6243
  * Calculate the cosecant of a value, defined as csc(x) = 1/sin(x). For
6452
6244
  * matrices, the function is evaluated element wise.
6453
6245
  */
6454
6246
 
6455
- csc(this: MathJsChain<number | Unit>): MathJsChain<number>
6456
- csc(this: MathJsChain<Complex>): MathJsChain<Complex>
6457
- csc(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6458
- csc(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6247
+ csc<T extends number | BigNumber | Complex | MathCollection>(
6248
+ this: MathJsChain<T>
6249
+ ): MathJsChain<T>
6459
6250
 
6460
6251
  /**
6461
6252
  * Calculate the hyperbolic cosecant of a value, defined as csch(x) = 1
6462
6253
  * / sinh(x). For matrices, the function is evaluated element wise.
6463
6254
  */
6464
6255
 
6465
- csch(this: MathJsChain<number | Unit>): MathJsChain<number>
6466
- csch(this: MathJsChain<Complex>): MathJsChain<Complex>
6467
- csch(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6468
- csch(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6256
+ csch<T extends number | BigNumber | Complex | MathCollection>(
6257
+ this: MathJsChain<T>
6258
+ ): MathJsChain<T>
6469
6259
 
6470
6260
  /**
6471
6261
  * Calculate the secant of a value, defined as sec(x) = 1/cos(x). For
6472
6262
  * matrices, the function is evaluated element wise.
6473
6263
  */
6474
6264
 
6475
- sec(this: MathJsChain<number | Unit>): MathJsChain<number>
6476
- sec(this: MathJsChain<Complex>): MathJsChain<Complex>
6477
- sec(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6478
- sec(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6265
+ sec<T extends number | BigNumber | Complex | MathCollection>(
6266
+ this: MathJsChain<T>
6267
+ ): MathJsChain<T>
6479
6268
 
6480
6269
  /**
6481
6270
  * Calculate the hyperbolic secant of a value, defined as sech(x) = 1 /
6482
6271
  * cosh(x). For matrices, the function is evaluated element wise.
6483
6272
  */
6484
6273
 
6485
- sech(this: MathJsChain<number | Unit>): MathJsChain<number>
6486
- sech(this: MathJsChain<Complex>): MathJsChain<Complex>
6487
- sech(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6488
- sech(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6274
+ sech<T extends number | BigNumber | Complex | MathCollection>(
6275
+ this: MathJsChain<T>
6276
+ ): MathJsChain<T>
6489
6277
 
6490
6278
  /**
6491
6279
  * Calculate the sine of a value. For matrices, the function is
6492
6280
  * evaluated element wise.
6493
6281
  */
6494
6282
 
6495
- sin(this: MathJsChain<number | Unit>): MathJsChain<number>
6496
- sin(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6497
- sin(this: MathJsChain<Complex>): MathJsChain<Complex>
6498
- sin(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6499
- sin(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6283
+ sin<T extends number | BigNumber | Complex | MathCollection>(
6284
+ this: MathJsChain<T>
6285
+ ): MathJsChain<T>
6500
6286
 
6501
6287
  /**
6502
6288
  * Calculate the hyperbolic sine of a value, defined as sinh(x) = 1/2 *
@@ -6504,22 +6290,18 @@ declare namespace math {
6504
6290
  * wise.
6505
6291
  */
6506
6292
 
6507
- sinh(this: MathJsChain<number | Unit>): MathJsChain<number>
6508
- sinh(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6509
- sinh(this: MathJsChain<Complex>): MathJsChain<Complex>
6510
- sinh(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6511
- sinh(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6293
+ sinh<T extends number | BigNumber | Complex | MathCollection>(
6294
+ this: MathJsChain<T>
6295
+ ): MathJsChain<T>
6512
6296
 
6513
6297
  /**
6514
6298
  * Calculate the tangent of a value. tan(x) is equal to sin(x) / cos(x).
6515
6299
  * For matrices, the function is evaluated element wise.
6516
6300
  */
6517
6301
 
6518
- tan(this: MathJsChain<number | Unit>): MathJsChain<number>
6519
- tan(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6520
- tan(this: MathJsChain<Complex>): MathJsChain<Complex>
6521
- tan(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6522
- tan(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6302
+ tan<T extends number | BigNumber | Complex | MathCollection>(
6303
+ this: MathJsChain<T>
6304
+ ): MathJsChain<T>
6523
6305
 
6524
6306
  /**
6525
6307
  * Calculate the hyperbolic tangent of a value, defined as tanh(x) =
@@ -6527,11 +6309,9 @@ declare namespace math {
6527
6309
  * evaluated element wise.
6528
6310
  */
6529
6311
 
6530
- tanh(this: MathJsChain<number | Unit>): MathJsChain<number>
6531
- tanh(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
6532
- tanh(this: MathJsChain<Complex>): MathJsChain<Complex>
6533
- tanh(this: MathJsChain<MathArray>): MathJsChain<MathArray>
6534
- tanh(this: MathJsChain<Matrix>): MathJsChain<Matrix>
6312
+ tanh<T extends number | BigNumber | Complex | MathCollection>(
6313
+ this: MathJsChain<T>
6314
+ ): MathJsChain<T>
6535
6315
 
6536
6316
  /*************************************************************************
6537
6317
  * Unit functions
@@ -6623,11 +6403,7 @@ declare namespace math {
6623
6403
  * evaluated element-wise in case of Array or Matrix input.
6624
6404
  */
6625
6405
 
6626
- isZero(
6627
- this: MathJsChain<
6628
- number | BigNumber | Fraction | MathCollection | Unit | Complex
6629
- >
6630
- ): MathJsChain<boolean>
6406
+ isZero(this: MathJsChain<MathType>): MathJsChain<boolean>
6631
6407
 
6632
6408
  /**
6633
6409
  * Determine the type of a variable.