mathjs 11.6.0 → 11.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. package/HISTORY.md +13 -0
  2. package/lib/browser/math.js +1 -1
  3. package/lib/browser/math.js.LICENSE.txt +2 -2
  4. package/lib/browser/math.js.map +1 -1
  5. package/lib/cjs/expression/embeddedDocs/function/matrix/partitionSelect.js +1 -1
  6. package/lib/cjs/function/arithmetic/expm1.js +1 -1
  7. package/lib/cjs/function/arithmetic/gcd.js +35 -12
  8. package/lib/cjs/function/arithmetic/nthRoots.js +2 -1
  9. package/lib/cjs/function/arithmetic/round.js +1 -1
  10. package/lib/cjs/function/arithmetic/sign.js +1 -1
  11. package/lib/cjs/function/bitwise/rightArithShift.js +1 -1
  12. package/lib/cjs/function/matrix/det.js +7 -1
  13. package/lib/cjs/function/matrix/diff.js +3 -3
  14. package/lib/cjs/function/matrix/partitionSelect.js +7 -2
  15. package/lib/cjs/function/set/setIsSubset.js +1 -1
  16. package/lib/cjs/function/set/setSize.js +3 -2
  17. package/lib/cjs/header.js +2 -2
  18. package/lib/cjs/version.js +1 -1
  19. package/lib/esm/expression/embeddedDocs/function/matrix/partitionSelect.js +1 -1
  20. package/lib/esm/function/arithmetic/expm1.js +1 -1
  21. package/lib/esm/function/arithmetic/gcd.js +27 -10
  22. package/lib/esm/function/arithmetic/nthRoots.js +2 -1
  23. package/lib/esm/function/arithmetic/round.js +1 -1
  24. package/lib/esm/function/arithmetic/sign.js +1 -1
  25. package/lib/esm/function/bitwise/rightArithShift.js +1 -1
  26. package/lib/esm/function/matrix/det.js +7 -1
  27. package/lib/esm/function/matrix/diff.js +3 -3
  28. package/lib/esm/function/matrix/partitionSelect.js +7 -2
  29. package/lib/esm/function/set/setIsSubset.js +1 -1
  30. package/lib/esm/function/set/setSize.js +3 -2
  31. package/lib/esm/version.js +1 -1
  32. package/package.json +9 -9
  33. package/types/index.d.ts +245 -469
package/types/index.d.ts CHANGED
@@ -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,9 @@ 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
1210
1192
 
1211
1193
  /**
1212
1194
  * Calculate the hypotenusa of a list with values. The hypotenusa is
@@ -1218,8 +1200,7 @@ declare namespace math {
1218
1200
  * whole matrix.
1219
1201
  * @returns Returns the hypothenuse of the input values.
1220
1202
  */
1221
- hypot(...args: number[]): number
1222
- hypot(...args: BigNumber[]): BigNumber
1203
+ hypot<T extends (number | BigNumber)[]>(...args: T[]): T
1223
1204
 
1224
1205
  /**
1225
1206
  * Calculate the least common multiple for two or more values or arrays.
@@ -1229,10 +1210,7 @@ declare namespace math {
1229
1210
  * @param b An integer number
1230
1211
  * @returns The least common multiple
1231
1212
  */
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
1213
+ lcm<T extends number | BigNumber | MathCollection>(a: T, b: T): T
1236
1214
 
1237
1215
  /**
1238
1216
  * Calculate the logarithm of a value.
@@ -1252,11 +1230,7 @@ declare namespace math {
1252
1230
  * @param x Value for which to calculate the logarithm.
1253
1231
  * @returns Returns the 10-base logarithm of x
1254
1232
  */
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
1233
+ log10<T extends number | BigNumber | Complex | MathCollection>(x: T): T
1260
1234
 
1261
1235
  /**
1262
1236
  * Calculate the logarithm of a value+1. For matrices, the function is
@@ -1264,11 +1238,10 @@ declare namespace math {
1264
1238
  * @param x Value for which to calculate the logarithm.
1265
1239
  * @returns Returns the logarithm of x+1
1266
1240
  */
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
1241
+ log1p<T extends number | BigNumber | Complex | MathCollection>(
1242
+ x: T,
1243
+ base?: number | BigNumber | Complex
1244
+ ): T
1272
1245
 
1273
1246
  /**
1274
1247
  * Calculate the 2-base of a value. This is the same as calculating
@@ -1276,11 +1249,7 @@ declare namespace math {
1276
1249
  * @param x Value for which to calculate the logarithm.
1277
1250
  * @returns Returns the 2-base logarithm of x
1278
1251
  */
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
1252
+ log2<T extends number | BigNumber | Complex | MathCollection>(x: T): T
1284
1253
 
1285
1254
  /**
1286
1255
  * Calculates the modulus, the remainder of an integer division. For
@@ -1309,9 +1278,7 @@ declare namespace math {
1309
1278
 
1310
1279
  multiply<T extends MathNumericType[]>(x: T, y: T[]): T
1311
1280
  multiply<T extends MathNumericType[]>(x: T[], y: T): T
1312
-
1313
1281
  multiply<T extends MathArray>(x: T, y: T): T
1314
-
1315
1282
  multiply(x: Unit, y: Unit): Unit
1316
1283
  multiply(x: number, y: number): number
1317
1284
  multiply(x: MathType, y: MathType): MathType
@@ -1359,13 +1326,7 @@ declare namespace math {
1359
1326
  * @param x The number for which to determine the sign
1360
1327
  * @returns The sign of x
1361
1328
  */
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
1329
+ sign<T extends MathType>(x: T): T
1369
1330
 
1370
1331
  /**
1371
1332
  * Calculate the square root of a value. For matrices, use either
@@ -1375,20 +1336,14 @@ declare namespace math {
1375
1336
  * @returns Returns the square root of x
1376
1337
  */
1377
1338
  sqrt(x: number): number | Complex
1378
- sqrt(x: BigNumber): BigNumber
1379
- sqrt(x: Complex): Complex
1380
- sqrt(x: Unit): Unit
1339
+ sqrt<T extends BigNumber | Complex | Unit>(x: T): T
1381
1340
 
1382
1341
  /**
1383
1342
  * Compute the square of a value, x * x.
1384
1343
  * @param x Number for which to calculate the square
1385
1344
  * @returns Squared value
1386
1345
  */
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
1346
+ square<T extends MathNumericType | Unit>(x: T): T
1392
1347
 
1393
1348
  /**
1394
1349
  * Subtract two values, x - y. For matrices, the function is evaluated
@@ -1408,13 +1363,7 @@ declare namespace math {
1408
1363
  * @param x Number to be inverted
1409
1364
  * @returns Retursn the value with inverted sign
1410
1365
  */
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
1366
+ unaryMinus<T extends MathType>(x: T): T
1418
1367
 
1419
1368
  /**
1420
1369
  * Unary plus operation. Boolean values and strings will be converted to
@@ -1424,14 +1373,7 @@ declare namespace math {
1424
1373
  * @returns Returns the input value when numeric, converts to a number
1425
1374
  * when input is non-numeric.
1426
1375
  */
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
1376
+ unaryPlus<T extends string | MathType>(x: T): T
1435
1377
 
1436
1378
  /**
1437
1379
  * Calculate the extended greatest common divisor for two values. See
@@ -1466,10 +1408,7 @@ declare namespace math {
1466
1408
  * @param x Value to not
1467
1409
  * @returns NOT of x
1468
1410
  */
1469
- bitNot(x: number): number
1470
- bitNot(x: BigNumber): BigNumber
1471
- bitNot(x: MathArray): MathArray
1472
- bitNot(x: Matrix): Matrix
1411
+ bitNot<T extends number | BigNumber | MathCollection>(x: T): T
1473
1412
 
1474
1413
  /**
1475
1414
  * Bitwise OR two values, x | y. For matrices, the function is evaluated
@@ -1479,10 +1418,7 @@ declare namespace math {
1479
1418
  * @param y Second value to or
1480
1419
  * @returns OR of x and y
1481
1420
  */
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
1421
+ bitOr<T extends number | BigNumber | MathCollection>(x: T, y: T): T
1486
1422
 
1487
1423
  /**
1488
1424
  * Bitwise XOR two values, x ^ y. For matrices, the function is
@@ -1547,8 +1483,7 @@ declare namespace math {
1547
1483
  * @param n Total number of objects in the set
1548
1484
  * @returns B(n)
1549
1485
  */
1550
- bellNumbers(n: number): number
1551
- bellNumbers(n: BigNumber): BigNumber
1486
+ bellNumbers<T extends number | BigNumber>(n: T): T
1552
1487
 
1553
1488
  /**
1554
1489
  * The Catalan Numbers enumerate combinatorial structures of many
@@ -1557,8 +1492,7 @@ declare namespace math {
1557
1492
  * @param n nth Catalan number
1558
1493
  * @returns Cn(n)
1559
1494
  */
1560
- catalan(n: number): number
1561
- catalan(n: BigNumber): BigNumber
1495
+ catalan<T extends number | BigNumber>(n: T): T
1562
1496
 
1563
1497
  /**
1564
1498
  * The composition counts of n into k parts. Composition only takes
@@ -1600,8 +1534,7 @@ declare namespace math {
1600
1534
  */
1601
1535
  arg(x: number | Complex): number
1602
1536
  arg(x: BigNumber | Complex): BigNumber
1603
- arg(x: MathArray): MathArray
1604
- arg(x: Matrix): Matrix
1537
+ arg<T extends MathCollection>(x: T): T
1605
1538
 
1606
1539
  /**
1607
1540
  * Compute the complex conjugate of a complex value. If x = a+bi, the
@@ -1622,8 +1555,7 @@ declare namespace math {
1622
1555
  * @returns The imaginary part of x
1623
1556
  */
1624
1557
  im(x: MathJsChain<number | Complex>): MathJsChain<number>
1625
- im(x: MathJsChain<BigNumber>): MathJsChain<BigNumber>
1626
- im(x: MathJsChain<MathCollection>): MathJsChain<MathCollection>
1558
+ im<T extends BigNumber | MathCollection>(x: MathJsChain<T>): MathJsChain<T>
1627
1559
 
1628
1560
  /**
1629
1561
  * Get the real part of a complex number. For a complex number a + bi,
@@ -1633,8 +1565,7 @@ declare namespace math {
1633
1565
  * @returns The real part of x
1634
1566
  */
1635
1567
  re(x: MathJsChain<number | Complex>): MathJsChain<number>
1636
- re(x: MathJsChain<BigNumber>): MathJsChain<BigNumber>
1637
- re(x: MathJsChain<MathCollection>): MathJsChain<MathCollection>
1568
+ re<T extends BigNumber | MathCollection>(x: MathJsChain<T>): MathJsChain<T>
1638
1569
 
1639
1570
  /*************************************************************************
1640
1571
  * Geometry functions
@@ -1773,7 +1704,7 @@ declare namespace math {
1773
1704
  * @param y Second vector
1774
1705
  * @returns Returns the cross product of x and y
1775
1706
  */
1776
- cross(x: MathCollection, y: MathCollection): Matrix | MathArray
1707
+ cross(x: MathCollection, y: MathCollection): MathCollection
1777
1708
 
1778
1709
  /**
1779
1710
  * Calculate the determinant of a matrix.
@@ -1801,7 +1732,7 @@ declare namespace math {
1801
1732
  X: MathCollection,
1802
1733
  k: number | BigNumber,
1803
1734
  format?: string
1804
- ): Matrix | MathArray
1735
+ ): MathCollection
1805
1736
 
1806
1737
  /**
1807
1738
  * Calculate the dot product of two vectors. The dot product of A = [a1,
@@ -1853,10 +1784,10 @@ declare namespace math {
1853
1784
  * @returns Matrix X, solving the Sylvester equation
1854
1785
  */
1855
1786
  sylvester(
1856
- A: Matrix | MathArray,
1857
- B: Matrix | MathArray,
1858
- C: Matrix | MathArray
1859
- ): Matrix | MathArray
1787
+ A: MathCollection,
1788
+ B: MathCollection,
1789
+ C: MathCollection
1790
+ ): MathCollection
1860
1791
 
1861
1792
  /**
1862
1793
  * Performs a real Schur decomposition of the real matrix A = UTU' where U is orthogonal
@@ -1865,7 +1796,7 @@ declare namespace math {
1865
1796
  * @param A Matrix A
1866
1797
  * @returns Object containing both matrix U and T of the Schur Decomposition A=UTU'
1867
1798
  */
1868
- schur(A: Matrix | MathArray): SchurDecomposition
1799
+ schur(A: MathCollection): SchurDecomposition
1869
1800
 
1870
1801
  /**
1871
1802
  * Solves the Continuous-time Lyapunov equation AP+PA'=Q for P, where Q is a positive semidefinite
@@ -1875,7 +1806,7 @@ declare namespace math {
1875
1806
  * @param Q Matrix Q
1876
1807
  * @returns Matrix P solution to the Continuous-time Lyapunov equation AP+PA'=Q
1877
1808
  */
1878
- lyap(A: Matrix | MathArray, Q: Matrix | MathArray): Matrix | MathArray
1809
+ lyap(A: MathCollection, Q: MathCollection): MathCollection
1879
1810
 
1880
1811
  /**
1881
1812
  * Create a 2-dimensional identity matrix with size m x n or n x n. The
@@ -1885,16 +1816,16 @@ declare namespace math {
1885
1816
  * @returns A matrix with ones on the diagonal
1886
1817
  */
1887
1818
  identity(
1888
- size: number | number[] | Matrix | MathArray,
1819
+ size: number | number[] | MathCollection,
1889
1820
  format?: string
1890
- ): Matrix | MathArray | number
1821
+ ): MathCollection | number
1891
1822
  /**
1892
1823
  * @param m The x dimension for the matrix
1893
1824
  * @param n The y dimension for the matrix
1894
1825
  * @param format The Matrix storage format
1895
1826
  * @returns A matrix with ones on the diagonal
1896
1827
  */
1897
- identity(m: number, n: number, format?: string): Matrix | MathArray | number
1828
+ identity(m: number, n: number, format?: string): MathCollection | number
1898
1829
 
1899
1830
  /**
1900
1831
  * Filter the items in an array or one dimensional matrix.
@@ -1906,17 +1837,17 @@ declare namespace math {
1906
1837
  * traversed. The function must return a boolean.
1907
1838
  */
1908
1839
  filter(
1909
- x: Matrix | MathArray | string[],
1840
+ x: MathCollection | string[],
1910
1841
  test:
1911
1842
  | ((
1912
1843
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1913
1844
  value: any,
1914
1845
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1915
1846
  index: any,
1916
- matrix: Matrix | MathArray | string[]
1847
+ matrix: MathCollection | string[]
1917
1848
  ) => boolean)
1918
1849
  | RegExp
1919
- ): Matrix | MathArray
1850
+ ): MathCollection
1920
1851
 
1921
1852
  /**
1922
1853
  * Flatten a multi dimensional matrix into a single dimensional matrix.
@@ -1933,7 +1864,7 @@ declare namespace math {
1933
1864
  * parameters: the value of the element, the index of the element, and
1934
1865
  * the Matrix/array being traversed.
1935
1866
  */
1936
- forEach<T extends Matrix | MathArray>(
1867
+ forEach<T extends MathCollection>(
1937
1868
  x: T,
1938
1869
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1939
1870
  callback: (value: any, index: any, matrix: T) => void
@@ -1952,7 +1883,7 @@ declare namespace math {
1952
1883
  * @param y Second vector
1953
1884
  * @returns Returns the kronecker product of x and y
1954
1885
  */
1955
- kron(x: Matrix | MathArray, y: Matrix | MathArray): Matrix
1886
+ kron(x: MathCollection, y: MathCollection): Matrix
1956
1887
 
1957
1888
  /**
1958
1889
  * Iterate over all elements of a matrix/array, and executes the given
@@ -1963,7 +1894,7 @@ declare namespace math {
1963
1894
  * the Matrix/array being traversed.
1964
1895
  * @returns Transformed map of x
1965
1896
  */
1966
- map<T extends Matrix | MathArray>(
1897
+ map<T extends MathCollection>(
1967
1898
  x: T,
1968
1899
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1969
1900
  callback: (value: any, index: any, matrix: T) => MathType | string
@@ -2141,7 +2072,7 @@ declare namespace math {
2141
2072
  * b, and 0 when a == b. Default value: ‘asc’
2142
2073
  * @returns Returns the sorted matrix
2143
2074
  */
2144
- sort<T extends Matrix | MathArray>(
2075
+ sort<T extends MathCollection>(
2145
2076
  x: T,
2146
2077
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2147
2078
  compare: ((a: any, b: any) => number) | 'asc' | 'desc' | 'natural'
@@ -2422,10 +2353,7 @@ declare namespace math {
2422
2353
  * @returns Returns true when the input matrices have the same size and
2423
2354
  * each of their elements is equal.
2424
2355
  */
2425
- deepEqual(
2426
- x: MathType,
2427
- y: MathType
2428
- ): number | BigNumber | Fraction | Complex | Unit | MathCollection
2356
+ deepEqual(x: MathType, y: MathType): MathType
2429
2357
 
2430
2358
  /**
2431
2359
  * Test whether two values are equal.
@@ -2594,10 +2522,7 @@ declare namespace math {
2594
2522
  * @returns The number of how many times the multiset contains the
2595
2523
  * element
2596
2524
  */
2597
- setMultiplicity(
2598
- e: number | BigNumber | Fraction | Complex,
2599
- a: MathCollection
2600
- ): number
2525
+ setMultiplicity(e: MathNumericType, a: MathCollection): number
2601
2526
 
2602
2527
  /**
2603
2528
  * Create the powerset of a (multi)set. (The powerset contains very
@@ -2970,8 +2895,7 @@ declare namespace math {
2970
2895
  * @returns The arc cosine of x
2971
2896
  */
2972
2897
  acos(x: number): number | Complex
2973
- acos(x: BigNumber): BigNumber
2974
- acos(x: Complex): Complex
2898
+ acos<T extends BigNumber | Complex>(x: T): T
2975
2899
 
2976
2900
  /**
2977
2901
  * Calculate the hyperbolic arccos of a value, defined as acosh(x) =
@@ -2980,8 +2904,7 @@ declare namespace math {
2980
2904
  * @returns The hyperbolic arccosine of x
2981
2905
  */
2982
2906
  acosh(x: number): number | Complex
2983
- acosh(x: BigNumber): BigNumber
2984
- acosh(x: Complex): Complex
2907
+ acosh<T extends BigNumber | Complex>(x: T): T
2985
2908
 
2986
2909
  /**
2987
2910
  * Calculate the inverse cotangent of a value.
@@ -2989,8 +2912,7 @@ declare namespace math {
2989
2912
  * @returns The arc cotangent of x
2990
2913
  */
2991
2914
  acot(x: number): number
2992
- acot(x: BigNumber): BigNumber
2993
- acot(x: Complex): Complex
2915
+ acot<T extends BigNumber | Complex>(x: T): T
2994
2916
 
2995
2917
  /**
2996
2918
  * Calculate the hyperbolic arccotangent of a value, defined as acoth(x)
@@ -2999,8 +2921,7 @@ declare namespace math {
2999
2921
  * @returns The hyperbolic arccotangent of x
3000
2922
  */
3001
2923
  acoth(x: number): number
3002
- acoth(x: BigNumber): BigNumber
3003
- acoth(x: Complex): Complex
2924
+ acoth<T extends BigNumber | Complex>(x: T): T
3004
2925
 
3005
2926
  /**
3006
2927
  * Calculate the inverse cosecant of a value.
@@ -3008,8 +2929,7 @@ declare namespace math {
3008
2929
  * @returns The arc cosecant of x
3009
2930
  */
3010
2931
  acsc(x: number): number | Complex
3011
- acsc(x: BigNumber): BigNumber
3012
- acsc(x: Complex): Complex
2932
+ acsc<T extends BigNumber | Complex>(x: T): T
3013
2933
 
3014
2934
  /**
3015
2935
  * Calculate the hyperbolic arccosecant of a value, defined as acsch(x)
@@ -3018,8 +2938,7 @@ declare namespace math {
3018
2938
  * @returns The hyperbolic arccosecant of x
3019
2939
  */
3020
2940
  acsch(x: number): number
3021
- acsch(x: BigNumber): BigNumber
3022
- acsch(x: Complex): Complex
2941
+ acsch<T extends BigNumber | Complex>(x: T): T
3023
2942
 
3024
2943
  /**
3025
2944
  * Calculate the inverse secant of a value.
@@ -3027,8 +2946,7 @@ declare namespace math {
3027
2946
  * @returns The arc secant of x
3028
2947
  */
3029
2948
  asec(x: number): number | Complex
3030
- asec(x: BigNumber): BigNumber
3031
- asec(x: Complex): Complex
2949
+ asec<T extends BigNumber | Complex>(x: T): T
3032
2950
 
3033
2951
  /**
3034
2952
  * Calculate the hyperbolic arcsecant of a value, defined as asech(x) =
@@ -3037,8 +2955,7 @@ declare namespace math {
3037
2955
  * @returns The hyperbolic arcsecant of x
3038
2956
  */
3039
2957
  asech(x: number): number | Complex
3040
- asech(x: BigNumber): BigNumber
3041
- asech(x: Complex): Complex
2958
+ asech<T extends BigNumber | Complex>(x: T): T
3042
2959
 
3043
2960
  /**
3044
2961
  * Calculate the inverse sine of a value.
@@ -3046,8 +2963,7 @@ declare namespace math {
3046
2963
  * @returns The arc sine of x
3047
2964
  */
3048
2965
  asin(x: number): number | Complex
3049
- asin(x: BigNumber): BigNumber
3050
- asin(x: Complex): Complex
2966
+ asin<T extends BigNumber | Complex>(x: T): T
3051
2967
 
3052
2968
  /**
3053
2969
  * Calculate the hyperbolic arcsine of a value, defined as asinh(x) =
@@ -3055,18 +2971,14 @@ declare namespace math {
3055
2971
  * @param x Function input
3056
2972
  * @returns The hyperbolic arcsine of x
3057
2973
  */
3058
- asinh(x: number): number
3059
- asinh(x: BigNumber): BigNumber
3060
- asinh(x: Complex): Complex
2974
+ asinh<T extends number | BigNumber | Complex>(x: T): T
3061
2975
 
3062
2976
  /**
3063
2977
  * Calculate the inverse tangent of a value.
3064
2978
  * @param x Function input
3065
2979
  * @returns The arc tangent of x
3066
2980
  */
3067
- atan(x: number): number
3068
- atan(x: BigNumber): BigNumber
3069
- atan(x: Complex): Complex
2981
+ atan<T extends number | BigNumber | Complex>(x: T): T
3070
2982
 
3071
2983
  /**
3072
2984
  * Calculate the inverse tangent function with two arguments, y/x. By
@@ -3075,8 +2987,7 @@ declare namespace math {
3075
2987
  * @param x Function input
3076
2988
  * @returns Four quadrant inverse tangent
3077
2989
  */
3078
- atan2(y: number, x: number): number
3079
- atan2(y: MathCollection, x: MathCollection): MathCollection
2990
+ atan2<T extends number | MathCollection>(y: T, x: T): T
3080
2991
 
3081
2992
  /**
3082
2993
  * Calculate the hyperbolic arctangent of a value, defined as atanh(x) =
@@ -3085,8 +2996,7 @@ declare namespace math {
3085
2996
  * @returns The hyperbolic arctangent of x
3086
2997
  */
3087
2998
  atanh(x: number): number | Complex
3088
- atanh(x: BigNumber): BigNumber
3089
- atanh(x: Complex): Complex
2999
+ atanh<T extends BigNumber | Complex>(x: T): T
3090
3000
 
3091
3001
  /**
3092
3002
  * Calculate the cosine of a value.
@@ -3094,8 +3004,7 @@ declare namespace math {
3094
3004
  * @returns The cosine of x
3095
3005
  */
3096
3006
  cos(x: number | Unit): number
3097
- cos(x: BigNumber): BigNumber
3098
- cos(x: Complex): Complex
3007
+ cos<T extends BigNumber | Complex>(x: T): T
3099
3008
 
3100
3009
  /**
3101
3010
  * Calculate the hyperbolic cosine of a value, defined as cosh(x) = 1/2
@@ -3104,8 +3013,7 @@ declare namespace math {
3104
3013
  * @returns The hyperbolic cosine of x
3105
3014
  */
3106
3015
  cosh(x: number | Unit): number
3107
- cosh(x: BigNumber): BigNumber
3108
- cosh(x: Complex): Complex
3016
+ cosh<T extends BigNumber | Complex>(x: T): T
3109
3017
 
3110
3018
  /**
3111
3019
  * Calculate the cotangent of a value. cot(x) is defined as 1 / tan(x).
@@ -3113,8 +3021,7 @@ declare namespace math {
3113
3021
  * @returns The cotangent of x
3114
3022
  */
3115
3023
  cot(x: number | Unit): number
3116
- cot(x: BigNumber): BigNumber
3117
- cot(x: Complex): Complex
3024
+ cot<T extends BigNumber | Complex>(x: T): T
3118
3025
 
3119
3026
  /**
3120
3027
  * Calculate the hyperbolic cotangent of a value, defined as coth(x) = 1
@@ -3123,8 +3030,7 @@ declare namespace math {
3123
3030
  * @returns The hyperbolic cotangent of x
3124
3031
  */
3125
3032
  coth(x: number | Unit): number
3126
- coth(x: BigNumber): BigNumber
3127
- coth(x: Complex): Complex
3033
+ coth<T extends BigNumber | Complex>(x: T): T
3128
3034
 
3129
3035
  /**
3130
3036
  * Calculate the cosecant of a value, defined as csc(x) = 1/sin(x).
@@ -3132,8 +3038,7 @@ declare namespace math {
3132
3038
  * @returns The cosecant hof x
3133
3039
  */
3134
3040
  csc(x: number | Unit): number
3135
- csc(x: BigNumber): BigNumber
3136
- csc(x: Complex): Complex
3041
+ csc<T extends BigNumber | Complex>(x: T): T
3137
3042
 
3138
3043
  /**
3139
3044
  * Calculate the hyperbolic cosecant of a value, defined as csch(x) = 1
@@ -3142,8 +3047,7 @@ declare namespace math {
3142
3047
  * @returns The hyperbolic cosecant of x
3143
3048
  */
3144
3049
  csch(x: number | Unit): number
3145
- csch(x: BigNumber): BigNumber
3146
- csch(x: Complex): Complex
3050
+ csch<T extends BigNumber | Complex>(x: T): T
3147
3051
 
3148
3052
  /**
3149
3053
  * Calculate the secant of a value, defined as sec(x) = 1/cos(x).
@@ -3151,8 +3055,7 @@ declare namespace math {
3151
3055
  * @returns The secant of x
3152
3056
  */
3153
3057
  sec(x: number | Unit): number
3154
- sec(x: BigNumber): BigNumber
3155
- sec(x: Complex): Complex
3058
+ sec<T extends BigNumber | Complex>(x: T): T
3156
3059
 
3157
3060
  /**
3158
3061
  * Calculate the hyperbolic secant of a value, defined as sech(x) = 1 /
@@ -3161,8 +3064,7 @@ declare namespace math {
3161
3064
  * @returns The hyperbolic secant of x
3162
3065
  */
3163
3066
  sech(x: number | Unit): number
3164
- sech(x: BigNumber): BigNumber
3165
- sech(x: Complex): Complex
3067
+ sech<T extends BigNumber | Complex>(x: T): T
3166
3068
 
3167
3069
  /**
3168
3070
  * Calculate the sine of a value.
@@ -3170,8 +3072,7 @@ declare namespace math {
3170
3072
  * @returns The sine of x
3171
3073
  */
3172
3074
  sin(x: number | Unit): number
3173
- sin(x: BigNumber): BigNumber
3174
- sin(x: Complex): Complex
3075
+ sin<T extends BigNumber | Complex>(x: T): T
3175
3076
 
3176
3077
  /**
3177
3078
  * Calculate the hyperbolic sine of a value, defined as sinh(x) = 1/2 *
@@ -3180,8 +3081,7 @@ declare namespace math {
3180
3081
  * @returns The hyperbolic sine of x
3181
3082
  */
3182
3083
  sinh(x: number | Unit): number
3183
- sinh(x: BigNumber): BigNumber
3184
- sinh(x: Complex): Complex
3084
+ sinh<T extends BigNumber | Complex>(x: T): T
3185
3085
 
3186
3086
  /**
3187
3087
  * Calculate the tangent of a value. tan(x) is equal to sin(x) / cos(x).
@@ -3189,8 +3089,7 @@ declare namespace math {
3189
3089
  * @returns The tangent of x
3190
3090
  */
3191
3091
  tan(x: number | Unit): number
3192
- tan(x: BigNumber): BigNumber
3193
- tan(x: Complex): Complex
3092
+ tan<T extends BigNumber | Complex>(x: T): T
3194
3093
 
3195
3094
  /**
3196
3095
  * Calculate the hyperbolic tangent of a value, defined as tanh(x) =
@@ -3199,8 +3098,7 @@ declare namespace math {
3199
3098
  * @returns The hyperbolic tangent of x
3200
3099
  */
3201
3100
  tanh(x: number | Unit): number
3202
- tanh(x: BigNumber): BigNumber
3203
- tanh(x: Complex): Complex
3101
+ tanh<T extends BigNumber | Complex>(x: T): T
3204
3102
 
3205
3103
  /*************************************************************************
3206
3104
  * Unit functions
@@ -3396,9 +3294,7 @@ declare namespace math {
3396
3294
  * @returns Returns true when x is zero. Throws an error in case of an
3397
3295
  * unknown data type.
3398
3296
  */
3399
- isZero(
3400
- x: number | BigNumber | Fraction | MathCollection | Unit | Complex
3401
- ): boolean
3297
+ isZero(x: MathType): boolean
3402
3298
 
3403
3299
  /**
3404
3300
  * Determine the type of a variable.
@@ -3784,7 +3680,7 @@ declare namespace math {
3784
3680
  apply(
3785
3681
  dim: number,
3786
3682
  callback: (array: MathCollection) => number
3787
- ): Matrix | MathArray
3683
+ ): MathCollection
3788
3684
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3789
3685
  get(index: number[]): any
3790
3686
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -4395,11 +4291,7 @@ declare namespace math {
4395
4291
  * @param unit The unit to be created
4396
4292
  */
4397
4293
  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>
4294
+ unit(this: MathJsChain<MathNumericType>, unit?: string): MathJsChain<Unit>
4403
4295
  unit(this: MathJsChain<MathCollection>, unit?: string): MathJsChain<Unit[]>
4404
4296
 
4405
4297
  /*************************************************************************
@@ -4488,13 +4380,10 @@ declare namespace math {
4488
4380
  * must be a lower triangular matrix.
4489
4381
  * @param b A column vector with the b values
4490
4382
  */
4491
- lsolve(
4492
- this: MathJsChain<Matrix>,
4493
- b: Matrix | MathArray
4494
- ): MathJsChain<Matrix>
4383
+ lsolve(this: MathJsChain<Matrix>, b: MathCollection): MathJsChain<Matrix>
4495
4384
  lsolve(
4496
4385
  this: MathJsChain<MathArray>,
4497
- b: Matrix | MathArray
4386
+ b: MathCollection
4498
4387
  ): MathJsChain<MathArray>
4499
4388
 
4500
4389
  /**
@@ -4502,7 +4391,7 @@ declare namespace math {
4502
4391
  * is decomposed in two matrices (L, U) and a row permutation vector p
4503
4392
  * where A[p,:] = L * U
4504
4393
  */
4505
- lup(this: MathJsChain<Matrix | MathArray>): MathJsChain<LUDecomposition>
4394
+ lup(this: MathJsChain<MathCollection>): MathJsChain<LUDecomposition>
4506
4395
 
4507
4396
  /**
4508
4397
  * Solves the linear system A * x = b where A is an [n x n] matrix and b
@@ -4515,21 +4404,21 @@ declare namespace math {
4515
4404
  */
4516
4405
  lusolve(
4517
4406
  this: MathJsChain<Matrix>,
4518
- b: Matrix | MathArray,
4407
+ b: MathCollection,
4519
4408
  order?: number,
4520
4409
  threshold?: number
4521
4410
  ): MathJsChain<Matrix>
4522
4411
 
4523
4412
  lusolve(
4524
4413
  this: MathJsChain<MathArray>,
4525
- b: Matrix | MathArray,
4414
+ b: MathCollection,
4526
4415
  order?: number,
4527
4416
  threshold?: number
4528
4417
  ): MathJsChain<MathArray>
4529
4418
 
4530
4419
  lusolve(
4531
4420
  this: MathJsChain<LUDecomposition>,
4532
- b: Matrix | MathArray
4421
+ b: MathCollection
4533
4422
  ): MathJsChain<Matrix>
4534
4423
 
4535
4424
  /**
@@ -4537,7 +4426,7 @@ declare namespace math {
4537
4426
  * matrices (Q, R) where Q is an orthogonal matrix and R is an upper
4538
4427
  * triangular matrix.
4539
4428
  */
4540
- qr(this: MathJsChain<Matrix | MathArray>): MathJsChain<QRDecomposition>
4429
+ qr(this: MathJsChain<MathCollection>): MathJsChain<QRDecomposition>
4541
4430
 
4542
4431
  /**
4543
4432
  * Transform a rationalizable expression in a rational fraction. If
@@ -4606,13 +4495,10 @@ declare namespace math {
4606
4495
  * must be an upper triangular matrix. U * x = b
4607
4496
  * @param b A column vector with the b values
4608
4497
  */
4609
- usolve(
4610
- this: MathJsChain<Matrix>,
4611
- b: Matrix | MathArray
4612
- ): MathJsChain<Matrix>
4498
+ usolve(this: MathJsChain<Matrix>, b: MathCollection): MathJsChain<Matrix>
4613
4499
  usolve(
4614
4500
  this: MathJsChain<MathArray>,
4615
- b: Matrix | MathArray
4501
+ b: MathCollection
4616
4502
  ): MathJsChain<MathArray>
4617
4503
 
4618
4504
  /*************************************************************************
@@ -4623,13 +4509,7 @@ declare namespace math {
4623
4509
  * Calculate the absolute value of a number. For matrices, the function
4624
4510
  * is evaluated element wise.
4625
4511
  */
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>
4512
+ abs<T extends MathType>(this: MathJsChain<T>): MathJsChain<T>
4633
4513
 
4634
4514
  /**
4635
4515
  * Add two values, x + y. For matrices, the function is evaluated
@@ -4661,10 +4541,10 @@ declare namespace math {
4661
4541
  * a number or complex number. If true, all complex roots are returned,
4662
4542
  * if false (default) the principal root is returned.
4663
4543
  */
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>
4544
+ cbrt<T extends number | BigNumber | Complex | Unit>(
4545
+ this: MathJsChain<T>,
4546
+ allRoots?: boolean
4547
+ ): MathJsChain<T>
4668
4548
 
4669
4549
  // Rounding functions grouped for similarity
4670
4550
 
@@ -4674,56 +4554,40 @@ declare namespace math {
4674
4554
  * function is evaluated element wise.
4675
4555
  * @param n Number of decimals Default value: 0.
4676
4556
  */
4677
- ceil(
4678
- this: MathJsChain<MathNumericType>,
4679
- n?: number | BigNumber | MathCollection
4680
- ): MathJsChain<MathNumericType>
4681
- ceil(
4682
- this: MathJsChain<MathCollection>,
4557
+ ceil<T extends MathNumericType | MathCollection>(
4558
+ this: MathJsChain<T>,
4683
4559
  n?: number | BigNumber | MathCollection
4684
- ): MathJsChain<MathCollection>
4560
+ ): MathJsChain<T>
4685
4561
 
4686
4562
  /**
4687
4563
  * Round a value towards zero. For matrices, the function is evaluated
4688
4564
  * element wise.
4689
4565
  * @param n Number of decimals Default value: 0.
4690
4566
  */
4691
- fix(
4692
- this: MathJsChain<MathNumericType>,
4693
- n?: number | BigNumber | MathCollection
4694
- ): MathJsChain<MathNumericType>
4695
- fix(
4696
- this: MathJsChain<MathCollection>,
4567
+ fix<T extends MathNumericType | MathCollection>(
4568
+ this: MathJsChain<T>,
4697
4569
  n?: number | BigNumber | MathCollection
4698
- ): MathJsChain<MathCollection>
4570
+ ): MathJsChain<T>
4699
4571
 
4700
4572
  /**
4701
4573
  * Round a value towards minus infinity. For matrices, the function is
4702
4574
  * evaluated element wise.
4703
4575
  * @param n Number of decimals Default value: 0.
4704
4576
  */
4705
- floor(
4706
- this: MathJsChain<MathNumericType>,
4707
- n?: number | BigNumber | MathCollection
4708
- ): MathJsChain<MathNumericType>
4709
- floor(
4710
- this: MathJsChain<MathCollection>,
4577
+ floor<T extends MathNumericType | MathCollection>(
4578
+ this: MathJsChain<T>,
4711
4579
  n?: number | BigNumber | MathCollection
4712
- ): MathJsChain<MathCollection>
4580
+ ): MathJsChain<T>
4713
4581
 
4714
4582
  /**
4715
4583
  * Round a value towards the nearest integer. For matrices, the function
4716
4584
  * is evaluated element wise.
4717
4585
  * @param n Number of decimals Default value: 0.
4718
4586
  */
4719
- round(
4720
- this: MathJsChain<MathNumericType>,
4721
- n?: number | BigNumber | MathCollection
4722
- ): MathJsChain<MathNumericType>
4723
- round(
4724
- this: MathJsChain<MathCollection>,
4587
+ round<T extends MathNumericType | MathCollection>(
4588
+ this: MathJsChain<T>,
4725
4589
  n?: number | BigNumber | MathCollection
4726
- ): MathJsChain<MathCollection>
4590
+ ): MathJsChain<T>
4727
4591
 
4728
4592
  // End of rounding group
4729
4593
 
@@ -4731,11 +4595,7 @@ declare namespace math {
4731
4595
  * Compute the cube of a value, x * x * x. For matrices, the function is
4732
4596
  * evaluated element wise.
4733
4597
  */
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>
4598
+ cube<T extends MathNumericType | Unit>(this: MathJsChain<T>): MathJsChain<T>
4739
4599
 
4740
4600
  /**
4741
4601
  * Divide two values, x / y. To divide matrices, x is multiplied with
@@ -4800,33 +4660,27 @@ declare namespace math {
4800
4660
  * Calculate the exponent of a value. For matrices, the function is
4801
4661
  * evaluated element wise.
4802
4662
  */
4803
- exp(this: MathJsChain<number>): MathJsChain<number>
4804
- exp(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
4805
- exp(this: MathJsChain<Complex>): MathJsChain<Complex>
4663
+ exp<T extends number | BigNumber | Complex>(
4664
+ this: MathJsChain<T>
4665
+ ): MathJsChain<T>
4806
4666
 
4807
4667
  /**
4808
4668
  * Calculate the value of subtracting 1 from the exponential value. For
4809
4669
  * matrices, the function is evaluated element wise.
4810
4670
  */
4811
- expm1(this: MathJsChain<number>): MathJsChain<number>
4812
- expm1(this: MathJsChain<BigNumber>): MathJsChain<BigNumber>
4813
- expm1(this: MathJsChain<Complex>): MathJsChain<Complex>
4671
+ expm1<T extends number | BigNumber | Complex>(
4672
+ this: MathJsChain<T>
4673
+ ): MathJsChain<T>
4814
4674
 
4815
4675
  /**
4816
4676
  * Calculate the greatest common divisor for two or more values or
4817
4677
  * arrays. For matrices, the function is evaluated element wise.
4818
4678
  */
4819
- gcd(this: MathJsChain<number[]>, ...args: number[]): MathJsChain<number>
4820
- gcd(
4821
- this: MathJsChain<BigNumber[]>,
4822
- ...args: BigNumber[]
4823
- ): MathJsChain<BigNumber>
4679
+ gcd<T extends number | BigNumber | MathCollection>(
4680
+ this: MathJsChain<T[]>,
4681
+ ...args: T[]
4682
+ ): MathJsChain<T>
4824
4683
  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>
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.