nerdamer 1.1.13 → 2.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (387) hide show
  1. package/BREAKING_CHANGES.md +244 -5
  2. package/LICENSE.md +184 -0
  3. package/README.md +232 -318
  4. package/dist/bundle.js +2 -0
  5. package/dist/bundle.js.LICENSE.txt +7 -0
  6. package/dist/parser.js +2 -0
  7. package/dist/parser.js.LICENSE.txt +7 -0
  8. package/docs-data/parser-functions.json +2248 -0
  9. package/index.d.ts +10 -426
  10. package/output/algebra/adapters.d.ts +3 -0
  11. package/output/algebra/adapters.js +11 -0
  12. package/output/algebra/algorithms/arith.d.ts +84 -0
  13. package/output/algebra/algorithms/arith.js +324 -0
  14. package/output/algebra/algorithms/groebnerBase.d.ts +161 -0
  15. package/output/algebra/algorithms/groebnerBase.js +929 -0
  16. package/output/algebra/dispatch.d.ts +1 -0
  17. package/output/algebra/dispatch.js +25 -0
  18. package/output/algebra/factor/factor.d.ts +77 -0
  19. package/output/algebra/factor/factor.js +245 -0
  20. package/output/algebra/gcd/gcd.d.ts +30 -0
  21. package/output/algebra/gcd/gcd.js +95 -0
  22. package/output/algebra/groebner.d.ts +21 -0
  23. package/output/algebra/groebner.js +36 -0
  24. package/output/algebra/partfrac.d.ts +19 -0
  25. package/output/algebra/partfrac.js +365 -0
  26. package/output/algebra/polynomial/ModularSparsePolynomial.d.ts +131 -0
  27. package/output/algebra/polynomial/ModularSparsePolynomial.js +378 -0
  28. package/output/algebra/polynomial/ModularSparsePolynomialFactor.d.ts +40 -0
  29. package/output/algebra/polynomial/ModularSparsePolynomialFactor.js +661 -0
  30. package/output/algebra/polynomial/SparsePolynomialFactor.d.ts +64 -0
  31. package/output/algebra/polynomial/SparsePolynomialFactor.js +492 -0
  32. package/output/algebra/polynomial/SparsePolynomialGcd.d.ts +29 -0
  33. package/output/algebra/polynomial/SparsePolynomialGcd.js +259 -0
  34. package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.d.ts +82 -0
  35. package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.js +604 -0
  36. package/output/algebra/polynomial/modularGcd.d.ts +40 -0
  37. package/output/algebra/polynomial/modularGcd.js +365 -0
  38. package/output/algebra/polynomialize.d.ts +20 -0
  39. package/output/algebra/polynomialize.js +26 -0
  40. package/output/algebra/simplify/complexsimp.d.ts +7 -0
  41. package/output/algebra/simplify/complexsimp.js +24 -0
  42. package/output/algebra/simplify/factorCommon.d.ts +13 -0
  43. package/output/algebra/simplify/factorCommon.js +136 -0
  44. package/output/algebra/simplify/funcsimp.d.ts +26 -0
  45. package/output/algebra/simplify/funcsimp.js +633 -0
  46. package/output/algebra/simplify/invtrigrewrite.d.ts +10 -0
  47. package/output/algebra/simplify/invtrigrewrite.js +96 -0
  48. package/output/algebra/simplify/ratsimp.d.ts +21 -0
  49. package/output/algebra/simplify/ratsimp.js +140 -0
  50. package/output/algebra/simplify/simplify.d.ts +25 -0
  51. package/output/algebra/simplify/simplify.js +237 -0
  52. package/output/algebra/simplify/trigreduce.d.ts +38 -0
  53. package/output/algebra/simplify/trigreduce.js +424 -0
  54. package/output/algebra/simplify/trigrewrite.d.ts +17 -0
  55. package/output/algebra/simplify/trigrewrite.js +156 -0
  56. package/output/algebra/simplify/trigsimp.d.ts +11 -0
  57. package/output/algebra/simplify/trigsimp.js +369 -0
  58. package/output/algebra/simplify/utils.d.ts +32 -0
  59. package/output/algebra/simplify/utils.js +56 -0
  60. package/output/algebra/utils.d.ts +32 -0
  61. package/output/algebra/utils.js +48 -0
  62. package/output/api/advanced.d.ts +8 -0
  63. package/output/api/advanced.js +18 -0
  64. package/output/api/algebra.d.ts +17 -0
  65. package/output/api/algebra.js +35 -0
  66. package/output/api/assumptions.d.ts +4 -0
  67. package/output/api/assumptions.js +11 -0
  68. package/output/api/calculus.d.ts +10 -0
  69. package/output/api/calculus.js +22 -0
  70. package/output/api/core.d.ts +17 -0
  71. package/output/api/core.js +41 -0
  72. package/output/api/debug.d.ts +16 -0
  73. package/output/api/debug.js +23 -0
  74. package/output/api/languages/deu.d.ts +3 -0
  75. package/output/api/languages/deu.js +266 -0
  76. package/output/api/languages/fra.d.ts +3 -0
  77. package/output/api/languages/fra.js +266 -0
  78. package/output/api/languages/ita.d.ts +3 -0
  79. package/output/api/languages/ita.js +266 -0
  80. package/output/api/languages/nld.d.ts +3 -0
  81. package/output/api/languages/nld.js +266 -0
  82. package/output/api/languages/por.d.ts +3 -0
  83. package/output/api/languages/por.js +266 -0
  84. package/output/api/languages/spa.d.ts +3 -0
  85. package/output/api/languages/spa.js +266 -0
  86. package/output/api/parser.d.ts +93 -0
  87. package/output/api/parser.js +18 -0
  88. package/output/api/solve.d.ts +10 -0
  89. package/output/api/solve.js +17 -0
  90. package/output/api/structures.d.ts +10 -0
  91. package/output/api/structures.js +23 -0
  92. package/output/calculus/adapters.d.ts +8 -0
  93. package/output/calculus/adapters.js +41 -0
  94. package/output/calculus/derivative/diff.d.ts +30 -0
  95. package/output/calculus/derivative/diff.js +241 -0
  96. package/output/calculus/dispatch.d.ts +1 -0
  97. package/output/calculus/dispatch.js +25 -0
  98. package/output/calculus/fresnel.d.ts +16 -0
  99. package/output/calculus/fresnel.js +39 -0
  100. package/output/calculus/integrate/byParts.d.ts +18 -0
  101. package/output/calculus/integrate/byParts.js +339 -0
  102. package/output/calculus/integrate/bySubstitution.d.ts +135 -0
  103. package/output/calculus/integrate/bySubstitution.js +411 -0
  104. package/output/calculus/integrate/integrate.d.ts +38 -0
  105. package/output/calculus/integrate/integrate.js +652 -0
  106. package/output/calculus/integrate/integrationTable.d.ts +2 -0
  107. package/output/calculus/integrate/integrationTable.js +914 -0
  108. package/output/calculus/integrate/utils.d.ts +28 -0
  109. package/output/calculus/integrate/utils.js +96 -0
  110. package/output/calculus/laplace/ilaplace.d.ts +31 -0
  111. package/output/calculus/laplace/ilaplace.js +192 -0
  112. package/output/calculus/laplace/ilaplaceTable.d.ts +2 -0
  113. package/output/calculus/laplace/ilaplaceTable.js +200 -0
  114. package/output/calculus/laplace/laplace.d.ts +22 -0
  115. package/output/calculus/laplace/laplace.js +109 -0
  116. package/output/calculus/laplace/laplaceTable.d.ts +2 -0
  117. package/output/calculus/laplace/laplaceTable.js +187 -0
  118. package/output/calculus/limit/limit.d.ts +35 -0
  119. package/output/calculus/limit/limit.js +1183 -0
  120. package/output/calculus/limit/limitsTable.d.ts +2 -0
  121. package/output/calculus/limit/limitsTable.js +7 -0
  122. package/output/core/Settings.d.ts +32 -0
  123. package/output/core/Settings.js +68 -0
  124. package/output/core/classes/assumption/Assumption.d.ts +218 -0
  125. package/output/core/classes/assumption/Assumption.js +609 -0
  126. package/output/core/classes/assumption/assertiveFunctions.d.ts +6 -0
  127. package/output/core/classes/assumption/assertiveFunctions.js +64 -0
  128. package/output/core/classes/assumption/assume.d.ts +90 -0
  129. package/output/core/classes/assumption/assume.js +145 -0
  130. package/output/core/classes/assumption/dispatch.d.ts +1 -0
  131. package/output/core/classes/assumption/dispatch.js +11 -0
  132. package/output/core/classes/collection/Collection.d.ts +107 -0
  133. package/output/core/classes/collection/Collection.js +240 -0
  134. package/output/core/classes/complex/Complex.d.ts +109 -0
  135. package/output/core/classes/complex/Complex.js +153 -0
  136. package/output/core/classes/decimalSet/DecimalSet.d.ts +226 -0
  137. package/output/core/classes/decimalSet/DecimalSet.js +454 -0
  138. package/output/core/classes/dictionary/Dictionary.d.ts +102 -0
  139. package/output/core/classes/dictionary/Dictionary.js +216 -0
  140. package/output/core/classes/equation/Equation.d.ts +256 -0
  141. package/output/core/classes/equation/Equation.js +350 -0
  142. package/output/core/classes/expression/CoeffObject.d.ts +100 -0
  143. package/output/core/classes/expression/CoeffObject.js +197 -0
  144. package/output/core/classes/expression/Expression.d.ts +1691 -0
  145. package/output/core/classes/expression/Expression.js +2381 -0
  146. package/output/core/classes/expression/analysis.d.ts +25 -0
  147. package/output/core/classes/expression/analysis.js +218 -0
  148. package/output/core/classes/expression/collect.d.ts +9 -0
  149. package/output/core/classes/expression/collect.js +49 -0
  150. package/output/core/classes/expression/format.d.ts +54 -0
  151. package/output/core/classes/expression/format.js +340 -0
  152. package/output/core/classes/expression/products.d.ts +23 -0
  153. package/output/core/classes/expression/products.js +115 -0
  154. package/output/core/classes/expression/shortcuts.d.ts +35 -0
  155. package/output/core/classes/expression/shortcuts.js +129 -0
  156. package/output/core/classes/expression/traversal.d.ts +31 -0
  157. package/output/core/classes/expression/traversal.js +216 -0
  158. package/output/core/classes/expression/trig.d.ts +25 -0
  159. package/output/core/classes/expression/trig.js +40 -0
  160. package/output/core/classes/expression/utils.d.ts +61 -0
  161. package/output/core/classes/expression/utils.js +235 -0
  162. package/output/core/classes/lookupTable/LookupTable.d.ts +12 -0
  163. package/output/core/classes/lookupTable/LookupTable.js +55 -0
  164. package/output/core/classes/matrix/Matrix.d.ts +227 -0
  165. package/output/core/classes/matrix/Matrix.js +901 -0
  166. package/output/core/classes/matrix/Sylvester.d.ts +11 -0
  167. package/output/core/classes/matrix/Sylvester.js +54 -0
  168. package/output/core/classes/matrix/dispatch.d.ts +1 -0
  169. package/output/core/classes/matrix/dispatch.js +19 -0
  170. package/output/core/classes/matrix/functions.d.ts +28 -0
  171. package/output/core/classes/matrix/functions.js +57 -0
  172. package/output/core/classes/matrix/utils.d.ts +9 -0
  173. package/output/core/classes/matrix/utils.js +22 -0
  174. package/output/core/classes/parser/Parser.d.ts +493 -0
  175. package/output/core/classes/parser/Parser.js +1863 -0
  176. package/output/core/classes/parser/Token.d.ts +58 -0
  177. package/output/core/classes/parser/Token.js +137 -0
  178. package/output/core/classes/parser/constants.d.ts +162 -0
  179. package/output/core/classes/parser/constants.js +229 -0
  180. package/output/core/classes/parser/controlFlowSignals.d.ts +38 -0
  181. package/output/core/classes/parser/controlFlowSignals.js +60 -0
  182. package/output/core/classes/parser/helpers.d.ts +21 -0
  183. package/output/core/classes/parser/helpers.js +42 -0
  184. package/output/core/classes/parser/operations/add.d.ts +15 -0
  185. package/output/core/classes/parser/operations/add.js +236 -0
  186. package/output/core/classes/parser/operations/comma.d.ts +7 -0
  187. package/output/core/classes/parser/operations/comma.js +11 -0
  188. package/output/core/classes/parser/operations/compare.d.ts +21 -0
  189. package/output/core/classes/parser/operations/compare.js +474 -0
  190. package/output/core/classes/parser/operations/divide.d.ts +2 -0
  191. package/output/core/classes/parser/operations/divide.js +72 -0
  192. package/output/core/classes/parser/operations/functions.d.ts +46 -0
  193. package/output/core/classes/parser/operations/functions.js +438 -0
  194. package/output/core/classes/parser/operations/multiply.d.ts +11 -0
  195. package/output/core/classes/parser/operations/multiply.js +328 -0
  196. package/output/core/classes/parser/operations/power.d.ts +48 -0
  197. package/output/core/classes/parser/operations/power.js +673 -0
  198. package/output/core/classes/parser/operations/subtract.d.ts +3 -0
  199. package/output/core/classes/parser/operations/subtract.js +36 -0
  200. package/output/core/classes/parser/preprocess.d.ts +7 -0
  201. package/output/core/classes/parser/preprocess.js +246 -0
  202. package/output/core/classes/parser/scripting/controlFlow.d.ts +23 -0
  203. package/output/core/classes/parser/scripting/controlFlow.js +279 -0
  204. package/output/core/classes/parser/scripting/deferred.d.ts +4 -0
  205. package/output/core/classes/parser/scripting/deferred.js +65 -0
  206. package/output/core/classes/parser/scripting/dispatch.d.ts +1 -0
  207. package/output/core/classes/parser/scripting/dispatch.js +62 -0
  208. package/output/core/classes/parser/scripting/evaluate.d.ts +23 -0
  209. package/output/core/classes/parser/scripting/evaluate.js +128 -0
  210. package/output/core/classes/parser/scripting/functions.d.ts +14 -0
  211. package/output/core/classes/parser/scripting/functions.js +59 -0
  212. package/output/core/classes/parser/scripting/scope.d.ts +8 -0
  213. package/output/core/classes/parser/scripting/scope.js +132 -0
  214. package/output/core/classes/parser/types.d.ts +130 -0
  215. package/output/core/classes/parser/types.js +2 -0
  216. package/output/core/classes/parser/wrappers/IndexedReference.d.ts +31 -0
  217. package/output/core/classes/parser/wrappers/IndexedReference.js +68 -0
  218. package/output/core/classes/parser/wrappers/KeyValuePair.d.ts +24 -0
  219. package/output/core/classes/parser/wrappers/KeyValuePair.js +51 -0
  220. package/output/core/classes/polynomial/Polynomial.d.ts +504 -0
  221. package/output/core/classes/polynomial/Polynomial.js +1195 -0
  222. package/output/core/classes/polynomial/SparsePolynomial.d.ts +221 -0
  223. package/output/core/classes/polynomial/SparsePolynomial.js +824 -0
  224. package/output/core/classes/polynomial/SparsePolynomialAdapter.d.ts +56 -0
  225. package/output/core/classes/polynomial/SparsePolynomialAdapter.js +241 -0
  226. package/output/core/classes/polynomial/Term.d.ts +222 -0
  227. package/output/core/classes/polynomial/Term.js +430 -0
  228. package/output/core/classes/polynomial/adapters.d.ts +18 -0
  229. package/output/core/classes/polynomial/adapters.js +33 -0
  230. package/output/core/classes/polynomial/dispatch.d.ts +1 -0
  231. package/output/core/classes/polynomial/dispatch.js +14 -0
  232. package/output/core/classes/polynomial/functions.d.ts +77 -0
  233. package/output/core/classes/polynomial/functions.js +189 -0
  234. package/output/core/classes/polynomial/utils.d.ts +62 -0
  235. package/output/core/classes/polynomial/utils.js +207 -0
  236. package/output/core/classes/rational/Rational.d.ts +501 -0
  237. package/output/core/classes/rational/Rational.js +829 -0
  238. package/output/core/classes/seq/SEQ.d.ts +13 -0
  239. package/output/core/classes/seq/SEQ.js +137 -0
  240. package/output/core/classes/valuesSet/ValuesSet.d.ts +187 -0
  241. package/output/core/classes/valuesSet/ValuesSet.js +399 -0
  242. package/output/core/classes/vector/Vector.d.ts +222 -0
  243. package/output/core/classes/vector/Vector.js +501 -0
  244. package/output/core/classes/vector/dispatch.d.ts +1 -0
  245. package/output/core/classes/vector/dispatch.js +11 -0
  246. package/output/core/classes/vector/functions.d.ts +28 -0
  247. package/output/core/classes/vector/functions.js +47 -0
  248. package/output/core/common/classes/MathematicalAggregate.d.ts +53 -0
  249. package/output/core/common/classes/MathematicalAggregate.js +149 -0
  250. package/output/core/common/classes/Scope.d.ts +62 -0
  251. package/output/core/common/classes/Scope.js +122 -0
  252. package/output/core/common/classes/StructuredEntity.d.ts +55 -0
  253. package/output/core/common/classes/StructuredEntity.js +151 -0
  254. package/output/core/common/common.d.ts +62 -0
  255. package/output/core/common/common.js +74 -0
  256. package/output/core/common/functions/functions.d.ts +14 -0
  257. package/output/core/common/functions/functions.js +33 -0
  258. package/output/core/common/functions/structuredEntityUtils.d.ts +27 -0
  259. package/output/core/common/functions/structuredEntityUtils.js +40 -0
  260. package/output/core/converters/BaseConverter.d.ts +97 -0
  261. package/output/core/converters/BaseConverter.js +405 -0
  262. package/output/core/converters/Converter.d.ts +111 -0
  263. package/output/core/converters/Converter.js +806 -0
  264. package/output/core/converters/Pattern.d.ts +71 -0
  265. package/output/core/converters/Pattern.js +302 -0
  266. package/output/core/dispatch.d.ts +52 -0
  267. package/output/core/dispatch.js +26 -0
  268. package/output/core/errors.d.ts +316 -0
  269. package/output/core/errors.js +349 -0
  270. package/output/core/fullFunctions.d.ts +7 -0
  271. package/output/core/fullFunctions.js +31 -0
  272. package/output/core/functions/bigint/bigint.d.ts +133 -0
  273. package/output/core/functions/bigint/bigint.js +444 -0
  274. package/output/core/functions/bigint/primeFactor.d.ts +51 -0
  275. package/output/core/functions/bigint/primeFactor.js +267 -0
  276. package/output/core/functions/bigint/primes.d.ts +1 -0
  277. package/output/core/functions/bigint/primes.js +11 -0
  278. package/output/core/functions/build/definitions.d.ts +12 -0
  279. package/output/core/functions/build/definitions.js +139 -0
  280. package/output/core/functions/build/index.d.ts +32 -0
  281. package/output/core/functions/build/index.js +136 -0
  282. package/output/core/functions/complex.d.ts +90 -0
  283. package/output/core/functions/complex.dispatch.d.ts +1 -0
  284. package/output/core/functions/complex.dispatch.js +16 -0
  285. package/output/core/functions/complex.js +482 -0
  286. package/output/core/functions/decimal.d.ts +24 -0
  287. package/output/core/functions/decimal.js +665 -0
  288. package/output/core/functions/expand/expand.d.ts +42 -0
  289. package/output/core/functions/expand/expand.js +376 -0
  290. package/output/core/functions/fresnelNumeric.d.ts +12 -0
  291. package/output/core/functions/fresnelNumeric.js +123 -0
  292. package/output/core/functions/numeric.d.ts +140 -0
  293. package/output/core/functions/numeric.js +790 -0
  294. package/output/core/functions/rationalNormalization.d.ts +11 -0
  295. package/output/core/functions/rationalNormalization.js +117 -0
  296. package/output/core/functions/setFunction.d.ts +19 -0
  297. package/output/core/functions/setFunction.js +75 -0
  298. package/output/core/functions/string.d.ts +26 -0
  299. package/output/core/functions/string.js +102 -0
  300. package/output/core/functions/subst.d.ts +90 -0
  301. package/output/core/functions/subst.js +506 -0
  302. package/output/core/functions/utils.d.ts +24 -0
  303. package/output/core/functions/utils.js +51 -0
  304. package/output/core/parserFunctions.d.ts +7 -0
  305. package/output/core/parserFunctions.js +25 -0
  306. package/output/core/types.d.ts +48 -0
  307. package/output/core/types.js +2 -0
  308. package/output/index.d.ts +359 -0
  309. package/output/index.js +739 -0
  310. package/output/math/defint/defint.d.ts +18 -0
  311. package/output/math/defint/defint.js +60 -0
  312. package/output/math/defint/defintDecimal.d.ts +37 -0
  313. package/output/math/defint/defintDecimal.js +321 -0
  314. package/output/math/defint/defintNative.d.ts +57 -0
  315. package/output/math/defint/defintNative.js +281 -0
  316. package/output/math/dispatch.d.ts +1 -0
  317. package/output/math/dispatch.js +101 -0
  318. package/output/math/geometry.d.ts +12 -0
  319. package/output/math/geometry.js +55 -0
  320. package/output/math/math.d.ts +695 -0
  321. package/output/math/math.js +1955 -0
  322. package/output/math/trig.d.ts +518 -0
  323. package/output/math/trig.js +1444 -0
  324. package/output/math/trunc.d.ts +19 -0
  325. package/output/math/trunc.js +36 -0
  326. package/output/math/utils.d.ts +66 -0
  327. package/output/math/utils.js +219 -0
  328. package/output/solve/classes/DecimalMatrix.d.ts +17 -0
  329. package/output/solve/classes/DecimalMatrix.js +86 -0
  330. package/output/solve/classes/FunctionSolver.d.ts +135 -0
  331. package/output/solve/classes/FunctionSolver.js +433 -0
  332. package/output/solve/classes/MultivariateSolver.d.ts +84 -0
  333. package/output/solve/classes/MultivariateSolver.js +240 -0
  334. package/output/solve/classes/PolynomialSolver.d.ts +104 -0
  335. package/output/solve/classes/PolynomialSolver.js +492 -0
  336. package/output/solve/classes/SolutionSet.d.ts +172 -0
  337. package/output/solve/classes/SolutionSet.js +434 -0
  338. package/output/solve/classes/Solver.d.ts +17 -0
  339. package/output/solve/classes/Solver.js +132 -0
  340. package/output/solve/classes/SymbolicSolver.d.ts +74 -0
  341. package/output/solve/classes/SymbolicSolver.js +601 -0
  342. package/output/solve/dispatch.d.ts +1 -0
  343. package/output/solve/dispatch.js +13 -0
  344. package/output/solve/linsolve.d.ts +53 -0
  345. package/output/solve/linsolve.js +233 -0
  346. package/output/solve/solve.d.ts +44 -0
  347. package/output/solve/solve.js +368 -0
  348. package/output/solve/solveSystem.d.ts +31 -0
  349. package/output/solve/solveSystem.js +266 -0
  350. package/output/solve/utils.d.ts +10 -0
  351. package/output/solve/utils.js +58 -0
  352. package/output/utils/array.d.ts +42 -0
  353. package/output/utils/array.js +98 -0
  354. package/output/utils/debug.d.ts +131 -0
  355. package/output/utils/debug.js +296 -0
  356. package/output/utils/decimal.d.ts +3 -0
  357. package/output/utils/decimal.js +16 -0
  358. package/output/utils/numeric.d.ts +14 -0
  359. package/output/utils/numeric.js +51 -0
  360. package/output/utils/object.d.ts +26 -0
  361. package/output/utils/object.js +56 -0
  362. package/package.json +178 -57
  363. package/.travis.yml +0 -3
  364. package/Algebra.js +0 -4568
  365. package/CODE_OF_CONDUCT.md +0 -46
  366. package/CONTRIBUTING.md +0 -14
  367. package/Calculus.js +0 -2675
  368. package/Extra.js +0 -622
  369. package/Solve.js +0 -1783
  370. package/all.js +0 -16
  371. package/all.min.js +0 -1
  372. package/gulpfile.js +0 -16
  373. package/index.html +0 -158
  374. package/license.txt +0 -19
  375. package/nerdamer.core.js +0 -12510
  376. package/spec/LaTeX.spec.js +0 -302
  377. package/spec/TeXConvert.spec.js +0 -8
  378. package/spec/algebra.spec.js +0 -287
  379. package/spec/basic_parser.spec.js +0 -134
  380. package/spec/build.spec.js +0 -131
  381. package/spec/calculus.spec.js +0 -183
  382. package/spec/core.spec.js +0 -2970
  383. package/spec/extra.spec.js +0 -54
  384. package/spec/solve.spec.js +0 -126
  385. package/spec/support/jasmine.json +0 -11
  386. package/spec/support/utils.js +0 -42
  387. package/spec/text.spec.js +0 -132
package/README.md CHANGED
@@ -1,427 +1,341 @@
1
- [![Build Status](https://travis-ci.org/jiggzson/nerdamer.svg?branch=master)](https://travis-ci.org/jiggzson/nerdamer)
1
+ # Nerdamer
2
2
 
3
- Nerdamer
4
- ========
3
+ Nerdamer is a symbolic mathematics library and computer algebra system for JavaScript and TypeScript.
5
4
 
6
- As of version 0.5.0, the library is split into the core and optional add-ons which can be loaded after the core has been loaded.
5
+ Nerdamer 2.0 is a TypeScript rewrite of Nerdamer. The familiar string-based API remains available, while the package also exposes typed modules for direct use of the symbolic engine, algebra, calculus, solving, structures, assumptions, parser APIs, and advanced algorithms.
7
6
 
8
- Getting started with Nerdamer
7
+ This branch prepares `2.0.0-rc.2`.
9
8
 
10
- Load the library in your html page
9
+ ## Install
11
10
 
12
- ```html
13
- <!-- assuming you've saved the file in the root of course -->
14
- <!-- This the core and the only file needed if all you'll be doing is evaluating expresssions -->
15
- <script src="nerdamer.core.js"></script>
16
- <!-- LOAD ADD-ONS. These files contain extended functions. See documentation -->
17
- <!-- again assuming you've saved the files in root -->
18
- <script src="Algebra.js"></script>
19
- <script src="Calculus.js"></script>
20
- <script src="Solve.js"></script>
21
- <script src="Extra.js"></script>
22
- ```
23
- Or import everything
24
- ```html
25
- <script src="all.min.js"></script> <!-- assuming you've saved the file in the root -->
11
+ ```bash
12
+ npm install nerdamer@next
26
13
  ```
27
- If you're using node.js install it using `npm i nerdamer` and then
14
+
15
+ The release candidate is published under npm's `next` tag until the final 2.0 release.
16
+
17
+ ## Quick start
28
18
 
29
19
  ```javascript
30
- // const cannot be used since nerdamer gets modified when other modules are loaded
31
- var nerdamer = require('nerdamer');
32
- // Load additional modules. These are not required.
33
- require('nerdamer/Algebra');
34
- require('nerdamer/Calculus');
35
- require('nerdamer/Solve');
36
- require('nerdamer/Extra');
37
- ```
38
- Or do a single import to import everything
39
- ```javascript
40
- const nerdamer = require("nerdamer/all.min")
20
+ const nerdamer = require('nerdamer');
21
+
22
+ const expression = nerdamer('x^2+2*(cos(x)+x*x)');
23
+ console.log(expression.text());
24
+ // 2*cos(x)+3*x^2
41
25
  ```
42
26
 
43
- Some functions have dependencies from other add-ons.
27
+ TypeScript:
44
28
 
45
- You can see nerdamer in action at http://nerdamer.com/demo
29
+ ```typescript
30
+ import nerdamer from 'nerdamer';
46
31
 
47
- For full documentation go to http://nerdamer.com/documentation
32
+ const expression = nerdamer('(x+1)^3').expand();
33
+ console.log(expression.text({ sort: true }));
34
+ // x^3+3*x^2+3*x+1
35
+ ```
48
36
 
49
- All operations are done using the 'nerdamer' object.
37
+ TypeScript projects compiling to CommonJS should enable `esModuleInterop`.
50
38
 
51
- To add an expression just add it to the nerdamer object which will return a `Expression` object.
39
+ ## Full package and parser package
52
40
 
53
- ```javascript
54
- var e = nerdamer('x^2+2*(cos(x)+x*x)');
55
- console.log(e.text());
41
+ The normal `nerdamer` entry point assembles the complete CAS. It registers the parser/core and math functions together with algebra, calculus, and solving.
56
42
 
57
- //result:
58
- //2*cos(x)+3*x^2
59
- ```
60
- It is also possible to use `nerdamer` functions directly within the need for string manipulation of the input. The input will be parsed and the output will of type `Expression`. For example:
61
43
  ```javascript
62
- var ans = nerdamer.expand('(x-1)^5');
63
- console.log(ans.text());
64
- // -1-10*x^2-5*x^4+10*x^3+5*x+x^5
44
+ const nerdamer = require('nerdamer');
65
45
 
66
- var sol = nerdamer.solve('x^2-4', 'x');
67
- console.log(sol.text())
68
- // [2,-2]
46
+ nerdamer.factor('x^2-1').text();
47
+ nerdamer.diff('x^3', 'x').text();
48
+ nerdamer.solve('x^2-4', 'x').text();
69
49
  ```
70
50
 
71
- You can also pass in an object with known values as the second parameter.
51
+ Nerdamer 2.0 also has a separate parser entry point. It contains the symbolic parser, scripting, assumptions, structures, complex and polynomial operations, and general math functions without loading the higher-level algebra, calculus, and solver domains.
72
52
 
73
- ```javascript
74
- var e = nerdamer('x^2+2*(cos(x)+x*x)',{x:6});
75
- console.log(e.text());
53
+ ```typescript
54
+ import { Parser } from 'nerdamer/parser';
76
55
 
77
- //result:
78
- //108+2*cos(6)
79
- ```
80
-
81
-
82
- As you can see only the substitution is performed. To evaluate the result just call evaluate.
83
- Note that evaluate returns a text string or a number not an object.
56
+ const expression = Parser.parse('sqrt(x^2+1)');
57
+ console.log(expression.text());
58
+ ```
84
59
 
85
- ```javascript
86
- var e = nerdamer('x^2+2*(cos(x)+x*x)',{x:6}).evaluate();
87
- console.log(e.text());
60
+ This separation is also reflected in the browser builds:
88
61
 
89
- //result:
90
- //109.9203405733006
91
- ```
92
- To get back the text as a fraction, call the text method and pass in the string 'fractions'.
62
+ - `dist/bundle.js` — complete Nerdamer package;
63
+ - `dist/parser.js` — parser-focused browser bundle.
93
64
 
94
- ```javascript
95
- var e = nerdamer('x^2+2*(cos(x)+x*x)',{x:6}).evaluate();
96
- console.log(e.text('fractions'));
65
+ ```html
66
+ <script src="./node_modules/nerdamer/dist/bundle.js"></script>
67
+ <script>
68
+ console.log(nerdamer('factor(x^2-1)').text());
69
+ </script>
70
+ ```
97
71
 
98
- //result:
99
- //429607273/3908351
100
- ```
101
- You can get your expression back as LaTeX by calling the toTeX method
102
- ```javascript
103
- var LaTeX = nerdamer('x^2+2*(cos(x)+x*x)',{x:0.25}).toTeX();
104
- console.log(LaTeX);
72
+ The parser bundle exposes `nerdamerParser` rather than the complete `nerdamer` API.
105
73
 
106
- //result:
107
- //2 \cdot \mathrm{cos}\left(\frac{1}{4}\right)+\frac{3}{16}
108
- ```
74
+ ## Package entry points
109
75
 
110
- To have numbers returned as decimals pass in the string 'decimals' to the toTeX method
76
+ The npm package exports the complete callable API plus typed module entry points:
111
77
 
112
- ```javascript
113
- var LaTeX = nerdamer('x^2+2*(cos(x)+x*x)',{x:0.25}).toTeX('decimal');
114
- console.log(LaTeX);
78
+ ```typescript
79
+ import nerdamer from 'nerdamer';
80
+ import { Expression, Rational, type TextOptions } from 'nerdamer/core';
81
+ import { Polynomial, gcd, lcm, partfrac } from 'nerdamer/algebra';
82
+ import { diff, integrate, limit } from 'nerdamer/calculus';
83
+ import { solve, PolynomialSolver } from 'nerdamer/solve';
84
+ import { Matrix, Vector, ValuesSet } from 'nerdamer/structures';
85
+ import { assume, clearAssumptions } from 'nerdamer/assumptions';
86
+ import { Parser } from 'nerdamer/parser';
87
+ ```
115
88
 
116
- //result:
117
- //2 \cdot \mathrm{cos}\left(0.25\right)+0.1875
118
- ```
89
+ Additional supported entry points are `nerdamer/advanced` and `nerdamer/debug`.
119
90
 
120
- Alternatively you can pass an object containing known values into evaluate method instead. The values passed in don't have to be number they can be another expression if needed.
91
+ ## Parser results
121
92
 
122
- ```javascript
123
- var e = nerdamer('x^2+2*(cos(x)+x*x)',{x:'x^2+1'});
124
- console.log(e.text());
93
+ `nerdamer(...)` returns the Nerdamer entity represented by the input. Scalar symbolic input normally returns an `Expression`; equations and structured notation can return `Equation`, `Vector`, `Matrix`, `Collection`, `ValuesSet`, or `Dictionary`.
125
94
 
126
- //result:
127
- //2*cos(1+x^2)+3*(1+x^2)^2
128
- ```
95
+ ```javascript
96
+ const scalar = nerdamer('x^2+1');
97
+ const equation = nerdamer('x^2=1');
98
+ const vector = nerdamer('[x, y, 3]');
99
+ ```
129
100
 
130
- Every time you parse an expression it's stored in nerdamer. To get a list of all the expressions you just call
131
- nerdamer.expressions().
101
+ This is intentional. Nerdamer 2.0 does not wrap every parser result in a compatibility `Expression` object.
132
102
 
133
- ```javascript
134
- var knownValues = {x:'x^2+1'};
135
- nerdamer('x^2+2*(cos(x)+x*x)').evaluate(knownValues);
136
- nerdamer('sin(x)^2+cos(x)^2').evaluate(knownValues);
103
+ ## Substitution and evaluation
137
104
 
138
- console.log(nerdamer.expressions());
105
+ Values supplied to `nerdamer(...)` are substitutions. They do not imply numerical evaluation.
139
106
 
140
- //result:
141
- //[ 46.692712758272776, 1 ]
142
- ```
107
+ ```javascript
108
+ const substituted = nerdamer('x^2+cos(x)', { x: 6 });
109
+ const evaluated = substituted.evaluate();
110
+ ```
143
111
 
144
- You can request it as an object as well by passing in true. This can be convenient in some
145
- situations as the numbering starts at 1;
112
+ Values can themselves be symbolic expressions:
146
113
 
147
- ```javascript
148
- var knownValues = {x:'x^2+1'};
149
- nerdamer('x^2+2*(cos(x)+x*x)', knownValues );
150
- nerdamer('sin(x)^2+cos(x)^2', knownValues );
114
+ ```javascript
115
+ nerdamer('x^2+1', { x: 'y+1' }).text();
116
+ ```
151
117
 
152
- console.log(nerdamer.expressions(true));
118
+ ## Text and TeX output
153
119
 
154
- //{ '1': '2*cos(1+x^(2))+3*(1+x^(2))^(2)',
155
- //'2': 'cos(1+x^(2))^(2)+sin(1+x^(2))^(2)' }
156
- ```
157
-
158
- Functions aren't always immediately parsed to numbers. For example
120
+ `text()` returns Nerdamer notation. Term ordering can be requested per call:
159
121
 
160
122
  ```javascript
161
- var result = nerdamer('cos(x)',{x:6});
162
- console.log(result.text());
163
- //cos(6)
123
+ const expression = nerdamer('x^2+2*x+1');
124
+
125
+ expression.text();
126
+ // 1+2*x+x^2
127
+
128
+ expression.text({ sort: true });
129
+ // x^2+2*x+1
164
130
  ```
165
- will only subsitute out the variable name. To change this behaviour numer should be passed in as the 3rd argument.
131
+
132
+ The full package also supplies `toText()` and TeX conversion:
166
133
 
167
134
  ```javascript
168
- var result = nerdamer('cos(x)',{x:6}, 'numer');
169
- console.log(result.text());
170
- //0.960170286650366
135
+ expression.toText();
136
+ expression.toTeX();
137
+ nerdamer.convertToTeX('sqrt(x^2+1)');
138
+ nerdamer.convertFromLaTeX('\\frac{x^2+1}{2}');
171
139
  ```
172
- or alternatively
140
+
141
+ `convertToLaTeX()` remains as a deprecated compatibility alias.
142
+
143
+ Scientific formatting can be requested through `text()` without changing the underlying expression:
173
144
 
174
145
  ```javascript
175
- var result = nerdamer('cos(x)').evaluate({x:6});
176
- console.log(result.text());
177
- //0.960170286650366
146
+ nerdamer('1200').text({ scientific: 4 });
147
+ // 1.200e3
178
148
  ```
179
- The difference however is that the first option directly substitutes the variables while the second first evaluates
180
- the expression and then makes the substitutions. This library utilizes native javascript functions as much as possible. As a result it inherits whatever rounding errors they possess. One major change with version 0.6.0 however, is dealing with floating point issues.
149
+
150
+ ## Algebra
181
151
 
182
152
  ```javascript
183
- var result = nerdamer('sqrt(x)*sqrt(x)-2', {x: 2});
184
- console.log(result.text());
185
- //0
153
+ nerdamer.expand('(x+1)^4').text();
154
+ nerdamer.factor('x^4-1').text();
155
+ nerdamer.simplify('sin(x)^2+cos(x)^2').text();
156
+ nerdamer.gcd('x^2-1', 'x^2-2*x+1').text();
157
+ nerdamer.partfrac('1/(x^2-1)', 'x').text();
186
158
  ```
187
- The above expample now returns zero whereas in previous version the result would be 4.440892098500626e-16. Same goes for 0.1+0.2.
188
159
 
189
- An expression can be replaced directly by passing in the index of which expression to override. For example
160
+ The 2.0 algebra implementation includes the rewritten polynomial GCD/factorization path, partial fractions, polynomial solving support, and direct polynomial APIs.
161
+
162
+ Prime factorization has two explicit forms:
190
163
 
191
164
  ```javascript
192
- nerdamer('cos(x)',{x:6}, 'numer');
193
- nerdamer('sin(x)+y',{x:6}, null, 1);
194
- console.log(nerdamer.expressions());
195
- //[ 'sin(6)+y' ]
165
+ nerdamer.pfactor(100).text();
166
+ // [2,2,5,5]
167
+
168
+ nerdamer.pfactord(100).text();
169
+ // {2=>2,5=>2}
196
170
  ```
197
171
 
198
- If multiple modifier options need to be passed into nerdamer you can do so using an array. For example ...
172
+ ## Calculus
199
173
 
200
174
  ```javascript
201
- var e = nerdamer('cos(x)+(y-x)^2', {x:7}, ['expand', 'numer']);
202
- console.log(e.text());
203
- //-14*y+y^2+49.7539022543433
175
+ nerdamer.diff('x^3+sin(x)', 'x').text();
176
+ nerdamer.integrate('x^2', 'x').text();
177
+ nerdamer.limit('sin(x)/x', 'x', '0').text();
178
+ nerdamer.laplace('t', 't', 's').text();
204
179
  ```
205
180
 
206
- If you need the code as LaTeX you can pass in true as the second parameter when requesting the expressions.
207
-
208
- ```javascript
209
- nerdamer('x^2+2*(cos(x)+x*x)');
210
- nerdamer('sin(x)^0.25+cos(x)^0.5' );
211
- var asObject = true;
212
- var asLaTeX = true;
213
- console.log(nerdamer.expressions(asObject, asLaTeX));
214
-
215
- /*{ '1': '2 \\cdot \\mathrm{cos}\\left(x\\right)+3 \\cdot x^{2}',
216
- '2': '\\sqrt{\\mathrm{cos}\\left(x\\right)}+\\mathrm{sin}\\left(x\\right)^{\\frac{1}{4}}' }*/
217
- ```
218
-
219
-
220
- You can specify a particular location when adding an expression, which is specified with the third parameter.
221
-
222
- ```javascript
223
- nerdamer('x^2+2*(cos(x)+x*x)');
224
- nerdamer('sin(x)^0.25+cos(x)^0.5' );
225
- nerdamer('expr-override', undefined, 2 );
226
- var asObject = false;
227
- var asLaTeX = true;
228
- console.log(nerdamer.expressions(asObject, asLaTeX));
229
-
230
- /* [ '2 \\cdot \\mathrm{cos}\\left(x\\right)+3 \\cdot x^{2}',
231
- '\\sqrt{\\mathrm{cos}\\left(x\\right)}+\\mathrm{sin}\\left(x\\right)^{\\frac{1}{4}}',
232
- 'expr-override' ]
233
- */
181
+ The same functions can be used in Nerdamer notation:
182
+
183
+ ```javascript
184
+ nerdamer('diff(x^3,x)').text();
234
185
  ```
235
186
 
236
- Here's an example of reserved variable and function names.
187
+ ## Solving
237
188
 
238
- ```javascript
239
- var reserved = nerdamer.reserved();
240
- console.log(reserved);
241
- //result:
242
- /* csc, sec, cot, erf, fact, mod, GCD, QGCD, LCM, pow, PI, E, cos, sin, tan, acos, asin, atan, sinh, cosh, tanh, asinh, acosh, atanh, exp, min, max, floor, ceil, round, vector, matrix, parens, sqrt, log, expand, abs, invert, transpose, dot */
189
+ Single-variable solving returns a `SolutionSet`:
243
190
 
244
- //or as an array
191
+ ```javascript
192
+ const roots = nerdamer.solve('x^2-1', 'x');
193
+ console.log(roots.text());
194
+ ```
245
195
 
246
- var reserved = nerdamer.reserved(true);
247
- console.log(reserved);
248
- //result:
249
- /* [ 'csc', 'sec', 'cot', 'erf', 'fact', 'mod', 'GCD', 'QGCD', 'LCM', 'pow', 'PI', 'E', 'cos', 'sin', 'tan', 'acos', 'asin', 'atan', 'sinh', 'cosh', 'tanh', 'asinh', 'acosh', 'atanh', 'exp', 'min', 'max', 'floor', 'ceil', 'round', 'vector', 'matrix',
250
- 'parens', 'sqrt', 'log', 'expand', 'abs', 'invert', 'transpose', 'dot' ] */
251
- ```
196
+ System solving returns Nerdamer structures rather than legacy JavaScript arrays:
252
197
 
253
- Most math functions are passed in as part of the expression. If you want to differentiate for instance you just use the function diff which is located in the Calculus add-on as of version 0.5.0
198
+ ```javascript
199
+ const solutions = nerdamer.solveSystem(
200
+ ['x+y=3', 'x-y=1'],
201
+ ['x', 'y']
202
+ );
254
203
 
255
- ```javascript
256
- var e = nerdamer('diff(x^2+2*(cos(x)+x*x),x)');
204
+ console.log(solutions.text());
205
+ ```
257
206
 
258
- console.log(e.text());
207
+ The legacy `solveeqs` name is retained as the compatibility alias for system solving. `solveEquations` is not part of the 2.0 public API.
259
208
 
260
- //result:
261
- //-2*sin(x)+6*x
262
- ```
263
-
209
+ ## Matrices, vectors, sets, and dictionaries
264
210
 
265
- Nerdamer can also handle runtime functions. To do this use the method setFunction.
266
- The runtime functions do have symbolic capabilities and support for imaginary numbers.
267
- The setfunction method is used as follows:
211
+ Structured values are first-class parser entities:
268
212
 
269
- nerdamer.setFunction( function_name, parameter_array, function_body )
213
+ ```javascript
214
+ nerdamer('matrix([1,2],[3,4])').text();
215
+ nerdamer('[1,x,3]').text();
216
+ nerdamer('{1,2,x}').text();
217
+ ```
270
218
 
271
- For Example:
219
+ The corresponding TypeScript classes are exported from `nerdamer/structures`.
272
220
 
273
- ```javascript
274
- //generate some points
275
- var f = function(x) { return 5*x-1; }
276
- console.log(f(1)); //4
277
- console.log(f(2)); //9 - value to be found
278
- console.log(f(7)); //34
221
+ ## Scripting
279
222
 
280
- nerdamer.setFunction('interpolate',['y0','x0','y1','x1','x'],'y0+(y1-y0)*((x-x0)/(x1-x0))')
281
- var answer = nerdamer('interpolate(4,1,34,7,2)').evaluate();
223
+ Nerdamer notation includes a symbolic scripting layer with assignments, user functions, local bindings, conditionals, loops, blocks, logical operations, `return`, `break`, `continue`, and error-handling helpers.
282
224
 
283
- console.log(answer);
225
+ ```javascript
226
+ const result = nerdamer(`
227
+ f(x):=x^2+1;
228
+ f(12)
229
+ `);
284
230
 
285
- //result: 9
231
+ console.log(result.text());
286
232
  ```
287
233
 
288
- Custom functions alternatively be set in following manner.
234
+ Control-flow operations that intentionally produce no mathematical value use an internal null signal. That signal is distinct from legitimate values such as an empty vector and is not exposed as a normal parser entity.
235
+
236
+ ## Runtime functions, constants, and settings
289
237
 
290
238
  ```javascript
291
- nerdamer('hyp(a, b) := sqrt(a^2 + b^2) ');
292
- var result = nerdamer('hyp(3, 4)').evaluate().text();
293
- console.log(result);
294
- //result: 5
239
+ nerdamer.setFunction('line', ['x', 'm', 'b'], 'm*x+b');
240
+ nerdamer.setConstant('g', 9.81);
241
+ nerdamer.setVar('a', 5);
295
242
  ```
296
243
 
244
+ Settings remain shared by the package instance:
297
245
 
298
- If you need to add a constant use the setConstant method
299
-
300
- ```javascript
301
- nerdamer.setConstant( 'g', 9.81);
302
- var weight = nerdamer('100*g').text();
303
- console.log(weight);
304
- //result:
305
- //981
306
- ```
307
-
308
- To delete just set it to delete
309
-
310
- ```javascript
311
- nerdamer.setConstant( 'g', 9.81);
312
- var weight = nerdamer('100*g').text();
313
- console.log(weight);
314
- //981
315
- nerdamer.setConstant( 'g', 'delete');
316
- var weight = nerdamer('100*g').text();
317
- console.log(weight);
318
- //100*g
319
- ```
320
-
321
- You also have the option of exporting your function to a javascript function which can be useful if you need some
322
- filtering from user input. Do keep in mind that the parameters are sorted alphabetically for more than one
323
- parameter. To use it add the expression to nerdamer and use the buildFunction method.
324
-
325
- ```javascript
326
- var f = nerdamer('x^2+5').buildFunction();
327
- console.log(f(9));
328
-
329
- //result:
330
- //86
331
- ```
332
- If you have a particular order in which you need the parameters to be set, then you pass in an array with the variables in the order in which you want them for instance:
246
+ ```javascript
247
+ nerdamer.set('LANGUAGE', 'spa');
248
+ nerdamer.set('LANGUAGE', 'eng');
249
+ ```
333
250
 
334
- ```javascript
335
- var f = nerdamer('z+x^2+y').buildFunction(['y', 'x', 'z']);
336
- console.log(f(9,2,1));
337
- //result
338
- //14
339
- ```
251
+ Built-in error messages are available in English, Spanish, French, German, Portuguese, Italian, and Dutch.
340
252
 
341
- Every time you add an expression to nerdamer it's stored. To list the expressions currently in nerdamer call
342
- the 'expressions' method. To delete an expression use the 'clear' method and pass in the expression you want to delete.
343
- To clear everything pass in the string 'all'.
253
+ ## Assumptions
344
254
 
345
- ```javascript
346
- nerdamer('n*R*T/v');
347
- nerdamer('mc^2');
348
- nerdamer('G*m1*m2/d^2');
255
+ ```typescript
256
+ import nerdamer from 'nerdamer';
257
+ import { assume, clearAssumptions } from 'nerdamer/assumptions';
349
258
 
350
- nerdamer.clear(2);
259
+ assume('x > 0');
260
+ console.log(nerdamer('sqrt(x^2)').text());
261
+ // x
262
+ clearAssumptions();
263
+ ```
351
264
 
352
- console.log(nerdamer.expressions(true));
265
+ Repeated assumptions for a symbol are intersected. Contradictory assumptions are rejected.
353
266
 
354
- //result:
355
- //{ '1': 'R*T*n*v^(-1)', '2': 'G*d^(-2)*m1*m2' }
267
+ ## Building JavaScript functions
356
268
 
357
- nerdamer.clear('all');
358
- console.log(nerdamer.expressions(true));
359
- //result:
360
- //{}
361
- ```
362
-
363
- If you need go get the variables of an expression use the variables method. This method can be called after
364
- nerdamer was provided an expression. For example
269
+ Scalar expressions can be compiled to native JavaScript-number functions:
365
270
 
366
271
  ```javascript
367
- var variables = nerdamer('csc(x*cos(y))-no_boring_x').variables();
368
- console.log(variables);
369
- //result:
370
- //[ 'no_boring_x', 'x', 'y' ]
272
+ const f = nerdamer('x^2+5').buildFunction();
273
+ console.log(f(9));
274
+ // 86
371
275
  ```
372
276
 
373
- The order in which the variables appear require a little bit of knowledge of how nerdamer organizes symbols. For the
374
- sake of simplicity we'll just assume that there is no particular order
277
+ `buildFunction()` uses dynamic JavaScript function construction. Applications whose Content Security Policy blocks dynamic code generation should use Nerdamer's symbolic or numeric evaluation APIs instead. Structured parser results cannot be compiled as scalar functions.
375
278
 
376
- ----------------------------------------------------------------------------------------------------------------------
279
+ ## Numeric behavior
280
+
281
+ Nerdamer preserves exact integer and rational arithmetic where possible. Large integers use native `BigInt`; decimal arithmetic uses Decimal.js. Complex arithmetic is represented by Nerdamer's numeric types rather than JavaScript's native `Number` alone.
377
282
 
378
- Using the solver
379
- ===============
380
- To solve equations first load Solve.js. Just remember that Solve also required Algebra.js and Calculus.js to be loaded. You can then solve equations using nerdamer. Important: State the variable for which you are trying to solve.
381
283
  ```javascript
382
- var sol = nerdamer.solveEquations('x^3+8=x^2+6','x');
383
- console.log(sol.toString());
384
- //1+i,-i+1,-1
284
+ nerdamer('0.1+0.2').text();
285
+ nerdamer('sqrt(2)').evaluate().text();
385
286
  ```
386
287
 
387
- Notice that we use toString rather than text as this returns a javascript array.
288
+ ## Building from source
388
289
 
389
- You can also solve an expression
390
- ```javascript
391
- var e = nerdamer.solveEquations('x^2+4-y', 'y');
392
- console.log(e[0].text());
393
- //4+x^2
394
- ```
290
+ Install dependencies and run the normal checks:
395
291
 
396
- You can also solve multivariate equations
397
- ```javascript
398
- var sol = nerdamer.solveEquations('x^2+8+y=x+6','x');
399
- console.log(sol.toString());
400
- //0.5*((-4*y-7)^0.5+1),0.5*(-(-4*y-7)^0.5+1)
292
+ ```bash
293
+ npm install
294
+ npm run typecheck
295
+ npm test
401
296
  ```
402
- You can do up to 3rd order polynomials for multivariate polynomials
403
297
 
404
- Additionally you can try for equations containing functions. This is more of a hit or miss approach unlike single variable polynomials (which uses Mr. David Binner's Jenkins-Traub port - http://www.akiti.ca/PolyRootRe.html) but it's there if you want to give it a try.
298
+ Build the complete package:
405
299
 
406
- ```javascript
407
- var sol = nerdamer.solveEquations('cos(x)+cos(3*x)=1','x');
408
- console.log(sol.toString());
409
- //5.7981235959208695,0.4850617112587174
300
+ ```bash
301
+ npm run build
410
302
  ```
411
- To solve a system of linear equations pass them in as an array. For example
412
303
 
413
- ```javascript
414
- var sol = nerdamer.solveEquations(['x+y=1', '2*x=6', '4*z+y=6']);
415
- console.log(sol);
416
- //[ [ 'x', 3 ], [ 'y', -2 ], [ 'z', 2 ] ]
417
- ```
418
- In version 0.7.2 and up the solver can additionally be used in the following way
419
- ```javascript
420
- //first parse the equation
421
- var x = nerdamer('x^2+2=y-7*a');
422
- //You can make substitutions to the equation
423
- x = x.evaluate({a: 'x^2-3'});
424
- console.log(x.toString()); //2+x^2=-7*x^2+21+y
425
- var solutions = x.solveFor('x');
426
- console.log(solutions.toString()); //(1/16)*sqrt(32*y+608),(-1/16)*sqrt(32*y+608)
304
+ Build the parser-only browser bundle:
305
+
306
+ ```bash
307
+ npm run build:parser
427
308
  ```
309
+
310
+ The webpack build also accepts a language selection (`eng`, `spa`, `fra`, `deu`, `por`, `ita`, `nld`, or `all`) for browser bundles. English is the default.
311
+
312
+ Before publishing, the package runs type checking, tests, coverage, both browser builds, parser documentation generation, TypeDoc validation, and packed-package validation through `prepublishOnly`.
313
+
314
+ ## Migrating from Nerdamer 1.x
315
+
316
+ Nerdamer 2.0 keeps much of the familiar expression-oriented API, but it is a new implementation. Important migration areas include:
317
+
318
+ - the old `Algebra`, `Calculus`, `Solve`, and `Extra` side-effect imports are replaced by the complete package and supported module entry points;
319
+ - the third and fourth arguments to `nerdamer(...)` are gone;
320
+ - global parsed-expression history is gone;
321
+ - parser results can be structured Nerdamer entities instead of always being wrapped as an `Expression`;
322
+ - system-solving results use `Vector`/`Dictionary` structures;
323
+ - lower-level 1.x extension hooks such as `getCore()` and `register()` are not restored;
324
+ - several compatibility functions were restored explicitly rather than by exposing every parser function on the root object;
325
+ - internal numeric, parser, solver, polynomial, assumptions, set, and scripting implementations have changed substantially.
326
+
327
+ See [BREAKING_CHANGES.md](BREAKING_CHANGES.md) and [Moving from Nerdamer 1.x to 2.0](docs/MIGRATING_FROM_1X.md) before upgrading an existing application.
328
+
329
+ ## Documentation
330
+
331
+ - Website: https://nerdamer.com/
332
+ - Documentation: https://nerdamer.com/documentation
333
+ - Migration guide: `docs/MIGRATING_FROM_1X.md`
334
+ - 2.0 release notes: `docs/RELEASE_NOTES_2.md`
335
+ - Parser conventions: `docs/PARSER_CONVENTIONS.md`
336
+ - Source repository: https://github.com/jiggzson/nerdamer
337
+ - Issues: https://github.com/jiggzson/nerdamer/issues
338
+
339
+ ## License
340
+
341
+ Nerdamer 2.0 is licensed under the Apache License 2.0.