mathjs 10.5.2 → 10.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (329) hide show
  1. package/HISTORY.md +28 -0
  2. package/lib/browser/math.js +6 -5
  3. package/lib/browser/math.js.map +1 -1
  4. package/lib/cjs/entry/dependenciesAny/dependenciesFft.generated.js +41 -0
  5. package/lib/cjs/entry/dependenciesAny/dependenciesIfft.generated.js +29 -0
  6. package/lib/cjs/entry/dependenciesAny.generated.js +16 -0
  7. package/lib/cjs/entry/impureFunctionsAny.generated.js +66 -64
  8. package/lib/cjs/entry/pureFunctionsAny.generated.js +189 -171
  9. package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +6 -0
  10. package/lib/cjs/expression/embeddedDocs/function/matrix/fft.js +15 -0
  11. package/lib/cjs/expression/embeddedDocs/function/matrix/ifft.js +15 -0
  12. package/lib/cjs/factoriesAny.js +16 -0
  13. package/lib/cjs/function/algebra/derivative.js +1 -1
  14. package/lib/cjs/function/matrix/fft.js +128 -0
  15. package/lib/cjs/function/matrix/ifft.js +49 -0
  16. package/lib/cjs/header.js +2 -2
  17. package/lib/cjs/version.js +1 -1
  18. package/lib/esm/entry/dependenciesAny/dependenciesFft.generated.js +24 -0
  19. package/lib/esm/entry/dependenciesAny/dependenciesIfft.generated.js +16 -0
  20. package/lib/esm/entry/dependenciesAny.generated.js +2 -0
  21. package/lib/esm/entry/impureFunctionsAny.generated.js +63 -61
  22. package/lib/esm/entry/pureFunctionsAny.generated.js +161 -145
  23. package/lib/esm/expression/embeddedDocs/embeddedDocs.js +4 -0
  24. package/lib/esm/expression/embeddedDocs/function/matrix/fft.js +8 -0
  25. package/lib/esm/expression/embeddedDocs/function/matrix/ifft.js +8 -0
  26. package/lib/esm/factoriesAny.js +2 -0
  27. package/lib/esm/function/algebra/derivative.js +1 -1
  28. package/lib/esm/function/matrix/fft.js +104 -0
  29. package/lib/esm/function/matrix/ifft.js +38 -0
  30. package/lib/esm/version.js +1 -1
  31. package/package.json +22 -24
  32. package/types/index.d.ts +1052 -283
  33. package/types/index.ts +711 -7
  34. package/docs/command_line_interface.md +0 -87
  35. package/docs/core/chaining.md +0 -41
  36. package/docs/core/configuration.md +0 -144
  37. package/docs/core/extension.md +0 -263
  38. package/docs/core/index.md +0 -21
  39. package/docs/core/serialization.md +0 -50
  40. package/docs/custom_bundling.md +0 -116
  41. package/docs/datatypes/bignumbers.md +0 -102
  42. package/docs/datatypes/complex_numbers.md +0 -168
  43. package/docs/datatypes/fractions.md +0 -75
  44. package/docs/datatypes/index.md +0 -67
  45. package/docs/datatypes/matrices.md +0 -375
  46. package/docs/datatypes/numbers.md +0 -106
  47. package/docs/datatypes/units.md +0 -444
  48. package/docs/expressions/algebra.md +0 -110
  49. package/docs/expressions/customization.md +0 -379
  50. package/docs/expressions/expression_trees.md +0 -710
  51. package/docs/expressions/html_classes.md +0 -38
  52. package/docs/expressions/index.md +0 -21
  53. package/docs/expressions/parsing.md +0 -224
  54. package/docs/expressions/security.md +0 -89
  55. package/docs/expressions/syntax.md +0 -706
  56. package/docs/getting_started.md +0 -124
  57. package/docs/index.md +0 -39
  58. package/docs/reference/classes/densematrix.md +0 -247
  59. package/docs/reference/classes/fibonacciheap.md +0 -70
  60. package/docs/reference/classes/matrixindex.md +0 -133
  61. package/docs/reference/classes/matrixrange.md +0 -158
  62. package/docs/reference/classes/resultset.md +0 -47
  63. package/docs/reference/classes/sparsematrix.md +0 -245
  64. package/docs/reference/classes/unit.md +0 -242
  65. package/docs/reference/classes.md +0 -86
  66. package/docs/reference/constants.md +0 -29
  67. package/docs/reference/functions/abs.md +0 -46
  68. package/docs/reference/functions/acos.md +0 -49
  69. package/docs/reference/functions/acosh.md +0 -47
  70. package/docs/reference/functions/acot.md +0 -48
  71. package/docs/reference/functions/acoth.md +0 -46
  72. package/docs/reference/functions/acsc.md +0 -49
  73. package/docs/reference/functions/acsch.md +0 -46
  74. package/docs/reference/functions/add.md +0 -59
  75. package/docs/reference/functions/and.md +0 -53
  76. package/docs/reference/functions/apply.md +0 -56
  77. package/docs/reference/functions/arg.md +0 -53
  78. package/docs/reference/functions/asec.md +0 -49
  79. package/docs/reference/functions/asech.md +0 -46
  80. package/docs/reference/functions/asin.md +0 -49
  81. package/docs/reference/functions/asinh.md +0 -46
  82. package/docs/reference/functions/atan.md +0 -49
  83. package/docs/reference/functions/atan2.md +0 -56
  84. package/docs/reference/functions/atanh.md +0 -46
  85. package/docs/reference/functions/bellNumbers.md +0 -45
  86. package/docs/reference/functions/bignumber.md +0 -47
  87. package/docs/reference/functions/bin.md +0 -45
  88. package/docs/reference/functions/bitAnd.md +0 -51
  89. package/docs/reference/functions/bitNot.md +0 -51
  90. package/docs/reference/functions/bitOr.md +0 -52
  91. package/docs/reference/functions/bitXor.md +0 -51
  92. package/docs/reference/functions/boolean.md +0 -50
  93. package/docs/reference/functions/catalan.md +0 -45
  94. package/docs/reference/functions/cbrt.md +0 -60
  95. package/docs/reference/functions/ceil.md +0 -63
  96. package/docs/reference/functions/chain.md +0 -54
  97. package/docs/reference/functions/clone.md +0 -43
  98. package/docs/reference/functions/column.md +0 -45
  99. package/docs/reference/functions/combinations.md +0 -49
  100. package/docs/reference/functions/combinationsWithRep.md +0 -49
  101. package/docs/reference/functions/compare.md +0 -67
  102. package/docs/reference/functions/compareNatural.md +0 -92
  103. package/docs/reference/functions/compareText.md +0 -54
  104. package/docs/reference/functions/compile.md +0 -56
  105. package/docs/reference/functions/complex.md +0 -17
  106. package/docs/reference/functions/composition.md +0 -46
  107. package/docs/reference/functions/concat.md +0 -56
  108. package/docs/reference/functions/config.md +0 -44
  109. package/docs/reference/functions/conj.md +0 -50
  110. package/docs/reference/functions/cos.md +0 -51
  111. package/docs/reference/functions/cosh.md +0 -46
  112. package/docs/reference/functions/cot.md +0 -47
  113. package/docs/reference/functions/coth.md +0 -49
  114. package/docs/reference/functions/count.md +0 -45
  115. package/docs/reference/functions/createUnit.md +0 -52
  116. package/docs/reference/functions/cross.md +0 -58
  117. package/docs/reference/functions/csc.md +0 -47
  118. package/docs/reference/functions/csch.md +0 -49
  119. package/docs/reference/functions/ctranspose.md +0 -50
  120. package/docs/reference/functions/cube.md +0 -51
  121. package/docs/reference/functions/cumsum.md +0 -57
  122. package/docs/reference/functions/deepEqual.md +0 -53
  123. package/docs/reference/functions/derivative.md +0 -61
  124. package/docs/reference/functions/det.md +0 -49
  125. package/docs/reference/functions/diag.md +0 -61
  126. package/docs/reference/functions/diff.md +0 -70
  127. package/docs/reference/functions/distance.md +0 -80
  128. package/docs/reference/functions/divide.md +0 -55
  129. package/docs/reference/functions/dot.md +0 -48
  130. package/docs/reference/functions/dotDivide.md +0 -52
  131. package/docs/reference/functions/dotMultiply.md +0 -52
  132. package/docs/reference/functions/dotPow.md +0 -49
  133. package/docs/reference/functions/eigs.md +0 -54
  134. package/docs/reference/functions/equal.md +0 -75
  135. package/docs/reference/functions/equalText.md +0 -53
  136. package/docs/reference/functions/erf.md +0 -49
  137. package/docs/reference/functions/evaluate.md +0 -56
  138. package/docs/reference/functions/exp.md +0 -54
  139. package/docs/reference/functions/expm.md +0 -49
  140. package/docs/reference/functions/expm1.md +0 -54
  141. package/docs/reference/functions/factorial.md +0 -49
  142. package/docs/reference/functions/fft.md +0 -35
  143. package/docs/reference/functions/filter.md +0 -50
  144. package/docs/reference/functions/fix.md +0 -62
  145. package/docs/reference/functions/flatten.md +0 -46
  146. package/docs/reference/functions/floor.md +0 -66
  147. package/docs/reference/functions/forEach.md +0 -41
  148. package/docs/reference/functions/format.md +0 -127
  149. package/docs/reference/functions/fraction.md +0 -45
  150. package/docs/reference/functions/gamma.md +0 -49
  151. package/docs/reference/functions/gcd.md +0 -50
  152. package/docs/reference/functions/getMatrixDataType.md +0 -59
  153. package/docs/reference/functions/hasNumericValue.md +0 -55
  154. package/docs/reference/functions/help.md +0 -42
  155. package/docs/reference/functions/hex.md +0 -45
  156. package/docs/reference/functions/hypot.md +0 -51
  157. package/docs/reference/functions/identity.md +0 -57
  158. package/docs/reference/functions/ifft.md +0 -35
  159. package/docs/reference/functions/im.md +0 -53
  160. package/docs/reference/functions/import.md +0 -68
  161. package/docs/reference/functions/index.md +0 -55
  162. package/docs/reference/functions/intersect.md +0 -50
  163. package/docs/reference/functions/inv.md +0 -45
  164. package/docs/reference/functions/invmod.md +0 -47
  165. package/docs/reference/functions/isInteger.md +0 -55
  166. package/docs/reference/functions/isNaN.md +0 -56
  167. package/docs/reference/functions/isNegative.md +0 -55
  168. package/docs/reference/functions/isNumeric.md +0 -55
  169. package/docs/reference/functions/isPositive.md +0 -57
  170. package/docs/reference/functions/isPrime.md +0 -54
  171. package/docs/reference/functions/isZero.md +0 -59
  172. package/docs/reference/functions/kldivergence.md +0 -41
  173. package/docs/reference/functions/kron.md +0 -53
  174. package/docs/reference/functions/larger.md +0 -60
  175. package/docs/reference/functions/largerEq.md +0 -56
  176. package/docs/reference/functions/lcm.md +0 -54
  177. package/docs/reference/functions/leafCount.md +0 -52
  178. package/docs/reference/functions/leftShift.md +0 -52
  179. package/docs/reference/functions/lgamma.md +0 -46
  180. package/docs/reference/functions/log.md +0 -57
  181. package/docs/reference/functions/log10.md +0 -50
  182. package/docs/reference/functions/log1p.md +0 -54
  183. package/docs/reference/functions/log2.md +0 -50
  184. package/docs/reference/functions/lsolve.md +0 -51
  185. package/docs/reference/functions/lsolveAll.md +0 -51
  186. package/docs/reference/functions/lup.md +0 -52
  187. package/docs/reference/functions/lusolve.md +0 -59
  188. package/docs/reference/functions/mad.md +0 -50
  189. package/docs/reference/functions/map.md +0 -65
  190. package/docs/reference/functions/matrix.md +0 -56
  191. package/docs/reference/functions/matrixFromColumns.md +0 -49
  192. package/docs/reference/functions/matrixFromFunction.md +0 -54
  193. package/docs/reference/functions/matrixFromRows.md +0 -49
  194. package/docs/reference/functions/max.md +0 -61
  195. package/docs/reference/functions/mean.md +0 -57
  196. package/docs/reference/functions/median.md +0 -57
  197. package/docs/reference/functions/min.md +0 -61
  198. package/docs/reference/functions/mod.md +0 -59
  199. package/docs/reference/functions/mode.md +0 -50
  200. package/docs/reference/functions/multinomial.md +0 -46
  201. package/docs/reference/functions/multiply.md +0 -60
  202. package/docs/reference/functions/norm.md +0 -59
  203. package/docs/reference/functions/not.md +0 -50
  204. package/docs/reference/functions/nthRoot.md +0 -53
  205. package/docs/reference/functions/nthRoots.md +0 -58
  206. package/docs/reference/functions/number.md +0 -49
  207. package/docs/reference/functions/numeric.md +0 -52
  208. package/docs/reference/functions/oct.md +0 -45
  209. package/docs/reference/functions/ones.md +0 -59
  210. package/docs/reference/functions/or.md +0 -53
  211. package/docs/reference/functions/parse.md +0 -56
  212. package/docs/reference/functions/parser.md +0 -70
  213. package/docs/reference/functions/partitionSelect.md +0 -53
  214. package/docs/reference/functions/permutations.md +0 -51
  215. package/docs/reference/functions/pickRandom.md +0 -59
  216. package/docs/reference/functions/pinv.md +0 -44
  217. package/docs/reference/functions/pow.md +0 -65
  218. package/docs/reference/functions/print.md +0 -64
  219. package/docs/reference/functions/prod.md +0 -55
  220. package/docs/reference/functions/qr.md +0 -65
  221. package/docs/reference/functions/quantileSeq.md +0 -62
  222. package/docs/reference/functions/random.md +0 -54
  223. package/docs/reference/functions/randomInt.md +0 -53
  224. package/docs/reference/functions/range.md +0 -70
  225. package/docs/reference/functions/rationalize.md +0 -68
  226. package/docs/reference/functions/re.md +0 -53
  227. package/docs/reference/functions/reshape.md +0 -60
  228. package/docs/reference/functions/resize.md +0 -51
  229. package/docs/reference/functions/resolve.md +0 -46
  230. package/docs/reference/functions/rightArithShift.md +0 -52
  231. package/docs/reference/functions/rightLogShift.md +0 -52
  232. package/docs/reference/functions/rotate.md +0 -53
  233. package/docs/reference/functions/rotationMatrix.md +0 -57
  234. package/docs/reference/functions/round.md +0 -61
  235. package/docs/reference/functions/row.md +0 -45
  236. package/docs/reference/functions/sec.md +0 -47
  237. package/docs/reference/functions/sech.md +0 -49
  238. package/docs/reference/functions/setCartesian.md +0 -49
  239. package/docs/reference/functions/setDifference.md +0 -47
  240. package/docs/reference/functions/setDistinct.md +0 -43
  241. package/docs/reference/functions/setIntersect.md +0 -46
  242. package/docs/reference/functions/setIsSubset.md +0 -47
  243. package/docs/reference/functions/setMultiplicity.md +0 -46
  244. package/docs/reference/functions/setPowerset.md +0 -43
  245. package/docs/reference/functions/setSize.md +0 -47
  246. package/docs/reference/functions/setSymDifference.md +0 -47
  247. package/docs/reference/functions/setUnion.md +0 -46
  248. package/docs/reference/functions/sign.md +0 -52
  249. package/docs/reference/functions/simplify.md +0 -130
  250. package/docs/reference/functions/simplifyConstant.md +0 -52
  251. package/docs/reference/functions/simplifyCore.md +0 -50
  252. package/docs/reference/functions/sin.md +0 -51
  253. package/docs/reference/functions/sinh.md +0 -46
  254. package/docs/reference/functions/size.md +0 -50
  255. package/docs/reference/functions/slu.md +0 -57
  256. package/docs/reference/functions/smaller.md +0 -60
  257. package/docs/reference/functions/smallerEq.md +0 -56
  258. package/docs/reference/functions/sort.md +0 -56
  259. package/docs/reference/functions/sparse.md +0 -51
  260. package/docs/reference/functions/splitUnit.md +0 -37
  261. package/docs/reference/functions/sqrt.md +0 -50
  262. package/docs/reference/functions/sqrtm.md +0 -46
  263. package/docs/reference/functions/square.md +0 -51
  264. package/docs/reference/functions/squeeze.md +0 -53
  265. package/docs/reference/functions/std.md +0 -76
  266. package/docs/reference/functions/stirlingS2.md +0 -52
  267. package/docs/reference/functions/string.md +0 -49
  268. package/docs/reference/functions/subset.md +0 -65
  269. package/docs/reference/functions/subtract.md +0 -54
  270. package/docs/reference/functions/sum.md +0 -54
  271. package/docs/reference/functions/symbolicEqual.md +0 -62
  272. package/docs/reference/functions/tan.md +0 -49
  273. package/docs/reference/functions/tanh.md +0 -50
  274. package/docs/reference/functions/to.md +0 -47
  275. package/docs/reference/functions/trace.md +0 -50
  276. package/docs/reference/functions/transpose.md +0 -49
  277. package/docs/reference/functions/typeOf.md +0 -81
  278. package/docs/reference/functions/typed.md +0 -56
  279. package/docs/reference/functions/unaryMinus.md +0 -49
  280. package/docs/reference/functions/unaryPlus.md +0 -48
  281. package/docs/reference/functions/unequal.md +0 -74
  282. package/docs/reference/functions/unit.md +0 -48
  283. package/docs/reference/functions/usolve.md +0 -51
  284. package/docs/reference/functions/usolveAll.md +0 -51
  285. package/docs/reference/functions/variance.md +0 -78
  286. package/docs/reference/functions/xgcd.md +0 -47
  287. package/docs/reference/functions/xor.md +0 -53
  288. package/docs/reference/functions/zeros.md +0 -57
  289. package/docs/reference/functions.md +0 -297
  290. package/docs/reference/index.md +0 -5
  291. package/examples/advanced/convert_fraction_to_bignumber.js +0 -59
  292. package/examples/advanced/custom_argument_parsing.js +0 -98
  293. package/examples/advanced/custom_datatype.js +0 -56
  294. package/examples/advanced/custom_evaluate_using_factories.js +0 -19
  295. package/examples/advanced/custom_evaluate_using_import.js +0 -18
  296. package/examples/advanced/custom_loading.js +0 -33
  297. package/examples/advanced/custom_relational_functions.js +0 -62
  298. package/examples/advanced/custom_scope_objects.js +0 -115
  299. package/examples/advanced/expression_trees.js +0 -55
  300. package/examples/advanced/function_transform.js +0 -50
  301. package/examples/advanced/more_secure_eval.js +0 -36
  302. package/examples/advanced/use_bigint.js +0 -43
  303. package/examples/advanced/web_server/math_worker.js +0 -24
  304. package/examples/advanced/web_server/server.js +0 -80
  305. package/examples/algebra.js +0 -34
  306. package/examples/basic_usage.js +0 -49
  307. package/examples/bignumbers.js +0 -52
  308. package/examples/browser/angle_configuration.html +0 -134
  309. package/examples/browser/basic_usage.html +0 -39
  310. package/examples/browser/currency_conversion.html +0 -125
  311. package/examples/browser/custom_separators.html +0 -81
  312. package/examples/browser/plot.html +0 -78
  313. package/examples/browser/pretty_printing_with_mathjax.html +0 -122
  314. package/examples/browser/printing_html.html +0 -170
  315. package/examples/browser/requirejs_loading.html +0 -20
  316. package/examples/browser/rocket_trajectory_optimization.html +0 -301
  317. package/examples/browser/webworkers/webworkers.html +0 -80
  318. package/examples/browser/webworkers/worker.js +0 -28
  319. package/examples/chaining.js +0 -56
  320. package/examples/complex_numbers.js +0 -67
  321. package/examples/expressions.js +0 -188
  322. package/examples/fractions.js +0 -74
  323. package/examples/import.js +0 -95
  324. package/examples/matrices.js +0 -101
  325. package/examples/objects.js +0 -35
  326. package/examples/package.json +0 -3
  327. package/examples/serialization.js +0 -16
  328. package/examples/sparse_matrices.js +0 -19
  329. package/examples/units.js +0 -108
@@ -1,57 +0,0 @@
1
- <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
-
3
- # Function zeros
4
-
5
- Create a matrix filled with zeros. The created matrix can have one or
6
- multiple dimensions.
7
-
8
-
9
- ## Syntax
10
-
11
- ```js
12
- math.zeros(m)
13
- math.zeros(m, format)
14
- math.zeros(m, n)
15
- math.zeros(m, n, format)
16
- math.zeros([m, n])
17
- math.zeros([m, n], format)
18
- ```
19
-
20
- ### Parameters
21
-
22
- Parameter | Type | Description
23
- --------- | ---- | -----------
24
- `size` | ...number &#124; Array | The size of each dimension of the matrix
25
- `format` | string | The Matrix storage format
26
-
27
- ### Returns
28
-
29
- Type | Description
30
- ---- | -----------
31
- Array &#124; Matrix | A matrix filled with zeros
32
-
33
-
34
- ### Throws
35
-
36
- Type | Description
37
- ---- | -----------
38
-
39
-
40
- ## Examples
41
-
42
- ```js
43
- math.zeros(3) // returns [0, 0, 0]
44
- math.zeros(3, 2) // returns [[0, 0], [0, 0], [0, 0]]
45
- math.zeros(3, 'dense') // returns [0, 0, 0]
46
-
47
- const A = [[1, 2, 3], [4, 5, 6]]
48
- math.zeros(math.size(A)) // returns [[0, 0, 0], [0, 0, 0]]
49
- ```
50
-
51
-
52
- ## See also
53
-
54
- [ones](ones.md),
55
- [identity](identity.md),
56
- [size](size.md),
57
- [range](range.md)
@@ -1,297 +0,0 @@
1
- # Function reference
2
-
3
- ## Expression functions
4
-
5
- Function | Description
6
- ---- | -----------
7
- [math.compile(expr)](functions/compile.md) | Parse and compile an expression.
8
- [math.evaluate(expr&nbsp;[,&nbsp;scope])](functions/evaluate.md) | Evaluate an expression.
9
- [math.help(search)](functions/help.md) | Retrieve help on a function or data type.
10
- [math.parser()](functions/parser.md) | Create a parser.
11
-
12
- ## Algebra functions
13
-
14
- Function | Description
15
- ---- | -----------
16
- [derivative(expr,&nbsp;variable)](functions/derivative.md) | Takes the derivative of an expression expressed in parser Nodes.
17
- [leafCount(expr)](functions/leafCount.md) | Gives the number of "leaf nodes" in the parse tree of the given expression A leaf node is one that has no subexpressions, essentially either a symbol or a constant.
18
- [math.lsolve(L,&nbsp;b)](functions/lsolve.md) | Finds one solution of a linear equation system by forwards substitution.
19
- [math.lsolveAll(L,&nbsp;b)](functions/lsolveAll.md) | Finds all solutions of a linear equation system by forwards substitution.
20
- [math.lup(A)](functions/lup.md) | Calculate the Matrix LU decomposition with partial pivoting.
21
- [math.lusolve(A,&nbsp;b)](functions/lusolve.md) | Solves the linear system `A * x = b` where `A` is an [n x n] matrix and `b` is a [n] column vector.
22
- [math.qr(A)](functions/qr.md) | Calculate the Matrix QR decomposition.
23
- [rationalize(expr)](functions/rationalize.md) | Transform a rationalizable expression in a rational fraction.
24
- [resolve(expr,&nbsp;scope)](functions/resolve.md) | resolve(expr, scope) replaces variable nodes with their scoped values.
25
- [simplify(expr)](functions/simplify.md) | Simplify an expression tree.
26
- [simplifyCore(expr)](functions/simplifyCore.md) | simplifyCore() performs single pass simplification suitable for applications requiring ultimate performance.
27
- [math.slu(A,&nbsp;order,&nbsp;threshold)](functions/slu.md) | Calculate the Sparse Matrix LU decomposition with full pivoting.
28
- [symbolicEqual(expr1,&nbsp;expr2)](functions/symbolicEqual.md) | Attempts to determine if two expressions are symbolically equal, i.
29
- [math.usolve(U,&nbsp;b)](functions/usolve.md) | Finds one solution of a linear equation system by backward substitution.
30
- [math.usolveAll(U,&nbsp;b)](functions/usolveAll.md) | Finds all solutions of a linear equation system by backward substitution.
31
-
32
- ## Arithmetic functions
33
-
34
- Function | Description
35
- ---- | -----------
36
- [math.abs(x)](functions/abs.md) | Calculate the absolute value of a number.
37
- [math.add(x,&nbsp;y)](functions/add.md) | Add two or more values, `x + y`.
38
- [math.cbrt(x&nbsp;[,&nbsp;allRoots])](functions/cbrt.md) | Calculate the cubic root of a value.
39
- [math.ceil(x)](functions/ceil.md) | Round a value towards plus infinity If `x` is complex, both real and imaginary part are rounded towards plus infinity.
40
- [math.cube(x)](functions/cube.md) | Compute the cube of a value, `x * x * x`.
41
- [math.divide(x,&nbsp;y)](functions/divide.md) | Divide two values, `x / y`.
42
- [math.dotDivide(x,&nbsp;y)](functions/dotDivide.md) | Divide two matrices element wise.
43
- [math.dotMultiply(x,&nbsp;y)](functions/dotMultiply.md) | Multiply two matrices element wise.
44
- [math.dotPow(x,&nbsp;y)](functions/dotPow.md) | Calculates the power of x to y element wise.
45
- [math.exp(x)](functions/exp.md) | Calculate the exponent of a value.
46
- [math.expm1(x)](functions/expm1.md) | Calculate the value of subtracting 1 from the exponential value.
47
- [math.fix(x)](functions/fix.md) | Round a value towards zero.
48
- [math.floor(x)](functions/floor.md) | Round a value towards minus infinity.
49
- [math.gcd(a,&nbsp;b)](functions/gcd.md) | Calculate the greatest common divisor for two or more values or arrays.
50
- [math.hypot(a,&nbsp;b,&nbsp;...)](functions/hypot.md) | Calculate the hypotenusa of a list with values.
51
- [math.invmod(a,&nbsp;b)](functions/invmod.md) | Calculate the (modular) multiplicative inverse of a modulo b.
52
- [math.lcm(a,&nbsp;b)](functions/lcm.md) | Calculate the least common multiple for two or more values or arrays.
53
- [math.log(x&nbsp;[,&nbsp;base])](functions/log.md) | Calculate the logarithm of a value.
54
- [math.log10(x)](functions/log10.md) | Calculate the 10-base logarithm of a value.
55
- [math.log1p(x)](functions/log1p.md) | Calculate the logarithm of a `value+1`.
56
- [math.log2(x)](functions/log2.md) | Calculate the 2-base of a value.
57
- [math.mod(x,&nbsp;y)](functions/mod.md) | Calculates the modulus, the remainder of an integer division.
58
- [math.multiply(x,&nbsp;y)](functions/multiply.md) | Multiply two or more values, `x * y`.
59
- [math.norm(x&nbsp;[,&nbsp;p])](functions/norm.md) | Calculate the norm of a number, vector or matrix.
60
- [math.nthRoot(a)](functions/nthRoot.md) | Calculate the nth root of a value.
61
- [math.nthRoots(x)](functions/nthRoots.md) | Calculate the nth roots of a value.
62
- [math.pow(x,&nbsp;y)](functions/pow.md) | Calculates the power of x to y, `x ^ y`.
63
- [math.round(x&nbsp;[,&nbsp;n])](functions/round.md) | Round a value towards the nearest integer.
64
- [math.sign(x)](functions/sign.md) | Compute the sign of a value.
65
- [math.sqrt(x)](functions/sqrt.md) | Calculate the square root of a value.
66
- [math.square(x)](functions/square.md) | Compute the square of a value, `x * x`.
67
- [math.subtract(x,&nbsp;y)](functions/subtract.md) | Subtract two values, `x - y`.
68
- [math.unaryMinus(x)](functions/unaryMinus.md) | Inverse the sign of a value, apply a unary minus operation.
69
- [math.unaryPlus(x)](functions/unaryPlus.md) | Unary plus operation.
70
- [math.xgcd(a,&nbsp;b)](functions/xgcd.md) | Calculate the extended greatest common divisor for two values.
71
-
72
- ## Bitwise functions
73
-
74
- Function | Description
75
- ---- | -----------
76
- [math.bitAnd(x,&nbsp;y)](functions/bitAnd.md) | Bitwise AND two values, `x & y`.
77
- [math.bitNot(x)](functions/bitNot.md) | Bitwise NOT value, `~x`.
78
- [math.bitOr(x,&nbsp;y)](functions/bitOr.md) | Bitwise OR two values, `x | y`.
79
- [math.bitXor(x,&nbsp;y)](functions/bitXor.md) | Bitwise XOR two values, `x ^ y`.
80
- [math.leftShift(x,&nbsp;y)](functions/leftShift.md) | Bitwise left logical shift of a value x by y number of bits, `x << y`.
81
- [math.rightArithShift(x,&nbsp;y)](functions/rightArithShift.md) | Bitwise right arithmetic shift of a value x by y number of bits, `x >> y`.
82
- [math.rightLogShift(x,&nbsp;y)](functions/rightLogShift.md) | Bitwise right logical shift of value x by y number of bits, `x >>> y`.
83
-
84
- ## Combinatorics functions
85
-
86
- Function | Description
87
- ---- | -----------
88
- [math.bellNumbers(n)](functions/bellNumbers.md) | The Bell Numbers count the number of partitions of a set.
89
- [math.catalan(n)](functions/catalan.md) | The Catalan Numbers enumerate combinatorial structures of many different types.
90
- [math.composition(n,&nbsp;k)](functions/composition.md) | The composition counts of n into k parts.
91
- [math.stirlingS2(n,&nbsp;k)](functions/stirlingS2.md) | The Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets.
92
-
93
- ## Complex functions
94
-
95
- Function | Description
96
- ---- | -----------
97
- [math.arg(x)](functions/arg.md) | Compute the argument of a complex value.
98
- [math.conj(x)](functions/conj.md) | Compute the complex conjugate of a complex value.
99
- [math.im(x)](functions/im.md) | Get the imaginary part of a complex number.
100
- [math.re(x)](functions/re.md) | Get the real part of a complex number.
101
-
102
- ## Geometry functions
103
-
104
- Function | Description
105
- ---- | -----------
106
- [math.distance([x1,&nbsp;y1],&nbsp;[x2,&nbsp;y2])](functions/distance.md) | Calculates: The eucledian distance between two points in N-dimensional spaces.
107
- [math.intersect(endPoint1Line1, endPoint2Line1, endPoint1Line2, endPoint2Line2)](functions/intersect.md) | Calculates the point of intersection of two lines in two or three dimensions and of a line and a plane in three dimensions.
108
-
109
- ## Logical functions
110
-
111
- Function | Description
112
- ---- | -----------
113
- [math.and(x,&nbsp;y)](functions/and.md) | Logical `and`.
114
- [math.not(x)](functions/not.md) | Logical `not`.
115
- [math.or(x,&nbsp;y)](functions/or.md) | Logical `or`.
116
- [math.xor(x,&nbsp;y)](functions/xor.md) | Logical `xor`.
117
-
118
- ## Matrix functions
119
-
120
- Function | Description
121
- ---- | -----------
122
- [math.apply(A,&nbsp;dim,&nbsp;callback)](functions/apply.md) | Apply a function that maps an array to a scalar along a given axis of a matrix or array.
123
- [math.column(value,&nbsp;index)](functions/column.md) | Return a column from a Matrix.
124
- [math.concat(a,&nbsp;b,&nbsp;c,&nbsp;...&nbsp;[,&nbsp;dim])](functions/concat.md) | Concatenate two or more matrices.
125
- [math.count(x)](functions/count.md) | Count the number of elements of a matrix, array or string.
126
- [math.cross(x,&nbsp;y)](functions/cross.md) | Calculate the cross product for two vectors in three dimensional space.
127
- [math.ctranspose(x)](functions/ctranspose.md) | Transpose and complex conjugate a matrix.
128
- [math.det(x)](functions/det.md) | Calculate the determinant of a matrix.
129
- [math.diag(X)](functions/diag.md) | Create a diagonal matrix or retrieve the diagonal of a matrix When `x` is a vector, a matrix with vector `x` on the diagonal will be returned.
130
- [math.diff(arr)](functions/diff.md) | Create a new matrix or array of the difference between elements of the given array The optional dim parameter lets you specify the dimension to evaluate the difference of If no dimension parameter is passed it is assumed as dimension 0 Dimension is zero-based in javascript and one-based in the parser and can be a number or bignumber Arrays must be 'rectangular' meaning arrays like [1, 2] If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays.
131
- [math.dot(x,&nbsp;y)](functions/dot.md) | Calculate the dot product of two vectors.
132
- [math.eigs(x,&nbsp;[prec])](functions/eigs.md) | Compute eigenvalues and eigenvectors of a matrix.
133
- [math.expm(x)](functions/expm.md) | Compute the matrix exponential, expm(A) = e^A.
134
- [math.filter(x,&nbsp;test)](functions/filter.md) | Filter the items in an array or one dimensional matrix.
135
- [math.flatten(x)](functions/flatten.md) | Flatten a multi dimensional matrix into a single dimensional matrix.
136
- [math.forEach(x,&nbsp;callback)](functions/forEach.md) | Iterate over all elements of a matrix/array, and executes the given callback function.
137
- [math.getMatrixDataType(x)](functions/getMatrixDataType.md) | Find the data type of all elements in a matrix or array, for example 'number' if all items are a number and 'Complex' if all values are complex numbers.
138
- [math.identity(n)](functions/identity.md) | Create a 2-dimensional identity matrix with size m x n or n x n.
139
- [math.inv(x)](functions/inv.md) | Calculate the inverse of a square matrix.
140
- [math.kron(x,&nbsp;y)](functions/kron.md) | Calculates the kronecker product of 2 matrices or vectors.
141
- [math.map(x,&nbsp;callback)](functions/map.md) | Create a new matrix or array with the results of a callback function executed on each entry of a given matrix/array.
142
- [math.matrixFromColumns(...arr)](functions/matrixFromColumns.md) | Create a dense matrix from vectors as individual columns.
143
- [math.matrixFromFunction(size,&nbsp;fn)](functions/matrixFromFunction.md) | Create a matrix by evaluating a generating function at each index.
144
- [math.matrixFromRows(...arr)](functions/matrixFromRows.md) | Create a dense matrix from vectors as individual rows.
145
- [math.ones(m,&nbsp;n,&nbsp;p,&nbsp;...)](functions/ones.md) | Create a matrix filled with ones.
146
- [math.partitionSelect(x,&nbsp;k)](functions/partitionSelect.md) | Partition-based selection of an array or 1D matrix.
147
- [math.pinv(x)](functions/pinv.md) | Calculate the Moore–Penrose inverse of a matrix.
148
- [math.range(start,&nbsp;end&nbsp;[,&nbsp;step])](functions/range.md) | Create an array from a range.
149
- [math.reshape(x,&nbsp;sizes)](functions/reshape.md) | Reshape a multi dimensional array to fit the specified dimensions.
150
- [math.resize(x,&nbsp;size&nbsp;[,&nbsp;defaultValue])](functions/resize.md) | Resize a matrix.
151
- [math.rotate(w,&nbsp;theta)](functions/rotate.md) | Rotate a vector of size 1x2 counter-clockwise by a given angle Rotate a vector of size 1x3 counter-clockwise by a given angle around the given axis.
152
- [math.rotationMatrix(theta)](functions/rotationMatrix.md) | Create a 2-dimensional counter-clockwise rotation matrix (2x2) for a given angle (expressed in radians).
153
- [math.row(value,&nbsp;index)](functions/row.md) | Return a row from a Matrix.
154
- [math.size(x)](functions/size.md) | Calculate the size of a matrix or scalar.
155
- [math.sort(x)](functions/sort.md) | Sort the items in a matrix.
156
- [X&nbsp;=&nbsp;math.sqrtm(A)](functions/sqrtm.md) | Calculate the principal square root of a square matrix.
157
- [math.squeeze(x)](functions/squeeze.md) | Squeeze a matrix, remove inner and outer singleton dimensions from a matrix.
158
- [math.subset(x,&nbsp;index&nbsp;[,&nbsp;replacement])](functions/subset.md) | Get or set a subset of a matrix or string.
159
- [math.trace(x)](functions/trace.md) | Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.
160
- [math.transpose(x)](functions/transpose.md) | Transpose a matrix.
161
- [math.zeros(m,&nbsp;n,&nbsp;p,&nbsp;...)](functions/zeros.md) | Create a matrix filled with zeros.
162
-
163
- ## Probability functions
164
-
165
- Function | Description
166
- ---- | -----------
167
- [math.combinations(n,&nbsp;k)](functions/combinations.md) | Compute the number of ways of picking `k` unordered outcomes from `n` possibilities.
168
- [math.combinationsWithRep(n,&nbsp;k)](functions/combinationsWithRep.md) | Compute the number of ways of picking `k` unordered outcomes from `n` possibilities, allowing individual outcomes to be repeated more than once.
169
- [math.factorial(n)](functions/factorial.md) | Compute the factorial of a value Factorial only supports an integer value as argument.
170
- [math.gamma(n)](functions/gamma.md) | Compute the gamma function of a value using Lanczos approximation for small values, and an extended Stirling approximation for large values.
171
- [math.kldivergence(x,&nbsp;y)](functions/kldivergence.md) | Calculate the Kullback-Leibler (KL) divergence between two distributions.
172
- [math.lgamma(n)](functions/lgamma.md) | Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.
173
- [math.multinomial(a)](functions/multinomial.md) | Multinomial Coefficients compute the number of ways of picking a1, a2, .
174
- [math.permutations(n&nbsp;[,&nbsp;k])](functions/permutations.md) | Compute the number of ways of obtaining an ordered subset of `k` elements from a set of `n` elements.
175
- [math.pickRandom(array)](functions/pickRandom.md) | Random pick one or more values from a one dimensional array.
176
- [math.random([min,&nbsp;max])](functions/random.md) | Return a random number larger or equal to `min` and smaller than `max` using a uniform distribution.
177
- [math.randomInt([min,&nbsp;max])](functions/randomInt.md) | Return a random integer number larger or equal to `min` and smaller than `max` using a uniform distribution.
178
-
179
- ## Relational functions
180
-
181
- Function | Description
182
- ---- | -----------
183
- [math.compare(x,&nbsp;y)](functions/compare.md) | Compare two values.
184
- [math.compareNatural(x,&nbsp;y)](functions/compareNatural.md) | Compare two values of any type in a deterministic, natural way.
185
- [math.compareText(x,&nbsp;y)](functions/compareText.md) | Compare two strings lexically.
186
- [math.deepEqual(x,&nbsp;y)](functions/deepEqual.md) | Test element wise whether two matrices are equal.
187
- [math.equal(x,&nbsp;y)](functions/equal.md) | Test whether two values are equal.
188
- [math.equalText(x,&nbsp;y)](functions/equalText.md) | Check equality of two strings.
189
- [math.larger(x,&nbsp;y)](functions/larger.md) | Test whether value x is larger than y.
190
- [math.largerEq(x,&nbsp;y)](functions/largerEq.md) | Test whether value x is larger or equal to y.
191
- [math.smaller(x,&nbsp;y)](functions/smaller.md) | Test whether value x is smaller than y.
192
- [math.smallerEq(x,&nbsp;y)](functions/smallerEq.md) | Test whether value x is smaller or equal to y.
193
- [math.unequal(x,&nbsp;y)](functions/unequal.md) | Test whether two values are unequal.
194
-
195
- ## Set functions
196
-
197
- Function | Description
198
- ---- | -----------
199
- [math.setCartesian(set1,&nbsp;set2)](functions/setCartesian.md) | Create the cartesian product of two (multi)sets.
200
- [math.setDifference(set1,&nbsp;set2)](functions/setDifference.md) | Create the difference of two (multi)sets: every element of set1, that is not the element of set2.
201
- [math.setDistinct(set)](functions/setDistinct.md) | Collect the distinct elements of a multiset.
202
- [math.setIntersect(set1,&nbsp;set2)](functions/setIntersect.md) | Create the intersection of two (multi)sets.
203
- [math.setIsSubset(set1,&nbsp;set2)](functions/setIsSubset.md) | Check whether a (multi)set is a subset of another (multi)set.
204
- [math.setMultiplicity(element,&nbsp;set)](functions/setMultiplicity.md) | Count the multiplicity of an element in a multiset.
205
- [math.setPowerset(set)](functions/setPowerset.md) | Create the powerset of a (multi)set.
206
- [math.setSize(set)](functions/setSize.md) | Count the number of elements of a (multi)set.
207
- [math.setSymDifference(set1,&nbsp;set2)](functions/setSymDifference.md) | Create the symmetric difference of two (multi)sets.
208
- [math.setUnion(set1,&nbsp;set2)](functions/setUnion.md) | Create the union of two (multi)sets.
209
-
210
- ## Special functions
211
-
212
- Function | Description
213
- ---- | -----------
214
- [math.erf(x)](functions/erf.md) | Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x.
215
-
216
- ## Statistics functions
217
-
218
- Function | Description
219
- ---- | -----------
220
- [math.cumsum(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/cumsum.md) | Compute the cumulative sum of a matrix or a list with values.
221
- [math.mad(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/mad.md) | Compute the median absolute deviation of a matrix or a list with values.
222
- [math.max(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/max.md) | Compute the maximum value of a matrix or a list with values.
223
- [math.mean(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/mean.md) | Compute the mean value of matrix or a list with values.
224
- [math.median(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/median.md) | Compute the median of a matrix or a list with values.
225
- [math.min(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/min.md) | Compute the minimum value of a matrix or a list of values.
226
- [math.mode(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/mode.md) | Computes the mode of a set of numbers or a list with values(numbers or characters).
227
- [math.prod(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/prod.md) | Compute the product of a matrix or a list with values.
228
- [math.quantileSeq(A,&nbsp;prob[,&nbsp;sorted])](functions/quantileSeq.md) | Compute the prob order quantile of a matrix or a list with values.
229
- [math.std(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/std.md) | Compute the standard deviation of a matrix or a list with values.
230
- [math.sum(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/sum.md) | Compute the sum of a matrix or a list with values.
231
- [math.variance(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/variance.md) | Compute the variance of a matrix or a list with values.
232
-
233
- ## String functions
234
-
235
- Function | Description
236
- ---- | -----------
237
- [math.bin(value)](functions/bin.md) | Format a number as binary.
238
- [math.format(value&nbsp;[,&nbsp;precision])](functions/format.md) | Format a value of any type into a string.
239
- [math.hex(value)](functions/hex.md) | Format a number as hexadecimal.
240
- [math.oct(value)](functions/oct.md) | Format a number as octal.
241
- [math.print(template, values [, precision])](functions/print.md) | Interpolate values into a string template.
242
-
243
- ## Trigonometry functions
244
-
245
- Function | Description
246
- ---- | -----------
247
- [math.acos(x)](functions/acos.md) | Calculate the inverse cosine of a value.
248
- [math.acosh(x)](functions/acosh.md) | Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.
249
- [math.acot(x)](functions/acot.md) | Calculate the inverse cotangent of a value, defined as `acot(x) = atan(1/x)`.
250
- [math.acoth(x)](functions/acoth.md) | Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = atanh(1/x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.
251
- [math.acsc(x)](functions/acsc.md) | Calculate the inverse cosecant of a value, defined as `acsc(x) = asin(1/x)`.
252
- [math.acsch(x)](functions/acsch.md) | Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = asinh(1/x) = ln(1/x + sqrt(1/x^2 + 1))`.
253
- [math.asec(x)](functions/asec.md) | Calculate the inverse secant of a value.
254
- [math.asech(x)](functions/asech.md) | Calculate the hyperbolic arcsecant of a value, defined as `asech(x) = acosh(1/x) = ln(sqrt(1/x^2 - 1) + 1/x)`.
255
- [math.asin(x)](functions/asin.md) | Calculate the inverse sine of a value.
256
- [math.asinh(x)](functions/asinh.md) | Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.
257
- [math.atan(x)](functions/atan.md) | Calculate the inverse tangent of a value.
258
- [math.atan2(y,&nbsp;x)](functions/atan2.md) | Calculate the inverse tangent function with two arguments, y/x.
259
- [math.atanh(x)](functions/atanh.md) | Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.
260
- [math.cos(x)](functions/cos.md) | Calculate the cosine of a value.
261
- [math.cosh(x)](functions/cosh.md) | Calculate the hyperbolic cosine of a value, defined as `cosh(x) = 1/2 * (exp(x) + exp(-x))`.
262
- [math.cot(x)](functions/cot.md) | Calculate the cotangent of a value.
263
- [math.coth(x)](functions/coth.md) | Calculate the hyperbolic cotangent of a value, defined as `coth(x) = 1 / tanh(x)`.
264
- [math.csc(x)](functions/csc.md) | Calculate the cosecant of a value, defined as `csc(x) = 1/sin(x)`.
265
- [math.csch(x)](functions/csch.md) | Calculate the hyperbolic cosecant of a value, defined as `csch(x) = 1 / sinh(x)`.
266
- [math.sec(x)](functions/sec.md) | Calculate the secant of a value, defined as `sec(x) = 1/cos(x)`.
267
- [math.sech(x)](functions/sech.md) | Calculate the hyperbolic secant of a value, defined as `sech(x) = 1 / cosh(x)`.
268
- [math.sin(x)](functions/sin.md) | Calculate the sine of a value.
269
- [math.sinh(x)](functions/sinh.md) | Calculate the hyperbolic sine of a value, defined as `sinh(x) = 1/2 * (exp(x) - exp(-x))`.
270
- [math.tan(x)](functions/tan.md) | Calculate the tangent of a value.
271
- [math.tanh(x)](functions/tanh.md) | Calculate the hyperbolic tangent of a value, defined as `tanh(x) = (exp(2 * x) - 1) / (exp(2 * x) + 1)`.
272
-
273
- ## Unit functions
274
-
275
- Function | Description
276
- ---- | -----------
277
- [math.to(x,&nbsp;unit)](functions/to.md) | Change the unit of a value.
278
-
279
- ## Utils functions
280
-
281
- Function | Description
282
- ---- | -----------
283
- [math.clone(x)](functions/clone.md) | Clone an object.
284
- [math.hasNumericValue(x)](functions/hasNumericValue.md) | Test whether a value is an numeric value.
285
- [math.isInteger(x)](functions/isInteger.md) | Test whether a value is an integer number.
286
- [math.isNaN(x)](functions/isNaN.md) | Test whether a value is NaN (not a number).
287
- [math.isNegative(x)](functions/isNegative.md) | Test whether a value is negative: smaller than zero.
288
- [math.isNumeric(x)](functions/isNumeric.md) | Test whether a value is an numeric value.
289
- [math.isPositive(x)](functions/isPositive.md) | Test whether a value is positive: larger than zero.
290
- [math.isPrime(x)](functions/isPrime.md) | Test whether a value is prime: has no divisors other than itself and one.
291
- [math.isZero(x)](functions/isZero.md) | Test whether a value is zero.
292
- [math.numeric(x)](functions/numeric.md) | Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.
293
- [math.typeOf(x)](functions/typeOf.md) | Determine the type of a variable.
294
-
295
-
296
-
297
- <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
@@ -1,5 +0,0 @@
1
- # Reference
2
-
3
- - [Classes](classes.md)
4
- - [Constants](constants.md)
5
- - [Functions](functions.md)
@@ -1,59 +0,0 @@
1
- // Convert from Fraction to BigNumber
2
- //
3
- // In the configuration of math.js one can specify the default number type to
4
- // be `number`, `BigNumber`, or `Fraction`. Not all functions support `Fraction`
5
- // or `BigNumber`, and if not supported these input types will be converted to
6
- // numbers.
7
- //
8
- // When `Fraction` is configured, one may want to fallback to `BigNumber`
9
- // instead of `number`. Also, one may want to be able to mix `Fraction` and
10
- // `BigNumber` in operations like summing them up. This can be achieved by
11
- // adding an extra conversion to the list of conversions as demonstrated in
12
- // this example.
13
-
14
- // Create an empty math.js instance, with only typed
15
- // (every instance contains `import` and `config` also out of the box)
16
- const { create, typedDependencies, all } = require('../..')
17
- const math = create({
18
- typedDependencies
19
- })
20
-
21
- // TODO: this should be much easier
22
- const allExceptLoaded = Object.keys(all)
23
- .map(key => all[key])
24
- .filter(factory => math[factory.fn] === undefined)
25
-
26
- // Configure to use fractions by default
27
- math.config({ number: 'Fraction' })
28
-
29
- // Add a conversion from Faction -> BigNumber
30
- // this conversion:
31
- // - must be inserted in the conversions list before the conversion Fraction -> number
32
- // - must be added to the conversions before loading functions into math.js
33
- math.typed.conversions.unshift({
34
- from: 'Fraction',
35
- to: 'BigNumber',
36
- convert: function (fraction) {
37
- return new math.BigNumber(fraction.n).div(fraction.d)
38
- }
39
- })
40
-
41
- // Import all data types, functions, constants, the expression parser, etc.
42
- math.import(allExceptLoaded)
43
-
44
- // Operators `add` and `divide` do have support for Fractions, so the result
45
- // will simply be a Fraction (default behavior of math.js).
46
- const ans1 = math.evaluate('1/3 + 1/4')
47
- console.log(math.typeOf(ans1), math.format(ans1))
48
- // outputs "Fraction 7/12"
49
-
50
- // Function sqrt doesn't have Fraction support, will now fall back to BigNumber
51
- // instead of number.
52
- const ans2 = math.evaluate('sqrt(4)')
53
- console.log(math.typeOf(ans2), math.format(ans2))
54
- // outputs "BigNumber 2"
55
-
56
- // We can now do operations with mixed Fractions and BigNumbers
57
- const ans3 = math.add(math.fraction(2, 5), math.bignumber(3))
58
- console.log(math.typeOf(ans3), math.format(ans3))
59
- // outputs "BigNumber 3.4"
@@ -1,98 +0,0 @@
1
- /**
2
- * The expression parser of math.js has support for letting functions
3
- * parse and evaluate arguments themselves, instead of calling them with
4
- * evaluated arguments.
5
- *
6
- * By adding a property `raw` with value true to a function, the function
7
- * will be invoked with unevaluated arguments, allowing the function
8
- * to process the arguments in a customized way.
9
- */
10
- const { create, all } = require('../..')
11
- const math = create(all)
12
-
13
- /**
14
- * Calculate the numeric integration of a function
15
- * @param {Function} f
16
- * @param {number} start
17
- * @param {number} end
18
- * @param {number} [step=0.01]
19
- */
20
- function integrate (f, start, end, step) {
21
- let total = 0
22
- step = step || 0.01
23
- for (let x = start; x < end; x += step) {
24
- total += f(x + step / 2) * step
25
- }
26
- return total
27
- }
28
-
29
- /**
30
- * A transformation for the integrate function. This transformation will be
31
- * invoked when the function is used via the expression parser of math.js.
32
- *
33
- * Syntax:
34
- *
35
- * integrate(integrand, variable, start, end)
36
- * integrate(integrand, variable, start, end, step)
37
- *
38
- * Usage:
39
- *
40
- * math.evaluate('integrate(2*x, x, 0, 2)')
41
- * math.evaluate('integrate(2*x, x, 0, 2, 0.01)')
42
- *
43
- * @param {Array.<math.Node>} args
44
- * Expects the following arguments: [f, x, start, end, step]
45
- * @param {Object} math
46
- * @param {Object} [scope]
47
- */
48
- integrate.transform = function (args, math, scope) {
49
- // determine the variable name
50
- if (!args[1].isSymbolNode) {
51
- throw new Error('Second argument must be a symbol')
52
- }
53
- const variable = args[1].name
54
-
55
- // evaluate start, end, and step
56
- const start = args[2].compile().evaluate(scope)
57
- const end = args[3].compile().evaluate(scope)
58
- const step = args[4] && args[4].compile().evaluate(scope) // step is optional
59
-
60
- // create a new scope, linked to the provided scope. We use this new scope
61
- // to apply the variable.
62
- const fnScope = Object.create(scope)
63
-
64
- // construct a function which evaluates the first parameter f after applying
65
- // a value for parameter x.
66
- const fnCode = args[0].compile()
67
- const f = function (x) {
68
- fnScope[variable] = x
69
- return fnCode.evaluate(fnScope)
70
- }
71
-
72
- // execute the integration
73
- return integrate(f, start, end, step)
74
- }
75
-
76
- // mark the transform function with a "rawArgs" property, so it will be called
77
- // with uncompiled, unevaluated arguments.
78
- integrate.transform.rawArgs = true
79
-
80
- // import the function into math.js. Raw functions must be imported in the
81
- // math namespace, they can't be used via `evaluate(scope)`.
82
- math.import({
83
- integrate: integrate
84
- })
85
-
86
- // use the function in JavaScript
87
- function f (x) {
88
- return math.pow(x, 0.5)
89
- }
90
- console.log(math.integrate(f, 0, 1)) // outputs 0.6667254718034714
91
-
92
- // use the function via the expression parser
93
- console.log(math.evaluate('integrate(x^0.5, x, 0, 1)')) // outputs 0.6667254718034714
94
-
95
- // use the function via the expression parser (2)
96
- const scope = {}
97
- math.evaluate('f(x) = 2 * x', scope)
98
- console.log(math.evaluate('integrate(f(x), x, 0, 2)', scope)) // outputs 4.000000000000003
@@ -1,56 +0,0 @@
1
- // This example demonstrates importing a custom data type,
2
- // and extending an existing function (add) with support for this data type.
3
-
4
- const { create, factory, all } = require('../..')
5
- const math = create(all)
6
-
7
- // factory function which defines a new data type CustomValue
8
- const createCustomValue = factory('CustomValue', ['typed'], ({ typed }) => {
9
- // create a new data type
10
- function CustomValue (value) {
11
- this.value = value
12
- }
13
- CustomValue.prototype.isCustomValue = true
14
- CustomValue.prototype.toString = function () {
15
- return 'CustomValue:' + this.value
16
- }
17
-
18
- // define a new data type with typed-function
19
- typed.addType({
20
- name: 'CustomValue',
21
- test: function (x) {
22
- // test whether x is of type CustomValue
23
- return x && x.isCustomValue === true
24
- }
25
- })
26
-
27
- return CustomValue
28
- })
29
-
30
- // function add which can add the CustomValue data type
31
- // When imported in math.js, the existing function `add` with support for
32
- // CustomValue, because both implementations are typed-functions and do not
33
- // have conflicting signatures.
34
- const createAddCustomValue = factory('add', ['typed', 'CustomValue'], ({ typed, CustomValue }) => {
35
- return typed('add', {
36
- 'CustomValue, CustomValue': function (a, b) {
37
- return new CustomValue(a.value + b.value)
38
- }
39
- })
40
- })
41
-
42
- // import the new data type and function
43
- math.import([
44
- createCustomValue,
45
- createAddCustomValue
46
- ])
47
-
48
- // use the new type
49
- const ans1 = math.add(new math.CustomValue(2), new math.CustomValue(3))
50
- console.log(ans1.toString())
51
- // outputs 'CustomValue:5'
52
-
53
- // you can automatically use the new type in functions which use `add` under the hood:
54
- const ans2 = math.sum(new math.CustomValue(6), new math.CustomValue(1), new math.CustomValue(2))
55
- console.log(ans2.toString())
56
- // outputs 'CustomValue:9'
@@ -1,19 +0,0 @@
1
- const { create, evaluateDependencies, factory } = require('../..')
2
-
3
- // custom implementations of all functions you want to support
4
- const add = (a, b) => a + b
5
- const subtract = (a, b) => a - b
6
- const multiply = (a, b) => a * b
7
- const divide = (a, b) => a / b
8
-
9
- // create factories for the functions, and create an evaluate function with those
10
- // these functions will also be used by the classes like Unit.
11
- const { evaluate } = create({
12
- evaluateDependencies,
13
- createAdd: factory('add', [], () => add),
14
- createSubtract: factory('subtract', [], () => subtract),
15
- createMultiply: factory('multiply', [], () => multiply),
16
- createDivide: factory('divide', [], () => divide)
17
- })
18
-
19
- console.log(evaluate('2 + 3 * 4')) // 14
@@ -1,18 +0,0 @@
1
- const { create, evaluateDependencies } = require('../..')
2
-
3
- // custom implementations of all functions you want to support
4
- const add = (a, b) => a + b
5
- const subtract = (a, b) => a - b
6
- const multiply = (a, b) => a * b
7
- const divide = (a, b) => a / b
8
-
9
- // create a mathjs instance with hardly any functions
10
- // there are some functions created which are used internally by evaluate though,
11
- // for example by the Unit class which has dependencies on addScalar, subtract,
12
- // multiplyScalar, etc.
13
- const math = create(evaluateDependencies)
14
-
15
- // import your own functions
16
- math.import({ add, subtract, multiply, divide }, { override: true })
17
-
18
- console.log(math.evaluate('2 + 3 * 4')) // 14
@@ -1,33 +0,0 @@
1
- import {
2
- create,
3
- fractionDependencies,
4
- addDependencies,
5
- divideDependencies,
6
- formatDependencies
7
- } from '../..'
8
-
9
- const config = {
10
- // optionally, you can specify configuration
11
- }
12
-
13
- // Create just the functions we need
14
- const { fraction, add, divide, format } = create({
15
- fractionDependencies,
16
- addDependencies,
17
- divideDependencies,
18
- formatDependencies
19
- }, config)
20
-
21
- // Use the created functions
22
- const a = fraction(1, 3)
23
- const b = fraction(3, 7)
24
- const c = add(a, b)
25
- const d = divide(a, b)
26
- console.log('c =', format(c)) // outputs "c = 16/21"
27
- console.log('d =', format(d)) // outputs "d = 7/9"
28
-
29
- // Now, when bundling your application for use in the browser, only the used
30
- // parts of math.js will be bundled. For example to create a bundle using Webpack:
31
- //
32
- // npx webpack custom_loading.js -o custom_loading.bundle.js --mode=production
33
- //