nerdamer 1.1.12 → 2.0.0-rc.1

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 (341) hide show
  1. package/LICENSE.md +184 -0
  2. package/README.md +297 -287
  3. package/dist/bundle.js +2 -0
  4. package/dist/bundle.js.LICENSE.txt +7 -0
  5. package/dist/parser.js +2 -0
  6. package/dist/parser.js.LICENSE.txt +7 -0
  7. package/docs-data/parser-functions.json +1960 -0
  8. package/index.d.ts +10 -420
  9. package/output/algebra/adapters.d.ts +33 -0
  10. package/output/algebra/adapters.js +109 -0
  11. package/output/algebra/algorithms/arith.d.ts +84 -0
  12. package/output/algebra/algorithms/arith.js +323 -0
  13. package/output/algebra/algorithms/factor.d.ts +3 -0
  14. package/output/algebra/algorithms/factor.js +5 -0
  15. package/output/algebra/algorithms/factorMultivariate.d.ts +23 -0
  16. package/output/algebra/algorithms/factorMultivariate.js +2393 -0
  17. package/output/algebra/algorithms/factorUnivariate.d.ts +72 -0
  18. package/output/algebra/algorithms/factorUnivariate.js +1072 -0
  19. package/output/algebra/algorithms/gcd.d.ts +22 -0
  20. package/output/algebra/algorithms/gcd.js +690 -0
  21. package/output/algebra/algorithms/groebnerBase.d.ts +157 -0
  22. package/output/algebra/algorithms/groebnerBase.js +1166 -0
  23. package/output/algebra/algorithms/multiPoly/MultiPoly.d.ts +137 -0
  24. package/output/algebra/algorithms/multiPoly/MultiPoly.js +346 -0
  25. package/output/algebra/algorithms/poly.d.ts +228 -0
  26. package/output/algebra/algorithms/poly.js +1299 -0
  27. package/output/algebra/algorithms/rational.d.ts +17 -0
  28. package/output/algebra/algorithms/rational.js +115 -0
  29. package/output/algebra/factor/factor.d.ts +62 -0
  30. package/output/algebra/factor/factor.js +158 -0
  31. package/output/algebra/gcd/gcd.d.ts +29 -0
  32. package/output/algebra/gcd/gcd.js +141 -0
  33. package/output/algebra/groebner.d.ts +21 -0
  34. package/output/algebra/groebner.js +42 -0
  35. package/output/algebra/partfrac.d.ts +19 -0
  36. package/output/algebra/partfrac.js +398 -0
  37. package/output/algebra/polynomialize.d.ts +20 -0
  38. package/output/algebra/polynomialize.js +24 -0
  39. package/output/algebra/simplify/complexsimp.d.ts +7 -0
  40. package/output/algebra/simplify/complexsimp.js +24 -0
  41. package/output/algebra/simplify/factorCommon.d.ts +13 -0
  42. package/output/algebra/simplify/factorCommon.js +136 -0
  43. package/output/algebra/simplify/funcsimp.d.ts +26 -0
  44. package/output/algebra/simplify/funcsimp.js +633 -0
  45. package/output/algebra/simplify/invtrigrewrite.d.ts +10 -0
  46. package/output/algebra/simplify/invtrigrewrite.js +96 -0
  47. package/output/algebra/simplify/ratsimp.d.ts +21 -0
  48. package/output/algebra/simplify/ratsimp.js +140 -0
  49. package/output/algebra/simplify/simplify.d.ts +25 -0
  50. package/output/algebra/simplify/simplify.js +228 -0
  51. package/output/algebra/simplify/trigreduce.d.ts +38 -0
  52. package/output/algebra/simplify/trigreduce.js +424 -0
  53. package/output/algebra/simplify/trigrewrite.d.ts +17 -0
  54. package/output/algebra/simplify/trigrewrite.js +156 -0
  55. package/output/algebra/simplify/trigsimp.d.ts +11 -0
  56. package/output/algebra/simplify/trigsimp.js +369 -0
  57. package/output/algebra/simplify/utils.d.ts +32 -0
  58. package/output/algebra/simplify/utils.js +56 -0
  59. package/output/algebra/utils.d.ts +32 -0
  60. package/output/algebra/utils.js +48 -0
  61. package/output/api/advanced.d.ts +7 -0
  62. package/output/api/advanced.js +18 -0
  63. package/output/api/algebra.d.ts +17 -0
  64. package/output/api/algebra.js +32 -0
  65. package/output/api/assumptions.d.ts +4 -0
  66. package/output/api/assumptions.js +11 -0
  67. package/output/api/calculus.d.ts +9 -0
  68. package/output/api/calculus.js +21 -0
  69. package/output/api/core.d.ts +17 -0
  70. package/output/api/core.js +41 -0
  71. package/output/api/debug.d.ts +16 -0
  72. package/output/api/debug.js +23 -0
  73. package/output/api/parser.d.ts +85 -0
  74. package/output/api/parser.js +16 -0
  75. package/output/api/solve.d.ts +10 -0
  76. package/output/api/solve.js +16 -0
  77. package/output/api/structures.d.ts +10 -0
  78. package/output/api/structures.js +22 -0
  79. package/output/calculus/derivative/diff.d.ts +30 -0
  80. package/output/calculus/derivative/diff.js +238 -0
  81. package/output/calculus/fresnel.d.ts +16 -0
  82. package/output/calculus/fresnel.js +39 -0
  83. package/output/calculus/integrate/byParts.d.ts +18 -0
  84. package/output/calculus/integrate/byParts.js +339 -0
  85. package/output/calculus/integrate/bySubstitution.d.ts +135 -0
  86. package/output/calculus/integrate/bySubstitution.js +411 -0
  87. package/output/calculus/integrate/integrate.d.ts +38 -0
  88. package/output/calculus/integrate/integrate.js +652 -0
  89. package/output/calculus/integrate/integrationTable.d.ts +2 -0
  90. package/output/calculus/integrate/integrationTable.js +914 -0
  91. package/output/calculus/integrate/utils.d.ts +28 -0
  92. package/output/calculus/integrate/utils.js +96 -0
  93. package/output/calculus/laplace/ilaplace.d.ts +31 -0
  94. package/output/calculus/laplace/ilaplace.js +192 -0
  95. package/output/calculus/laplace/ilaplaceTable.d.ts +2 -0
  96. package/output/calculus/laplace/ilaplaceTable.js +200 -0
  97. package/output/calculus/laplace/laplace.d.ts +22 -0
  98. package/output/calculus/laplace/laplace.js +109 -0
  99. package/output/calculus/laplace/laplaceTable.d.ts +2 -0
  100. package/output/calculus/laplace/laplaceTable.js +187 -0
  101. package/output/calculus/limit/limit.d.ts +35 -0
  102. package/output/calculus/limit/limit.js +1183 -0
  103. package/output/calculus/limit/limitsTable.d.ts +2 -0
  104. package/output/calculus/limit/limitsTable.js +7 -0
  105. package/output/core/Settings.d.ts +32 -0
  106. package/output/core/Settings.js +68 -0
  107. package/output/core/adapters.d.ts +18 -0
  108. package/output/core/adapters.js +40 -0
  109. package/output/core/classes/assumption/Assumption.d.ts +218 -0
  110. package/output/core/classes/assumption/Assumption.js +605 -0
  111. package/output/core/classes/assumption/assertiveFunctions.d.ts +6 -0
  112. package/output/core/classes/assumption/assertiveFunctions.js +64 -0
  113. package/output/core/classes/assumption/assume.d.ts +90 -0
  114. package/output/core/classes/assumption/assume.js +145 -0
  115. package/output/core/classes/collection/Collection.d.ts +107 -0
  116. package/output/core/classes/collection/Collection.js +231 -0
  117. package/output/core/classes/complex/Complex.d.ts +99 -0
  118. package/output/core/classes/complex/Complex.js +135 -0
  119. package/output/core/classes/decimalSet/DecimalSet.d.ts +226 -0
  120. package/output/core/classes/decimalSet/DecimalSet.js +453 -0
  121. package/output/core/classes/dictionary/Dictionary.d.ts +102 -0
  122. package/output/core/classes/dictionary/Dictionary.js +213 -0
  123. package/output/core/classes/equation/Equation.d.ts +256 -0
  124. package/output/core/classes/equation/Equation.js +350 -0
  125. package/output/core/classes/expression/CoeffObject.d.ts +100 -0
  126. package/output/core/classes/expression/CoeffObject.js +198 -0
  127. package/output/core/classes/expression/Expression.d.ts +1674 -0
  128. package/output/core/classes/expression/Expression.js +2332 -0
  129. package/output/core/classes/expression/analysis.d.ts +25 -0
  130. package/output/core/classes/expression/analysis.js +218 -0
  131. package/output/core/classes/expression/collect.d.ts +9 -0
  132. package/output/core/classes/expression/collect.js +49 -0
  133. package/output/core/classes/expression/format.d.ts +45 -0
  134. package/output/core/classes/expression/format.js +217 -0
  135. package/output/core/classes/expression/products.d.ts +23 -0
  136. package/output/core/classes/expression/products.js +115 -0
  137. package/output/core/classes/expression/shortcuts.d.ts +35 -0
  138. package/output/core/classes/expression/shortcuts.js +129 -0
  139. package/output/core/classes/expression/traversal.d.ts +31 -0
  140. package/output/core/classes/expression/traversal.js +216 -0
  141. package/output/core/classes/expression/trig.d.ts +25 -0
  142. package/output/core/classes/expression/trig.js +40 -0
  143. package/output/core/classes/expression/utils.d.ts +52 -0
  144. package/output/core/classes/expression/utils.js +189 -0
  145. package/output/core/classes/lookupTable/LookupTable.d.ts +12 -0
  146. package/output/core/classes/lookupTable/LookupTable.js +55 -0
  147. package/output/core/classes/matrix/Matrix.d.ts +227 -0
  148. package/output/core/classes/matrix/Matrix.js +889 -0
  149. package/output/core/classes/matrix/Sylvester.d.ts +11 -0
  150. package/output/core/classes/matrix/Sylvester.js +54 -0
  151. package/output/core/classes/matrix/functions.d.ts +26 -0
  152. package/output/core/classes/matrix/functions.js +52 -0
  153. package/output/core/classes/matrix/utils.d.ts +9 -0
  154. package/output/core/classes/matrix/utils.js +22 -0
  155. package/output/core/classes/parser/Parser.d.ts +480 -0
  156. package/output/core/classes/parser/Parser.js +1812 -0
  157. package/output/core/classes/parser/Token.d.ts +58 -0
  158. package/output/core/classes/parser/Token.js +137 -0
  159. package/output/core/classes/parser/constants.d.ts +160 -0
  160. package/output/core/classes/parser/constants.js +227 -0
  161. package/output/core/classes/parser/helpers.d.ts +21 -0
  162. package/output/core/classes/parser/helpers.js +42 -0
  163. package/output/core/classes/parser/operations/add.d.ts +15 -0
  164. package/output/core/classes/parser/operations/add.js +238 -0
  165. package/output/core/classes/parser/operations/comma.d.ts +7 -0
  166. package/output/core/classes/parser/operations/comma.js +11 -0
  167. package/output/core/classes/parser/operations/compare.d.ts +21 -0
  168. package/output/core/classes/parser/operations/compare.js +461 -0
  169. package/output/core/classes/parser/operations/divide.d.ts +2 -0
  170. package/output/core/classes/parser/operations/divide.js +72 -0
  171. package/output/core/classes/parser/operations/functions.d.ts +46 -0
  172. package/output/core/classes/parser/operations/functions.js +430 -0
  173. package/output/core/classes/parser/operations/multiply.d.ts +11 -0
  174. package/output/core/classes/parser/operations/multiply.js +321 -0
  175. package/output/core/classes/parser/operations/power.d.ts +48 -0
  176. package/output/core/classes/parser/operations/power.js +673 -0
  177. package/output/core/classes/parser/operations/subtract.d.ts +3 -0
  178. package/output/core/classes/parser/operations/subtract.js +35 -0
  179. package/output/core/classes/parser/preprocess.d.ts +14 -0
  180. package/output/core/classes/parser/preprocess.js +259 -0
  181. package/output/core/classes/parser/scripting/controlFlow.d.ts +121 -0
  182. package/output/core/classes/parser/scripting/controlFlow.js +355 -0
  183. package/output/core/classes/parser/scripting/evaluate.d.ts +10 -0
  184. package/output/core/classes/parser/scripting/evaluate.js +112 -0
  185. package/output/core/classes/parser/scripting/functions.d.ts +14 -0
  186. package/output/core/classes/parser/scripting/functions.js +59 -0
  187. package/output/core/classes/parser/scripting/scope.d.ts +35 -0
  188. package/output/core/classes/parser/scripting/scope.js +155 -0
  189. package/output/core/classes/parser/types.d.ts +125 -0
  190. package/output/core/classes/parser/types.js +2 -0
  191. package/output/core/classes/parser/wrappers/IndexedReference.d.ts +31 -0
  192. package/output/core/classes/parser/wrappers/IndexedReference.js +68 -0
  193. package/output/core/classes/parser/wrappers/KeyValuePair.d.ts +24 -0
  194. package/output/core/classes/parser/wrappers/KeyValuePair.js +51 -0
  195. package/output/core/classes/polynomial/Polynomial.d.ts +500 -0
  196. package/output/core/classes/polynomial/Polynomial.js +1149 -0
  197. package/output/core/classes/polynomial/Term.d.ts +222 -0
  198. package/output/core/classes/polynomial/Term.js +430 -0
  199. package/output/core/classes/polynomial/functions.d.ts +69 -0
  200. package/output/core/classes/polynomial/functions.js +126 -0
  201. package/output/core/classes/polynomial/utils.d.ts +62 -0
  202. package/output/core/classes/polynomial/utils.js +206 -0
  203. package/output/core/classes/rational/Rational.d.ts +504 -0
  204. package/output/core/classes/rational/Rational.js +779 -0
  205. package/output/core/classes/seq/SEQ.d.ts +13 -0
  206. package/output/core/classes/seq/SEQ.js +137 -0
  207. package/output/core/classes/valuesSet/ValuesSet.d.ts +179 -0
  208. package/output/core/classes/valuesSet/ValuesSet.js +381 -0
  209. package/output/core/classes/vector/Vector.d.ts +222 -0
  210. package/output/core/classes/vector/Vector.js +497 -0
  211. package/output/core/classes/vector/functions.d.ts +28 -0
  212. package/output/core/classes/vector/functions.js +47 -0
  213. package/output/core/common/classes/MathematicalAggregate.d.ts +53 -0
  214. package/output/core/common/classes/MathematicalAggregate.js +140 -0
  215. package/output/core/common/classes/Scope.d.ts +62 -0
  216. package/output/core/common/classes/Scope.js +122 -0
  217. package/output/core/common/classes/StructuredEntity.d.ts +55 -0
  218. package/output/core/common/classes/StructuredEntity.js +151 -0
  219. package/output/core/common/common.d.ts +63 -0
  220. package/output/core/common/common.js +279 -0
  221. package/output/core/common/functions/functions.d.ts +14 -0
  222. package/output/core/common/functions/functions.js +33 -0
  223. package/output/core/common/functions/structuredEntityUtils.d.ts +27 -0
  224. package/output/core/common/functions/structuredEntityUtils.js +40 -0
  225. package/output/core/converters/BaseConverter.d.ts +97 -0
  226. package/output/core/converters/BaseConverter.js +405 -0
  227. package/output/core/converters/Converter.d.ts +111 -0
  228. package/output/core/converters/Converter.js +802 -0
  229. package/output/core/converters/Pattern.d.ts +71 -0
  230. package/output/core/converters/Pattern.js +302 -0
  231. package/output/core/dispatch.d.ts +34 -0
  232. package/output/core/dispatch.js +304 -0
  233. package/output/core/errors.d.ts +531 -0
  234. package/output/core/errors.js +621 -0
  235. package/output/core/functions/bigint/bigint.d.ts +121 -0
  236. package/output/core/functions/bigint/bigint.js +392 -0
  237. package/output/core/functions/bigint/primeFactor.d.ts +49 -0
  238. package/output/core/functions/bigint/primeFactor.js +267 -0
  239. package/output/core/functions/bigint/primes.d.ts +1 -0
  240. package/output/core/functions/bigint/primes.js +11 -0
  241. package/output/core/functions/build/definitions.d.ts +12 -0
  242. package/output/core/functions/build/definitions.js +133 -0
  243. package/output/core/functions/build/index.d.ts +32 -0
  244. package/output/core/functions/build/index.js +136 -0
  245. package/output/core/functions/complex.d.ts +90 -0
  246. package/output/core/functions/complex.js +482 -0
  247. package/output/core/functions/decimal.d.ts +24 -0
  248. package/output/core/functions/decimal.js +664 -0
  249. package/output/core/functions/expand/expand.d.ts +42 -0
  250. package/output/core/functions/expand/expand.js +376 -0
  251. package/output/core/functions/fresnelNumeric.d.ts +12 -0
  252. package/output/core/functions/fresnelNumeric.js +123 -0
  253. package/output/core/functions/numeric.d.ts +140 -0
  254. package/output/core/functions/numeric.js +790 -0
  255. package/output/core/functions/rationalNormalization.d.ts +11 -0
  256. package/output/core/functions/rationalNormalization.js +117 -0
  257. package/output/core/functions/setFunction.d.ts +19 -0
  258. package/output/core/functions/setFunction.js +75 -0
  259. package/output/core/functions/string.d.ts +26 -0
  260. package/output/core/functions/string.js +101 -0
  261. package/output/core/functions/subst.d.ts +90 -0
  262. package/output/core/functions/subst.js +498 -0
  263. package/output/core/functions/utils.d.ts +24 -0
  264. package/output/core/functions/utils.js +51 -0
  265. package/output/core/types.d.ts +48 -0
  266. package/output/core/types.js +2 -0
  267. package/output/index.d.ts +339 -0
  268. package/output/index.js +715 -0
  269. package/output/math/defint/defintDecimal.d.ts +37 -0
  270. package/output/math/defint/defintDecimal.js +320 -0
  271. package/output/math/defint/defintNative.d.ts +57 -0
  272. package/output/math/defint/defintNative.js +292 -0
  273. package/output/math/geometry.d.ts +8 -0
  274. package/output/math/geometry.js +32 -0
  275. package/output/math/math.d.ts +655 -0
  276. package/output/math/math.js +1811 -0
  277. package/output/math/trig.d.ts +518 -0
  278. package/output/math/trig.js +1444 -0
  279. package/output/math/trunc.d.ts +19 -0
  280. package/output/math/trunc.js +36 -0
  281. package/output/math/utils.d.ts +60 -0
  282. package/output/math/utils.js +180 -0
  283. package/output/solve/classes/DecimalMatrix.d.ts +17 -0
  284. package/output/solve/classes/DecimalMatrix.js +86 -0
  285. package/output/solve/classes/FunctionSolver.d.ts +135 -0
  286. package/output/solve/classes/FunctionSolver.js +433 -0
  287. package/output/solve/classes/MultivariateSolver.d.ts +84 -0
  288. package/output/solve/classes/MultivariateSolver.js +240 -0
  289. package/output/solve/classes/PolynomialSolver.d.ts +85 -0
  290. package/output/solve/classes/PolynomialSolver.js +292 -0
  291. package/output/solve/classes/SolutionSet.d.ts +153 -0
  292. package/output/solve/classes/SolutionSet.js +357 -0
  293. package/output/solve/classes/Solver.d.ts +17 -0
  294. package/output/solve/classes/Solver.js +132 -0
  295. package/output/solve/classes/SymbolicSolver.d.ts +74 -0
  296. package/output/solve/classes/SymbolicSolver.js +601 -0
  297. package/output/solve/linsolve.d.ts +51 -0
  298. package/output/solve/linsolve.js +225 -0
  299. package/output/solve/solve.d.ts +34 -0
  300. package/output/solve/solve.js +260 -0
  301. package/output/solve/solveSystem.d.ts +31 -0
  302. package/output/solve/solveSystem.js +290 -0
  303. package/output/solve/utils.d.ts +9 -0
  304. package/output/solve/utils.js +62 -0
  305. package/output/utils/array.d.ts +42 -0
  306. package/output/utils/array.js +98 -0
  307. package/output/utils/debug.d.ts +131 -0
  308. package/output/utils/debug.js +295 -0
  309. package/output/utils/decimal.d.ts +3 -0
  310. package/output/utils/decimal.js +16 -0
  311. package/output/utils/numeric.d.ts +14 -0
  312. package/output/utils/numeric.js +51 -0
  313. package/output/utils/object.d.ts +26 -0
  314. package/output/utils/object.js +56 -0
  315. package/package.json +213 -57
  316. package/.travis.yml +0 -3
  317. package/Algebra.js +0 -4553
  318. package/BREAKING_CHANGES.md +0 -5
  319. package/CODE_OF_CONDUCT.md +0 -46
  320. package/CONTRIBUTING.md +0 -14
  321. package/Calculus.js +0 -2671
  322. package/Extra.js +0 -622
  323. package/Solve.js +0 -1734
  324. package/all.js +0 -16
  325. package/all.min.js +0 -1
  326. package/gulpfile.js +0 -16
  327. package/index.html +0 -158
  328. package/license.txt +0 -19
  329. package/nerdamer.core.js +0 -12613
  330. package/spec/LaTeX.spec.js +0 -302
  331. package/spec/TeXConvert.spec.js +0 -8
  332. package/spec/algebra.spec.js +0 -839
  333. package/spec/basic_parser.spec.js +0 -134
  334. package/spec/build.spec.js +0 -131
  335. package/spec/calculus.spec.js +0 -182
  336. package/spec/core.spec.js +0 -2970
  337. package/spec/extra.spec.js +0 -54
  338. package/spec/solve.spec.js +0 -120
  339. package/spec/support/jasmine.json +0 -11
  340. package/spec/support/utils.js +0 -42
  341. package/spec/text.spec.js +0 -132
package/README.md CHANGED
@@ -1,398 +1,408 @@
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 math library for JavaScript and TypeScript. It can parse and manipulate algebraic expressions, solve equations, work with matrices and vectors, perform calculus, and evaluate expressions numerically.
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 the library. Everyday usage remains familiar, while the parser, solvers, numeric handling, public types, and internal architecture have been substantially reworked.
7
6
 
8
- Getting started with Nerdamer
7
+ ## Getting started with Nerdamer
9
8
 
10
- Load the library in your html page
9
+ Nerdamer 2.0 is currently available as a release candidate under the npm `next` tag:
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>
11
+ ```bash
12
+ npm install nerdamer@next
22
13
  ```
23
14
 
24
- Some functions have dependencies from other add-ons.
25
-
26
- You can see nerdamer in action at http://nerdamer.com/demo
15
+ When Nerdamer 2.0 becomes the stable `latest` release, the normal `npm install nerdamer` command will install the 2.x line.
27
16
 
28
- For full documentation go to http://nerdamer.com/documentation
17
+ ### Need to stay on the 1.x line?
29
18
 
30
- All operations are done using the 'nerdamer' object.
19
+ Nerdamer 2.0 contains substantial API and behavior changes. If an existing application cannot migrate to 2.0 yet, use [Nerdamer-Prime](https://github.com/together-science/nerdamer-prime), a separately maintained continuation of the earlier Nerdamer codebase:
31
20
 
32
- To add an expression just add it to the nerdamer object which will return a expression object.
21
+ ```bash
22
+ npm install nerdamer-prime
23
+ ```
33
24
 
34
- ```javascript
35
- var e = nerdamer('x^2+2*(cos(x)+x*x)');
36
- console.log(e.text());
25
+ Nerdamer-Prime is maintained separately from Nerdamer 2.0 and is the appropriate option for projects that need to remain closer to the 1.x API and package structure.
37
26
 
38
- //result:
39
- //2*cos(x)+3*x^2
40
- ```
27
+ In Node.js, require the package and start working with expressions:
41
28
 
42
- You can also pass in an object with known values as the second parameter.
29
+ ```javascript
30
+ const nerdamer = require('nerdamer');
43
31
 
44
- ```javascript
45
- var e = nerdamer('x^2+2*(cos(x)+x*x)',{x:6});
32
+ const e = nerdamer('x^2+2*(cos(x)+x*x)');
46
33
  console.log(e.text());
34
+ // 2*cos(x)+3*x^2
35
+ ```
47
36
 
48
- //result:
49
- //108+2*cos(6)
50
- ```
51
-
37
+ TypeScript and ESM users can use the default import:
52
38
 
53
- As you can see only the substitution is performed. To evaluate the result just call evaluate.
54
- Note that evaluate returns a text string or a number not an object.
39
+ ```typescript
40
+ import nerdamer from 'nerdamer';
55
41
 
56
- ```javascript
57
- var e = nerdamer('x^2+2*(cos(x)+x*x)',{x:6}).evaluate();
58
- console.log(e.text());
42
+ console.log(nerdamer('expand((x+1)^3)').text());
43
+ ```
59
44
 
60
- //result:
61
- //109.9203405733006
62
- ```
63
- To get back the text as a fraction, call the text method and pass in the string 'fractions'.
45
+ TypeScript projects that compile to CommonJS should enable `esModuleInterop`.
64
46
 
65
- ```javascript
66
- var e = nerdamer('x^2+2*(cos(x)+x*x)',{x:6}).evaluate();
67
- console.log(e.text('fractions'));
47
+ ### Browser use
68
48
 
69
- //result:
70
- //429607273/3908351
71
- ```
72
- You can get your expression back as LaTeX by calling the toTeX method
73
- ```javascript
74
- var LaTeX = nerdamer('x^2+2*(cos(x)+x*x)',{x:0.25}).toTeX();
75
- console.log(LaTeX);
49
+ The complete browser bundle is included in the package at `dist/bundle.js`. A standalone parser bundle is also available at `dist/parser.js`.
76
50
 
77
- //result:
78
- //2 \cdot \mathrm{cos}\left(\frac{1}{4}\right)+\frac{3}{16}
79
- ```
51
+ ```html
52
+ <script src="./node_modules/nerdamer/dist/bundle.js"></script>
53
+ <script>
54
+ const e = nerdamer('x^2+2*x+1');
55
+ console.log(e.text());
56
+ </script>
57
+ ```
80
58
 
81
- To have numbers returned as decimals pass in the string 'decimals' to the toTeX method
59
+ ## Everything is included
82
60
 
83
- ```javascript
84
- var LaTeX = nerdamer('x^2+2*(cos(x)+x*x)',{x:0.25}).toTeX('decimal');
85
- console.log(LaTeX);
61
+ Nerdamer 1.x was split into the core plus add-ons such as `Algebra.js`, `Calculus.js`, `Solve.js`, and `Extra.js`. Nerdamer 2.0 includes the commonly used algebra, calculus, solving, matrix, vector, and special-function features in the main package. Additional add-on imports are no longer required.
86
62
 
87
- //result:
88
- //2 \cdot \mathrm{cos}\left(0.25\right)+0.1875
89
- ```
63
+ ```javascript
64
+ const nerdamer = require('nerdamer');
90
65
 
91
- 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.
66
+ console.log(nerdamer.factor('x^2-1').text());
67
+ console.log(nerdamer.diff('x^3', 'x').text());
68
+ console.log(nerdamer.solve('x^2-4', 'x').text());
69
+ ```
92
70
 
93
- ```javascript
94
- var e = nerdamer('x^2+2*(cos(x)+x*x)',{x:'x^2+1'});
95
- console.log(e.text());
71
+ ## Expressions and substitutions
96
72
 
97
- //result:
98
- //2*cos(1+x^2)+3*(1+x^2)^2
99
- ```
73
+ As in earlier versions, calling `nerdamer(...)` parses an expression and returns a Nerdamer value.
100
74
 
101
- Every time you parse an expression it's stored in nerdamer. To get a list of all the expressions you just call
102
- nerdamer.expressions().
75
+ ```javascript
76
+ const e = nerdamer('x^2+2*(cos(x)+x*x)', { x: 6 });
77
+ console.log(e.text());
78
+ ```
103
79
 
104
- ```javascript
105
- var knownValues = {x:'x^2+1'};
106
- nerdamer('x^2+2*(cos(x)+x*x)').evaluate(knownValues);
107
- nerdamer('sin(x)^2+cos(x)^2').evaluate(knownValues);
80
+ Only substitution is performed by the values object. To numerically evaluate the result, call `evaluate()`:
108
81
 
109
- console.log(nerdamer.expressions());
82
+ ```javascript
83
+ const e = nerdamer('x^2+2*(cos(x)+x*x)', { x: 6 }).evaluate();
84
+ console.log(e.text());
85
+ ```
110
86
 
111
- //result:
112
- //[ 46.692712758272776, 1 ]
113
- ```
87
+ Values can themselves be expressions:
114
88
 
115
- You can request it as an object as well by passing in true. This can be convenient in some
116
- situations as the numbering starts at 1;
89
+ ```javascript
90
+ const e = nerdamer('x^2+2*(cos(x)+x*x)', { x: 'x^2+1' });
91
+ console.log(e.text());
92
+ ```
117
93
 
118
- ```javascript
119
- var knownValues = {x:'x^2+1'};
120
- nerdamer('x^2+2*(cos(x)+x*x)', knownValues );
121
- nerdamer('sin(x)^2+cos(x)^2', knownValues );
94
+ Parser results are always represented by Nerdamer-native values. A scalar expression returns an `Expression`; equations, vectors, matrices, sets, collections, dictionaries, and other supported structured inputs return the corresponding Nerdamer type rather than a JavaScript-native result shape.
122
95
 
123
- console.log(nerdamer.expressions(true));
96
+ ## Text output and term ordering
124
97
 
125
- //{ '1': '2*cos(1+x^(2))+3*(1+x^(2))^(2)',
126
- //'2': 'cos(1+x^(2))^(2)+sin(1+x^(2))^(2)' }
127
- ```
128
-
129
- Functions aren't always immediately parsed to numbers. For example
98
+ `text()` returns Nerdamer's normal symbolic representation. For example, a polynomial
99
+ may place the constant term first:
130
100
 
131
101
  ```javascript
132
- var result = nerdamer('cos(x)',{x:6});
133
- console.log(result.text());
134
- //cos(6)
102
+ const e = nerdamer('x^2+2*x+1');
103
+
104
+ e.text();
105
+ // 1+2*x+x^2
135
106
  ```
136
- will only subsitute out the variable name. To change this behaviour numer should be passed in as the 3rd argument.
107
+
108
+ Use the per-call `sort` option when conventional display order is preferred:
137
109
 
138
110
  ```javascript
139
- var result = nerdamer('cos(x)',{x:6}, 'numer');
140
- console.log(result.text());
141
- //0.960170286650366
111
+ e.text({ sort: true });
112
+ // x^2+2*x+1
113
+
114
+ nerdamer('(x+1)^2').expand().text({ sort: true });
115
+ // x^2+2*x+1
142
116
  ```
143
- or alternatively
117
+
118
+ Sorting affects only the returned string. It does not modify the expression or change the
119
+ process-wide `SORT_TERMS` setting. TypeScript users can import `TextOptions` from
120
+ `nerdamer` or `nerdamer/core`.
121
+
122
+ The full package also provides the chainable converter-based form:
144
123
 
145
124
  ```javascript
146
- var result = nerdamer('cos(x)').evaluate({x:6});
147
- console.log(result.text());
148
- //0.960170286650366
125
+ e.toText();
126
+ // x^2+2*x+1
149
127
  ```
150
- The difference however is that the first option directly substitutes the variables while the second first evaluates
151
- 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.
128
+
129
+ Use `text({ sort: true })` when you want Nerdamer text syntax with explicit per-call
130
+ ordering control. Use `toText()` when you simply want the conventional formatted-text
131
+ representation.
132
+
133
+ ## Algebra
134
+
135
+ Nerdamer can expand, factor, simplify, compute polynomial GCDs, and perform related symbolic algebra operations.
152
136
 
153
137
  ```javascript
154
- var result = nerdamer('sqrt(x)*sqrt(x)-2', {x: 2});
155
- console.log(result.text());
156
- //0
138
+ nerdamer('expand((x+1)^4)').text();
139
+ nerdamer.factor('x^4-1').text();
140
+ nerdamer.simplify('sin(x)^2+cos(x)^2').text();
141
+ nerdamer.gcd('x^2-1', 'x^2-2*x+1').text();
142
+
143
+ const completed = nerdamer.completeSquare('x^2+6*x+1');
144
+ completed.expression.text({ sort: true });
145
+
146
+ const [substituted, substitutions] = nerdamer.uSub(
147
+ 'cos(x)^2+cos(x)+1',
148
+ 'cos(x)'
149
+ );
150
+ nerdamer.uUnSub(substituted, substitutions);
157
151
  ```
158
- The above expample now returns zero whereas in previous version the result would be 4.440892098500626e-16. Same goes for 0.1+0.2.
159
152
 
160
- An expression can be replaced directly by passing in the index of which expression to override. For example
153
+ ## Solving equations
154
+
155
+ Use `solve` for a single equation:
161
156
 
162
157
  ```javascript
163
- nerdamer('cos(x)',{x:6}, 'numer');
164
- nerdamer('sin(x)+y',{x:6}, null, 1);
165
- console.log(nerdamer.expressions());
166
- //[ 'sin(6)+y' ]
158
+ const roots = nerdamer.solve('x^2-1', 'x');
159
+ console.log(roots.text());
160
+
161
+ roots.each(root => {
162
+ console.log(root.text());
163
+ });
167
164
  ```
168
165
 
169
- If multiple modifier options need to be passed into nerdamer you can do so using an array. For example ...
166
+ Single-variable solving returns a `SolutionSet`. System solving returns Nerdamer structures rather than the compatibility-only arrays used by older releases.
170
167
 
171
168
  ```javascript
172
- var e = nerdamer('cos(x)+(y-x)^2', {x:7}, ['expand', 'numer']);
173
- console.log(e.text());
174
- //-14*y+y^2+49.7539022543433
175
- ```
169
+ const solutions = nerdamer.solveSystem(
170
+ ['x+y=3', 'x-y=1'],
171
+ ['x', 'y']
172
+ );
176
173
 
177
- If you need the code as LaTeX you can pass in true as the second parameter when requesting the expressions.
174
+ console.log(solutions.text());
175
+ ```
178
176
 
179
- ```javascript
180
- nerdamer('x^2+2*(cos(x)+x*x)');
181
- nerdamer('sin(x)^0.25+cos(x)^0.5' );
182
- var asObject = true;
183
- var asLaTeX = true;
184
- console.log(nerdamer.expressions(asObject, asLaTeX));
177
+ ## Calculus
185
178
 
186
- /*{ '1': '2 \\cdot \\mathrm{cos}\\left(x\\right)+3 \\cdot x^{2}',
187
- '2': '\\sqrt{\\mathrm{cos}\\left(x\\right)}+\\mathrm{sin}\\left(x\\right)^{\\frac{1}{4}}' }*/
188
- ```
189
-
179
+ Differentiation, integration, limits, sums, products, and transforms are available without loading a separate add-on.
190
180
 
191
- You can specify a particular location when adding an expression, which is specified with the third parameter.
181
+ ```javascript
182
+ nerdamer.diff('x^3+sin(x)', 'x').text();
183
+ nerdamer.integrate('x^2', 'x').text();
184
+ nerdamer.limit('sin(x)/x', 'x', '0').text();
185
+ ```
192
186
 
193
- ```javascript
194
- nerdamer('x^2+2*(cos(x)+x*x)');
195
- nerdamer('sin(x)^0.25+cos(x)^0.5' );
196
- nerdamer('expr-override', undefined, 2 );
197
- var asObject = false;
198
- var asLaTeX = true;
199
- console.log(nerdamer.expressions(asObject, asLaTeX));
187
+ You can also use calculus functions inside expression strings:
200
188
 
201
- /* [ '2 \\cdot \\mathrm{cos}\\left(x\\right)+3 \\cdot x^{2}',
202
- '\\sqrt{\\mathrm{cos}\\left(x\\right)}+\\mathrm{sin}\\left(x\\right)^{\\frac{1}{4}}',
203
- 'expr-override' ]
204
- */
189
+ ```javascript
190
+ nerdamer('diff(x^2+2*(cos(x)+x*x),x)').text();
205
191
  ```
206
192
 
207
- Here's an example of reserved variable and function names.
193
+ ## Matrices and vectors
194
+
195
+ Matrices and vectors are supported directly by the parser and are also available as public TypeScript classes.
196
+
197
+ ```javascript
198
+ const m = nerdamer('matrix([1,2],[3,4])');
199
+ console.log(m.text());
208
200
 
209
- ```javascript
210
- var reserved = nerdamer.reserved();
211
- console.log(reserved);
212
- //result:
213
- /* 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 */
201
+ const v = nerdamer('vector(1,2,3)');
202
+ console.log(v.text());
214
203
 
215
- //or as an array
204
+ const basis = nerdamer.nullspace(nerdamer('matrix([1,2,3],[2,4,6])'));
205
+ console.log(basis.text());
206
+ ```
216
207
 
217
- var reserved = nerdamer.reserved(true);
218
- console.log(reserved);
219
- //result:
220
- /* [ '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',
221
- 'parens', 'sqrt', 'log', 'expand', 'abs', 'invert', 'transpose', 'dot' ] */
222
- ```
208
+ ## Runtime functions and constants
223
209
 
224
- 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
210
+ Custom symbolic functions can be defined with Nerdamer syntax:
225
211
 
226
- ```javascript
227
- var e = nerdamer('diff(x^2+2*(cos(x)+x*x),x)');
212
+ ```javascript
213
+ nerdamer('hyp(a,b):=sqrt(a^2+b^2)');
214
+ console.log(nerdamer('hyp(3,4)').evaluate().text());
215
+ ```
228
216
 
229
- console.log(e.text());
217
+ Or use the public function API:
230
218
 
231
- //result:
232
- //-2*sin(x)+6*x
219
+ ```javascript
220
+ nerdamer.setFunction('line', ['x', 'm', 'b'], 'm*x+b');
221
+ console.log(nerdamer('line(2,3,4)').text());
233
222
  ```
234
-
235
223
 
236
- Nerdamer can also handle runtime functions. To do this use the method setFunction.
237
- The runtime functions do have symbolic capabilities and support for imaginary numbers.
238
- The setfunction method is used as follows:
224
+ Constants can be registered as well:
239
225
 
240
- nerdamer.setFunction( function_name, parameter_array, function_body )
226
+ ```javascript
227
+ nerdamer.setConstant('g', 9.81);
228
+ console.log(nerdamer('100*g').text());
229
+ ```
241
230
 
242
- For Example:
231
+ ## Nerdamer scripting
243
232
 
244
- ```javascript
245
- //generate some points
246
- var f = function(x) { return 5*x-1; }
247
- console.log(f(1)); //4
248
- console.log(f(2)); //9 - value to be found
249
- console.log(f(7)); //34
233
+ Nerdamer includes a small symbolic scripting language in addition to ordinary expression notation. It supports user-defined functions, assignments, local bindings, conditionals, loops, blocks, logical operations, `return`, `break`, `continue`, and error-handling helpers.
250
234
 
251
- nerdamer.setFunction('interpolate',['y0','x0','y1','x1','x'],'y0+(y1-y0)*((x-x0)/(x1-x0))')
252
- var answer = nerdamer('interpolate(4,1,34,7,2)').evaluate();
235
+ ```javascript
236
+ const result = nerdamer('let(x,4,if(x>3,x^2,0))');
237
+ console.log(result.text());
238
+ ```
239
+
240
+ Multiple statements use semicolons as statement separators:
253
241
 
254
- console.log(answer);
242
+ ```javascript
243
+ const result = nerdamer(`
244
+ f(x):=x^2+1;
245
+ f(12)
246
+ `);
255
247
 
256
- //result: 9
248
+ console.log(result.text());
257
249
  ```
258
250
 
259
- Custom functions alternatively be set in following manner.
251
+ ## Build a JavaScript function
252
+
253
+ An expression can be compiled to a JavaScript function:
260
254
 
261
255
  ```javascript
262
- nerdamer('hyp(a, b) := sqrt(a^2 + b^2) ');
263
- var result = nerdamer('hyp(3, 4)').evaluate().text();
264
- console.log(result);
265
- //result: 5
266
- ```
267
-
268
-
269
- If you need to add a constant use the setConstant method
270
-
271
- ```javascript
272
- nerdamer.setConstant( 'g', 9.81);
273
- var weight = nerdamer('100*g').text();
274
- console.log(weight);
275
- //result:
276
- //981
277
- ```
278
-
279
- To delete just set it to delete
280
-
281
- ```javascript
282
- nerdamer.setConstant( 'g', 9.81);
283
- var weight = nerdamer('100*g').text();
284
- console.log(weight);
285
- //981
286
- nerdamer.setConstant( 'g', 'delete');
287
- var weight = nerdamer('100*g').text();
288
- console.log(weight);
289
- //100*g
290
- ```
291
-
292
- You also have the option of exporting your function to a javascript function which can be useful if you need some
293
- filtering from user input. Do keep in mind that the parameters are sorted alphabetically for more than one
294
- parameter. To use it add the expression to nerdamer and use the buildFunction method.
295
-
296
- ```javascript
297
- var f = nerdamer('x^2+5').buildFunction();
256
+ const f = nerdamer('x^2+5').buildFunction();
298
257
  console.log(f(9));
258
+ // 86
259
+ ```
299
260
 
300
- //result:
301
- //86
302
- ```
303
- 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:
261
+ You can specify the parameter order explicitly:
304
262
 
305
- ```javascript
306
- var f = nerdamer('z+x^2+y').buildFunction(['y', 'x', 'z']);
307
- console.log(f(9,2,1));
308
- //result
309
- //14
310
- ```
263
+ ```javascript
264
+ const f = nerdamer('z+x^2+y').buildFunction(['y', 'x', 'z']);
265
+ console.log(f(9, 2, 1));
266
+ // 14
267
+ ```
311
268
 
312
- Every time you add an expression to nerdamer it's stored. To list the expressions currently in nerdamer call
313
- the 'expressions' method. To delete an expression use the 'clear' method and pass in the expression you want to delete.
314
- To clear everything pass in the string 'all'.
269
+ The chained `buildFunction()` method is available on values returned by `nerdamer(...)` so this form remains convenient in TypeScript. Only scalar `Expression` results can be compiled. If the input parses to an `Equation`, `Vector`, `Matrix`, set, or another structured result, calling `buildFunction()` throws `UnexpectedDataType` rather than compiling the contained values independently.
315
270
 
316
- ```javascript
317
- nerdamer('n*R*T/v');
318
- nerdamer('mc^2');
319
- nerdamer('G*m1*m2/d^2');
271
+ `buildFunction()` uses dynamic JavaScript function construction. Applications with a Content Security Policy that forbids dynamic code generation should use Nerdamer's ordinary symbolic and numeric evaluation APIs instead.
320
272
 
321
- nerdamer.clear(2);
273
+ ## TeX
322
274
 
323
- console.log(nerdamer.expressions(true));
275
+ Convert Nerdamer expressions to TeX math markup with `toTeX()` or `convertToTeX()`:
324
276
 
325
- //result:
326
- //{ '1': 'R*T*n*v^(-1)', '2': 'G*d^(-2)*m1*m2' }
277
+ ```javascript
278
+ const e = nerdamer('x^2+2*x+1');
279
+ console.log(e.toTeX());
327
280
 
328
- nerdamer.clear('all');
329
- console.log(nerdamer.expressions(true));
330
- //result:
331
- //{}
332
- ```
333
-
334
- If you need go get the variables of an expression use the variables method. This method can be called after
335
- nerdamer was provided an expression. For example
281
+ console.log(nerdamer.convertToTeX('sqrt(x^2+1)'));
282
+ ```
283
+
284
+ The legacy `convertToLaTeX()` name remains available as a deprecated compatibility alias.
285
+
286
+ Nerdamer can also parse supported LaTeX expressions:
336
287
 
337
288
  ```javascript
338
- var variables = nerdamer('csc(x*cos(y))-no_boring_x').variables();
339
- console.log(variables);
340
- //result:
341
- //[ 'no_boring_x', 'x', 'y' ]
289
+ const e = nerdamer.convertFromLaTeX('\\frac{x^2+1}{2}');
290
+ console.log(e.text());
342
291
  ```
343
292
 
344
- The order in which the variables appear require a little bit of knowledge of how nerdamer organizes symbols. For the
345
- sake of simplicity we'll just assume that there is no particular order
293
+ ## Direct TypeScript imports
294
+
295
+ The callable `nerdamer` API remains available, but Nerdamer 2.0 also exposes public classes and functions through package subpaths:
296
+
297
+ ```typescript
298
+ import { Expression, Rational, type TextOptions } from 'nerdamer/core';
299
+ import {
300
+ Polynomial,
301
+ completeSquare,
302
+ gcd,
303
+ isPrime,
304
+ lcm,
305
+ polyFactors,
306
+ uSub,
307
+ uUnSub,
308
+ } from 'nerdamer/algebra';
309
+ import { diff, integrate, limit } from 'nerdamer/calculus';
310
+ import { solve, PolynomialSolver } from 'nerdamer/solve';
311
+ import { Matrix, Vector, ValuesSet, nullspace } from 'nerdamer/structures';
312
+ ```
346
313
 
347
- ----------------------------------------------------------------------------------------------------------------------
314
+ Additional entry points are available for assumptions, selected parser APIs, advanced algorithms, and debugging tools.
348
315
 
349
- Using the solver
350
- ===============
351
- 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.
352
- ```javascript
353
- var sol = nerdamer.solveEquations('x^3+8=x^2+6','x');
354
- console.log(sol.toString());
355
- //1+i,-i+1,-1
316
+ ## Assumptions
317
+
318
+ Nerdamer can register numeric interval assumptions for symbols. Assumptions are process-wide and are used by symbolic comparisons and simplifications that depend on sign or range information.
319
+
320
+ ```typescript
321
+ import nerdamer from 'nerdamer';
322
+ import { assume, clearAssumptions } from 'nerdamer/assumptions';
323
+
324
+ assume('x > 0');
325
+
326
+ console.log(nerdamer('sqrt(x^2)').text());
327
+ // x
328
+
329
+ clearAssumptions();
356
330
  ```
357
331
 
358
- Notice that we use toString rather than text as this returns a javascript array.
332
+ Repeated assumptions for the same symbol are intersected. Contradictory assumptions are rejected instead of silently replacing the existing range.
333
+
334
+ ## Localized error messages
335
+
336
+ Nerdamer includes localized built-in error messages for English, Spanish, French, German, Portuguese, Italian, and Dutch. Select the language through the shared parser settings:
359
337
 
360
- You can also solve an expression
361
338
  ```javascript
362
- var e = nerdamer.solveEquations('x^2+4-y', 'y');
363
- console.log(e[0].text());
364
- //4+x^2
339
+ nerdamer.set('LANGUAGE', 'spa');
340
+
341
+ // Restore English when needed.
342
+ nerdamer.set('LANGUAGE', 'eng');
365
343
  ```
366
344
 
367
- You can also solve multivariate equations
345
+ The language codes are `eng`, `spa`, `fra`, `deu`, `por`, `ita`, and `nld`.
346
+
347
+ ## Numeric precision
348
+
349
+ Nerdamer keeps exact rational and integer arithmetic where possible. Decimal arithmetic uses Decimal.js and large integers use native `BigInt`.
350
+
368
351
  ```javascript
369
- var sol = nerdamer.solveEquations('x^2+8+y=x+6','x');
370
- console.log(sol.toString());
371
- //0.5*((-4*y-7)^0.5+1),0.5*(-(-4*y-7)^0.5+1)
352
+ nerdamer('0.1+0.2').text();
353
+ nerdamer('sqrt(2)').evaluate().text();
372
354
  ```
373
- You can do up to 3rd order polynomials for multivariate polynomials
374
355
 
375
- 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.
356
+ ## What changed in 2.0
376
357
 
377
- ```javascript
378
- var sol = nerdamer.solveEquations('cos(x)+cos(3*x)=1','x');
379
- console.log(sol.toString());
380
- //5.7981235959208695,0.4850617112587174
358
+ Nerdamer 2.0 keeps the familiar expression-oriented API, but it is a new implementation rather than a continuation of the 1.x source tree. Important changes include:
359
+
360
+ - the old add-on loading system is gone;
361
+ - TypeScript declarations ship with the package;
362
+ - Nerdamer no longer keeps a global history of every parsed expression;
363
+ - parser-facing APIs consistently return Nerdamer-native values instead of mixing Nerdamer types with JavaScript-native result shapes;
364
+ - solver result types are explicit public structures;
365
+ - lower-level 1.x extension hooks such as `getCore()` and `register()` are not exposed in the same way;
366
+ - decimal, complex-number, parser, solver, assumptions, and set handling have been substantially revised.
367
+
368
+ If an existing project cannot move to Nerdamer 2.0 yet, use [Nerdamer-Prime](https://github.com/together-science/nerdamer-prime), which continues the earlier Nerdamer line under the `nerdamer-prime` npm package.
369
+
370
+ For the current documentation, examples, and migration information, visit [nerdamer.com](https://nerdamer.com/).
371
+
372
+ ## Documentation and playground
373
+
374
+ - Website: [nerdamer.com](https://nerdamer.com/)
375
+ - Documentation: [nerdamer.com/docs](https://nerdamer.com/docs/)
376
+ - Playground: [nerdamer.com/playground](https://nerdamer.com/playground/)
377
+
378
+ ## Development
379
+
380
+ Run the type checker:
381
+
382
+ ```bash
383
+ npm run typecheck
381
384
  ```
382
- To solve a system of linear equations pass them in as an array. For example
383
385
 
384
- ```javascript
385
- var sol = nerdamer.solveEquations(['x+y=1', '2*x=6', '4*z+y=6']);
386
- console.log(sol);
387
- //[ [ 'x', 3 ], [ 'y', -2 ], [ 'z', 2 ] ]
386
+ Run the tests:
387
+
388
+ ```bash
389
+ npm test
388
390
  ```
389
- In version 0.7.2 and up the solver can additionally be used in the following way
390
- ```javascript
391
- //first parse the equation
392
- var x = nerdamer('x^2+2=y-7*a');
393
- //You can make substitutions to the equation
394
- x = x.evaluate({a: 'x^2-3'});
395
- console.log(x.toString()); //2+x^2=-7*x^2+21+y
396
- var solutions = x.solveFor('x');
397
- console.log(solutions.toString()); //(1/16)*sqrt(32*y+608),(-1/16)*sqrt(32*y+608)
391
+
392
+ Build the complete package:
393
+
394
+ ```bash
395
+ npm run build
398
396
  ```
397
+
398
+ Validate the npm package as an installed consumer:
399
+
400
+ ```bash
401
+ npm run validate:package
402
+ ```
403
+
404
+ The publish hook runs tests, builds the package and parser bundle, generates parser documentation data, and validates the packed npm artifact before publication.
405
+
406
+ ## License
407
+
408
+ Nerdamer 2.0 is licensed under the Apache License 2.0.