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
@@ -0,0 +1,665 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EULER_GAMMA = void 0;
7
+ exports.erf = erf;
8
+ exports.gamma = gamma;
9
+ exports.sinc = sinc;
10
+ exports.Si = Si;
11
+ exports.Shi = Shi;
12
+ exports.Ci = Ci;
13
+ exports.Chi = Chi;
14
+ exports.Ei = Ei;
15
+ exports.Li = Li;
16
+ const decimal_js_1 = __importDefault(require("decimal.js"));
17
+ const errors_1 = require("../errors");
18
+ const bigint_1 = require("./bigint/bigint");
19
+ /*
20
+ * TODO: Currently only up to a 100 digits. This will need to be calculated in the future.
21
+ */
22
+ exports.EULER_GAMMA = new decimal_js_1.default('0.5772156649015328606065120900824024310421593359399235988057672348848677267776646709369470632917467495');
23
+ const DEFAULT_SERIES_GUARD_DIGITS = 8;
24
+ const MIN_PRECISION_SERIES_ITERATIONS = 1000;
25
+ const SERIES_ITERATIONS_PER_PRECISION_DIGIT = 8;
26
+ const DECIMAL_SINC_SERIES_CUTOFF = '1e-8';
27
+ const OSCILLATORY_ASYMPTOTIC_CUTOFF = 1e9;
28
+ const RATIONAL_APPROXIMATION_CUTOFF = 4;
29
+ const ASYMPTOTIC_APPROXIMATION_CUTOFF = 8;
30
+ const EXPONENTIAL_ASYMPTOTIC_CUTOFF = 40;
31
+ const SERIES_MAX_ITERATIONS = 200;
32
+ const ASYMPTOTIC_MAX_TERMS = 100;
33
+ const POWER_SERIES_MAX_TERMS = 500;
34
+ function getSeriesError(guardDigits = DEFAULT_SERIES_GUARD_DIGITS) {
35
+ return new decimal_js_1.default(10).pow(-(decimal_js_1.default.precision + guardDigits));
36
+ }
37
+ function gammaSpouge(x) {
38
+ const precision = decimal_js_1.default.precision;
39
+ decimal_js_1.default.set({ precision: Math.floor(precision * 1.45) });
40
+ try {
41
+ const n = precision;
42
+ const coeffs = calcCoeffs(n);
43
+ let accm = coeffs[0];
44
+ for (let k = 1; k < n; k++) {
45
+ accm = accm.plus(coeffs[k].div(x.plus(k)));
46
+ }
47
+ accm = accm.times(decimal_js_1.default.exp(x.plus(n).neg())).times(decimal_js_1.default.pow(x.plus(n), x.plus(0.5)));
48
+ return accm.div(x);
49
+ }
50
+ finally {
51
+ decimal_js_1.default.set({ precision });
52
+ }
53
+ }
54
+ function erf(x) {
55
+ x = new decimal_js_1.default(x);
56
+ const pi = decimal_js_1.default.acos(-1);
57
+ const twoOverSqrtPi = new decimal_js_1.default(2).div(pi.sqrt());
58
+ const error = getSeriesError();
59
+ const sgn = decimal_js_1.default.sign(x);
60
+ x = x.abs();
61
+ if (x.isZero()) {
62
+ return new decimal_js_1.default(0);
63
+ }
64
+ if (x.lt(2)) {
65
+ let sum = new decimal_js_1.default(0);
66
+ let k = 0;
67
+ let dx = x;
68
+ const max = Math.max(MIN_PRECISION_SERIES_ITERATIONS, decimal_js_1.default.precision * SERIES_ITERATIONS_PER_PRECISION_DIGIT);
69
+ while (dx.gte(error)) {
70
+ const num = new decimal_js_1.default(-1).pow(k).times(x.pow(2 * k + 1));
71
+ const den = new decimal_js_1.default(2 * k + 1).times(String((0, bigint_1.factorial)(k)));
72
+ const result = sum.plus(num.div(den));
73
+ dx = result.minus(sum).abs();
74
+ sum = result;
75
+ k++;
76
+ if (k > max) {
77
+ throw new Error((0, errors_1.message)('erfConvergenceFailed'));
78
+ }
79
+ }
80
+ let retval = decimal_js_1.default.min(twoOverSqrtPi.times(sum), 1);
81
+ if (sgn === -1) {
82
+ retval = retval.neg();
83
+ }
84
+ return retval;
85
+ }
86
+ // Asymptotic expansion of erfc(x) for larger |x|:
87
+ // erfc(x) ~ exp(-x^2)/(sqrt(pi)*x) * (1 - 1/(2x^2) + 3/(4x^4) - 15/(8x^6) + ...)
88
+ const xx = x.mul(x);
89
+ const twoX2 = xx.mul(2);
90
+ let term = new decimal_js_1.default(1);
91
+ let series = term;
92
+ let best = term.abs();
93
+ const max = Math.max(MIN_PRECISION_SERIES_ITERATIONS, decimal_js_1.default.precision * SERIES_ITERATIONS_PER_PRECISION_DIGIT);
94
+ for (let n = 1; n < max; n++) {
95
+ term = term.mul(-(2 * n - 1)).div(twoX2);
96
+ const at = term.abs();
97
+ if (at.gt(best)) {
98
+ break;
99
+ }
100
+ best = at;
101
+ series = series.plus(term);
102
+ if (at.lt(error)) {
103
+ break;
104
+ }
105
+ }
106
+ const erfc = x.neg().mul(x).exp().div(pi.sqrt().mul(x)).times(series);
107
+ let retval = new decimal_js_1.default(1).minus(erfc);
108
+ if (sgn === -1) {
109
+ retval = retval.neg();
110
+ }
111
+ return retval;
112
+ }
113
+ function calcCoeffs(n) {
114
+ const c = [];
115
+ let kFact = new decimal_js_1.default(1);
116
+ // Get pi
117
+ const pi = decimal_js_1.default.acos(-1);
118
+ // sqrt(2*pi);
119
+ c[0] = pi.times(2).sqrt();
120
+ for (let k = 1; k < n; k++) {
121
+ c[k] = decimal_js_1.default.exp(n - k)
122
+ .times(decimal_js_1.default.pow(n - k, k - 0.5))
123
+ .div(kFact);
124
+ kFact = kFact.times(-k);
125
+ }
126
+ return c;
127
+ }
128
+ // https://math.stackexchange.com/questions/2204020/definition-of-the-gamma-function-for-non-integer-negative-values
129
+ /**
130
+ * The gamma function using Spouge approximation.
131
+ * This function is slow converging but appropriate for arbitrary precision. It relies on Decimal.js.
132
+ *
133
+ * Ported from: https://rosettacode.org/wiki/Gamma_function#C++ (the implementation)
134
+ * https://math.stackexchange.com/questions/2204020/definition-of-the-gamma-function-for-non-integer-negative-values (negative gamma)
135
+ * https://en.wikipedia.org/wiki/Spouge%27s_approximation (Spouge's Approximation)
136
+ *
137
+ * @param n The number of elements to be calculated in the coefficient array
138
+ * @param x The number being evaluated
139
+ * @returns
140
+ */
141
+ function gamma(x) {
142
+ x = new decimal_js_1.default(x);
143
+ if (x.isInteger()) {
144
+ if (x.lte(0)) {
145
+ return new decimal_js_1.default(Infinity);
146
+ }
147
+ return new decimal_js_1.default(String((0, bigint_1.factorial)(Number(x.minus(1)))));
148
+ }
149
+ if (x.lt(0)) {
150
+ const pi = decimal_js_1.default.acos(-1);
151
+ return pi.div(pi
152
+ .times(x)
153
+ .sin()
154
+ .times(gammaSpouge(new decimal_js_1.default(1).minus(x))));
155
+ }
156
+ return gammaSpouge(x);
157
+ }
158
+ function sinc(x) {
159
+ const d = new decimal_js_1.default(x);
160
+ if (d.isZero()) {
161
+ return new decimal_js_1.default(1);
162
+ }
163
+ const ax = d.abs();
164
+ if (ax.lt(DECIMAL_SINC_SERIES_CUTOFF)) {
165
+ const x2 = d.mul(d);
166
+ return new decimal_js_1.default(1)
167
+ .minus(x2.div(6))
168
+ .plus(x2.mul(x2).div(120))
169
+ .minus(x2.mul(x2).mul(x2).div(5040));
170
+ }
171
+ return d.sin().div(d);
172
+ }
173
+ function Si(x) {
174
+ let d = new decimal_js_1.default(x);
175
+ if (d.isZero()) {
176
+ return new decimal_js_1.default(0);
177
+ }
178
+ let sign = new decimal_js_1.default(1);
179
+ if (d.isNeg()) {
180
+ sign = new decimal_js_1.default(-1);
181
+ d = d.neg();
182
+ }
183
+ function polevl(y, coef) {
184
+ let ans = coef[0];
185
+ for (let i = 1; i < coef.length; i++) {
186
+ ans = ans.mul(y).plus(coef[i]);
187
+ }
188
+ return ans;
189
+ }
190
+ function p1evl(y, coef) {
191
+ let ans = y.plus(coef[0]);
192
+ for (let i = 1; i < coef.length; i++) {
193
+ ans = ans.mul(y).plus(coef[i]);
194
+ }
195
+ return ans;
196
+ }
197
+ if (d.gt(OSCILLATORY_ASYMPTOTIC_CUTOFF)) {
198
+ const halfPi = decimal_js_1.default.acos(-1).div(2);
199
+ return sign.mul(halfPi.minus(d.cos().div(d)));
200
+ }
201
+ if (d.lte(RATIONAL_APPROXIMATION_CUTOFF)) {
202
+ const SN = [
203
+ new decimal_js_1.default('-8.39167827910303881427e-11'),
204
+ new decimal_js_1.default('4.62591714427012837309e-8'),
205
+ new decimal_js_1.default('-9.75759303843632795789e-6'),
206
+ new decimal_js_1.default('9.76945438170435310816e-4'),
207
+ new decimal_js_1.default('-4.13470316229406538752e-2'),
208
+ new decimal_js_1.default('1.00000000000000000302'),
209
+ ];
210
+ const SD = [
211
+ new decimal_js_1.default('2.03269266195951942049e-12'),
212
+ new decimal_js_1.default('1.27997891179943299903e-9'),
213
+ new decimal_js_1.default('4.41827842801218905784e-7'),
214
+ new decimal_js_1.default('9.96412122043875552487e-5'),
215
+ new decimal_js_1.default('1.42085239326149893930e-2'),
216
+ new decimal_js_1.default('9.99999999999999996984e-1'),
217
+ ];
218
+ const z = d.mul(d);
219
+ const s = d.mul(polevl(z, SN)).div(polevl(z, SD));
220
+ return sign.mul(s);
221
+ }
222
+ const s = d.sin();
223
+ const c = d.cos();
224
+ const z = new decimal_js_1.default(1).div(d.mul(d));
225
+ let f;
226
+ let g;
227
+ if (d.lt(ASYMPTOTIC_APPROXIMATION_CUTOFF)) {
228
+ const FN4 = [
229
+ new decimal_js_1.default('4.23612862892216586994'),
230
+ new decimal_js_1.default('5.45937717161812843388'),
231
+ new decimal_js_1.default('1.62083287701538329132'),
232
+ new decimal_js_1.default('1.67006611831323023771e-1'),
233
+ new decimal_js_1.default('6.81020132472518137426e-3'),
234
+ new decimal_js_1.default('1.08936580650328664411e-4'),
235
+ new decimal_js_1.default('5.48900223421373614008e-7'),
236
+ ];
237
+ const FD4 = [
238
+ new decimal_js_1.default('8.16496634205391016773'),
239
+ new decimal_js_1.default('7.30828822505564552187'),
240
+ new decimal_js_1.default('1.86792257950184183883'),
241
+ new decimal_js_1.default('1.78792052963149907262e-1'),
242
+ new decimal_js_1.default('7.01710668322789753610e-3'),
243
+ new decimal_js_1.default('1.10034357153915731354e-4'),
244
+ new decimal_js_1.default('5.48900252756255700982e-7'),
245
+ ];
246
+ const GN4 = [
247
+ new decimal_js_1.default('8.71001698973114191777e-2'),
248
+ new decimal_js_1.default('6.11379109952219284151e-1'),
249
+ new decimal_js_1.default('3.97180296392337498885e-1'),
250
+ new decimal_js_1.default('7.48527737628469092119e-2'),
251
+ new decimal_js_1.default('5.38868681462177273157e-3'),
252
+ new decimal_js_1.default('1.61999794598934024525e-4'),
253
+ new decimal_js_1.default('1.97963874140963632189e-6'),
254
+ new decimal_js_1.default('7.82579040744090311069e-9'),
255
+ ];
256
+ const GD4 = [
257
+ new decimal_js_1.default('1.64402202413355338886'),
258
+ new decimal_js_1.default('6.66296701268987968381e-1'),
259
+ new decimal_js_1.default('9.88771761277688796203e-2'),
260
+ new decimal_js_1.default('6.22396345441768420760e-3'),
261
+ new decimal_js_1.default('1.73221081474177119497e-4'),
262
+ new decimal_js_1.default('2.02659182086343991969e-6'),
263
+ new decimal_js_1.default('7.82579218933534490868e-9'),
264
+ ];
265
+ f = polevl(z, FN4).div(d.mul(p1evl(z, FD4)));
266
+ g = z.mul(polevl(z, GN4)).div(p1evl(z, GD4));
267
+ }
268
+ else {
269
+ const FN8 = [
270
+ new decimal_js_1.default('4.55880873470465315206e-1'),
271
+ new decimal_js_1.default('7.13715274100146711374e-1'),
272
+ new decimal_js_1.default('1.60300158222319456320e-1'),
273
+ new decimal_js_1.default('1.16064229408124407915e-2'),
274
+ new decimal_js_1.default('3.49556442447859055605e-4'),
275
+ new decimal_js_1.default('4.86215430826454749482e-6'),
276
+ new decimal_js_1.default('3.20092790091004902806e-8'),
277
+ new decimal_js_1.default('9.41779576128512936592e-11'),
278
+ new decimal_js_1.default('9.70507110881952024631e-14'),
279
+ ];
280
+ const FD8 = [
281
+ new decimal_js_1.default('9.17463611873684053703e-1'),
282
+ new decimal_js_1.default('1.78685545332074536321e-1'),
283
+ new decimal_js_1.default('1.22253594771971293032e-2'),
284
+ new decimal_js_1.default('3.58696481881851580297e-4'),
285
+ new decimal_js_1.default('4.92435064317881464393e-6'),
286
+ new decimal_js_1.default('3.21956939101046018377e-8'),
287
+ new decimal_js_1.default('9.43720590350276732376e-11'),
288
+ new decimal_js_1.default('9.70507110881952025725e-14'),
289
+ ];
290
+ const GN8 = [
291
+ new decimal_js_1.default('6.97359953443276214934e-1'),
292
+ new decimal_js_1.default('3.30410979305632063225e-1'),
293
+ new decimal_js_1.default('3.84878767649974295920e-2'),
294
+ new decimal_js_1.default('1.71718239052347903558e-3'),
295
+ new decimal_js_1.default('3.48941165502279436777e-5'),
296
+ new decimal_js_1.default('3.47131167084116673800e-7'),
297
+ new decimal_js_1.default('1.70404452782044526189e-9'),
298
+ new decimal_js_1.default('3.85945925430276600453e-12'),
299
+ new decimal_js_1.default('3.14040098946363334640e-15'),
300
+ ];
301
+ const GD8 = [
302
+ new decimal_js_1.default('1.68548898811011640017'),
303
+ new decimal_js_1.default('4.87852258695304967486e-1'),
304
+ new decimal_js_1.default('4.67913194259625806320e-2'),
305
+ new decimal_js_1.default('1.90284426674399523638e-3'),
306
+ new decimal_js_1.default('3.68475504442561108162e-5'),
307
+ new decimal_js_1.default('3.57043223443740838771e-7'),
308
+ new decimal_js_1.default('1.72693748966316146736e-9'),
309
+ new decimal_js_1.default('3.87830166023954706752e-12'),
310
+ new decimal_js_1.default('3.14040098946363335242e-15'),
311
+ ];
312
+ f = polevl(z, FN8).div(d.mul(p1evl(z, FD8)));
313
+ g = z.mul(polevl(z, GN8)).div(p1evl(z, GD8));
314
+ }
315
+ const halfPi = decimal_js_1.default.acos(-1).div(2);
316
+ return sign.mul(halfPi.minus(f.mul(c)).minus(g.mul(s)));
317
+ }
318
+ function Shi(x) {
319
+ const d = new decimal_js_1.default(x);
320
+ if (d.isZero()) {
321
+ return new decimal_js_1.default(0);
322
+ }
323
+ const sign = d.isNeg() ? new decimal_js_1.default(-1) : new decimal_js_1.default(1);
324
+ const ax = d.abs();
325
+ if (ax.lt(ASYMPTOTIC_APPROXIMATION_CUTOFF)) {
326
+ let term = ax;
327
+ let sum = term;
328
+ let n = 0;
329
+ for (let iter = 0; iter < SERIES_MAX_ITERATIONS; iter++) {
330
+ const a = 2 * n + 1;
331
+ term = term
332
+ .mul(ax)
333
+ .mul(ax)
334
+ .mul(a)
335
+ .div(new decimal_js_1.default(a + 2).mul(a + 2).mul(a + 1));
336
+ sum = sum.plus(term);
337
+ n++;
338
+ if (term.abs().lt(getSeriesError())) {
339
+ break;
340
+ }
341
+ }
342
+ return sign.mul(sum);
343
+ }
344
+ function EiLocal(y) {
345
+ if (y.isZero()) {
346
+ return new decimal_js_1.default(-Infinity);
347
+ }
348
+ if (y.gt(EXPONENTIAL_ASYMPTOTIC_CUTOFF) || y.lt(-EXPONENTIAL_ASYMPTOTIC_CUTOFF)) {
349
+ let term = new decimal_js_1.default(1);
350
+ let sum = new decimal_js_1.default(1);
351
+ let best = term.abs();
352
+ for (let n = 1; n < ASYMPTOTIC_MAX_TERMS; n++) {
353
+ term = term.mul(n).div(y);
354
+ const at = term.abs();
355
+ if (at.gt(best)) {
356
+ break;
357
+ }
358
+ best = at;
359
+ sum = sum.plus(term);
360
+ if (at.lt(getSeriesError())) {
361
+ break;
362
+ }
363
+ }
364
+ return y.exp().mul(sum).div(y);
365
+ }
366
+ let term = y;
367
+ let sum = term;
368
+ for (let k = 1; k < POWER_SERIES_MAX_TERMS; k++) {
369
+ term = term
370
+ .mul(y)
371
+ .mul(k)
372
+ .div(new decimal_js_1.default(k + 1).mul(k + 1));
373
+ sum = sum.plus(term);
374
+ if (term.abs().lt(getSeriesError())) {
375
+ break;
376
+ }
377
+ }
378
+ return exports.EULER_GAMMA.plus(y.abs().ln()).plus(sum);
379
+ }
380
+ return EiLocal(d).minus(EiLocal(d.neg())).div(2);
381
+ }
382
+ function Ci(x) {
383
+ let d = new decimal_js_1.default(x);
384
+ if (d.isZero()) {
385
+ return new decimal_js_1.default(-Infinity);
386
+ }
387
+ if (d.isNeg()) {
388
+ d = d.neg();
389
+ }
390
+ function polevl(y, coef) {
391
+ let ans = coef[0];
392
+ for (let i = 1; i < coef.length; i++) {
393
+ ans = ans.mul(y).plus(coef[i]);
394
+ }
395
+ return ans;
396
+ }
397
+ function p1evl(y, coef) {
398
+ let ans = y.plus(coef[0]);
399
+ for (let i = 1; i < coef.length; i++) {
400
+ ans = ans.mul(y).plus(coef[i]);
401
+ }
402
+ return ans;
403
+ }
404
+ if (d.gt(OSCILLATORY_ASYMPTOTIC_CUTOFF)) {
405
+ return d.sin().div(d);
406
+ }
407
+ if (d.lte(RATIONAL_APPROXIMATION_CUTOFF)) {
408
+ const CN = [
409
+ new decimal_js_1.default('2.02524002389102268789e-11'),
410
+ new decimal_js_1.default('-1.35249504915790756375e-8'),
411
+ new decimal_js_1.default('3.59325051419993077021e-6'),
412
+ new decimal_js_1.default('-4.74007206873407909465e-4'),
413
+ new decimal_js_1.default('2.89159652607555242092e-2'),
414
+ new decimal_js_1.default('-1.00000000000000000080'),
415
+ ];
416
+ const CD = [
417
+ new decimal_js_1.default('4.07746040061880559506e-12'),
418
+ new decimal_js_1.default('3.06780997581887812692e-9'),
419
+ new decimal_js_1.default('1.23210355685883423679e-6'),
420
+ new decimal_js_1.default('3.17442024775032769882e-4'),
421
+ new decimal_js_1.default('5.10028056236446052392e-2'),
422
+ new decimal_js_1.default('4.00000000000000000080'),
423
+ ];
424
+ const z = d.mul(d);
425
+ const c0 = z.mul(polevl(z, CN)).div(polevl(z, CD));
426
+ return exports.EULER_GAMMA.plus(d.ln()).plus(c0);
427
+ }
428
+ const s = d.sin();
429
+ const c = d.cos();
430
+ const z = new decimal_js_1.default(1).div(d.mul(d));
431
+ let f;
432
+ let g;
433
+ if (d.lt(ASYMPTOTIC_APPROXIMATION_CUTOFF)) {
434
+ const FN4 = [
435
+ new decimal_js_1.default('4.23612862892216586994'),
436
+ new decimal_js_1.default('5.45937717161812843388'),
437
+ new decimal_js_1.default('1.62083287701538329132'),
438
+ new decimal_js_1.default('1.67006611831323023771e-1'),
439
+ new decimal_js_1.default('6.81020132472518137426e-3'),
440
+ new decimal_js_1.default('1.08936580650328664411e-4'),
441
+ new decimal_js_1.default('5.48900223421373614008e-7'),
442
+ ];
443
+ const FD4 = [
444
+ new decimal_js_1.default('8.16496634205391016773'),
445
+ new decimal_js_1.default('7.30828822505564552187'),
446
+ new decimal_js_1.default('1.86792257950184183883'),
447
+ new decimal_js_1.default('1.78792052963149907262e-1'),
448
+ new decimal_js_1.default('7.01710668322789753610e-3'),
449
+ new decimal_js_1.default('1.10034357153915731354e-4'),
450
+ new decimal_js_1.default('5.48900252756255700982e-7'),
451
+ ];
452
+ const GN4 = [
453
+ new decimal_js_1.default('8.71001698973114191777e-2'),
454
+ new decimal_js_1.default('6.11379109952219284151e-1'),
455
+ new decimal_js_1.default('3.97180296392337498885e-1'),
456
+ new decimal_js_1.default('7.48527737628469092119e-2'),
457
+ new decimal_js_1.default('5.38868681462177273157e-3'),
458
+ new decimal_js_1.default('1.61999794598934024525e-4'),
459
+ new decimal_js_1.default('1.97963874140963632189e-6'),
460
+ new decimal_js_1.default('7.82579040744090311069e-9'),
461
+ ];
462
+ const GD4 = [
463
+ new decimal_js_1.default('1.64402202413355338886'),
464
+ new decimal_js_1.default('6.66296701268987968381e-1'),
465
+ new decimal_js_1.default('9.88771761277688796203e-2'),
466
+ new decimal_js_1.default('6.22396345441768420760e-3'),
467
+ new decimal_js_1.default('1.73221081474177119497e-4'),
468
+ new decimal_js_1.default('2.02659182086343991969e-6'),
469
+ new decimal_js_1.default('7.82579218933534490868e-9'),
470
+ ];
471
+ f = polevl(z, FN4).div(d.mul(p1evl(z, FD4)));
472
+ g = z.mul(polevl(z, GN4)).div(p1evl(z, GD4));
473
+ }
474
+ else {
475
+ const FN8 = [
476
+ new decimal_js_1.default('4.55880873470465315206e-1'),
477
+ new decimal_js_1.default('7.13715274100146711374e-1'),
478
+ new decimal_js_1.default('1.60300158222319456320e-1'),
479
+ new decimal_js_1.default('1.16064229408124407915e-2'),
480
+ new decimal_js_1.default('3.49556442447859055605e-4'),
481
+ new decimal_js_1.default('4.86215430826454749482e-6'),
482
+ new decimal_js_1.default('3.20092790091004902806e-8'),
483
+ new decimal_js_1.default('9.41779576128512936592e-11'),
484
+ new decimal_js_1.default('9.70507110881952024631e-14'),
485
+ ];
486
+ const FD8 = [
487
+ new decimal_js_1.default('9.17463611873684053703e-1'),
488
+ new decimal_js_1.default('1.78685545332074536321e-1'),
489
+ new decimal_js_1.default('1.22253594771971293032e-2'),
490
+ new decimal_js_1.default('3.58696481881851580297e-4'),
491
+ new decimal_js_1.default('4.92435064317881464393e-6'),
492
+ new decimal_js_1.default('3.21956939101046018377e-8'),
493
+ new decimal_js_1.default('9.43720590350276732376e-11'),
494
+ new decimal_js_1.default('9.70507110881952025725e-14'),
495
+ ];
496
+ const GN8 = [
497
+ new decimal_js_1.default('6.97359953443276214934e-1'),
498
+ new decimal_js_1.default('3.30410979305632063225e-1'),
499
+ new decimal_js_1.default('3.84878767649974295920e-2'),
500
+ new decimal_js_1.default('1.71718239052347903558e-3'),
501
+ new decimal_js_1.default('3.48941165502279436777e-5'),
502
+ new decimal_js_1.default('3.47131167084116673800e-7'),
503
+ new decimal_js_1.default('1.70404452782044526189e-9'),
504
+ new decimal_js_1.default('3.85945925430276600453e-12'),
505
+ new decimal_js_1.default('3.14040098946363334640e-15'),
506
+ ];
507
+ const GD8 = [
508
+ new decimal_js_1.default('1.68548898811011640017'),
509
+ new decimal_js_1.default('4.87852258695304967486e-1'),
510
+ new decimal_js_1.default('4.67913194259625806320e-2'),
511
+ new decimal_js_1.default('1.90284426674399523638e-3'),
512
+ new decimal_js_1.default('3.68475504442561108162e-5'),
513
+ new decimal_js_1.default('3.57043223443740838771e-7'),
514
+ new decimal_js_1.default('1.72693748966316146736e-9'),
515
+ new decimal_js_1.default('3.87830166023954706752e-12'),
516
+ new decimal_js_1.default('3.14040098946363335242e-15'),
517
+ ];
518
+ f = polevl(z, FN8).div(d.mul(p1evl(z, FD8)));
519
+ g = z.mul(polevl(z, GN8)).div(p1evl(z, GD8));
520
+ }
521
+ return f.mul(s).minus(g.mul(c));
522
+ }
523
+ function Chi(x) {
524
+ const d = new decimal_js_1.default(x);
525
+ const ax = d.abs();
526
+ if (ax.isZero()) {
527
+ return new decimal_js_1.default(-Infinity);
528
+ }
529
+ if (ax.lt(ASYMPTOTIC_APPROXIMATION_CUTOFF)) {
530
+ let n = 1;
531
+ let term = ax.mul(ax).div(4);
532
+ let sum = term;
533
+ for (let iter = 0; iter < SERIES_MAX_ITERATIONS; iter++) {
534
+ term = term
535
+ .mul(ax)
536
+ .mul(ax)
537
+ .mul(n)
538
+ .div(new decimal_js_1.default(n + 1).mul(2 * n + 1).mul(2 * n + 2));
539
+ sum = sum.plus(term);
540
+ n++;
541
+ if (term.abs().lt(getSeriesError())) {
542
+ break;
543
+ }
544
+ }
545
+ return exports.EULER_GAMMA.plus(ax.ln()).plus(sum);
546
+ }
547
+ function EiLocal(y) {
548
+ if (y.isZero()) {
549
+ return new decimal_js_1.default(-Infinity);
550
+ }
551
+ if (y.gt(EXPONENTIAL_ASYMPTOTIC_CUTOFF) || y.lt(-EXPONENTIAL_ASYMPTOTIC_CUTOFF)) {
552
+ let term = new decimal_js_1.default(1);
553
+ let sum = new decimal_js_1.default(1);
554
+ let best = term.abs();
555
+ for (let n = 1; n < ASYMPTOTIC_MAX_TERMS; n++) {
556
+ term = term.mul(n).div(y);
557
+ const at = term.abs();
558
+ if (at.gt(best)) {
559
+ break;
560
+ }
561
+ best = at;
562
+ sum = sum.plus(term);
563
+ if (at.lt(getSeriesError())) {
564
+ break;
565
+ }
566
+ }
567
+ return y.exp().mul(sum).div(y);
568
+ }
569
+ let term = y;
570
+ let sum = term;
571
+ for (let k = 1; k < POWER_SERIES_MAX_TERMS; k++) {
572
+ term = term
573
+ .mul(y)
574
+ .mul(k)
575
+ .div(new decimal_js_1.default(k + 1).mul(k + 1));
576
+ sum = sum.plus(term);
577
+ if (term.abs().lt(getSeriesError())) {
578
+ break;
579
+ }
580
+ }
581
+ return exports.EULER_GAMMA.plus(y.abs().ln()).plus(sum);
582
+ }
583
+ return EiLocal(d).plus(EiLocal(d.neg())).div(2);
584
+ }
585
+ function Ei(x) {
586
+ const d = new decimal_js_1.default(x);
587
+ if (d.isZero()) {
588
+ return new decimal_js_1.default(-Infinity);
589
+ }
590
+ if (d.gt(EXPONENTIAL_ASYMPTOTIC_CUTOFF) || d.lt(-EXPONENTIAL_ASYMPTOTIC_CUTOFF)) {
591
+ let term = new decimal_js_1.default(1);
592
+ let sum = new decimal_js_1.default(1);
593
+ let best = term.abs();
594
+ for (let n = 1; n < ASYMPTOTIC_MAX_TERMS; n++) {
595
+ term = term.mul(n).div(d);
596
+ const at = term.abs();
597
+ if (at.gt(best)) {
598
+ break;
599
+ }
600
+ best = at;
601
+ sum = sum.plus(term);
602
+ if (at.lt(getSeriesError())) {
603
+ break;
604
+ }
605
+ }
606
+ return d.exp().mul(sum).div(d);
607
+ }
608
+ let term = d;
609
+ let sum = term;
610
+ for (let k = 1; k < POWER_SERIES_MAX_TERMS; k++) {
611
+ term = term
612
+ .mul(d)
613
+ .mul(k)
614
+ .div(new decimal_js_1.default(k + 1).mul(k + 1));
615
+ sum = sum.plus(term);
616
+ if (term.abs().lt(getSeriesError())) {
617
+ break;
618
+ }
619
+ }
620
+ return exports.EULER_GAMMA.plus(d.abs().ln()).plus(sum);
621
+ }
622
+ function Li(x) {
623
+ const d = new decimal_js_1.default(x);
624
+ if (d.lte(0)) {
625
+ return new decimal_js_1.default(NaN);
626
+ }
627
+ if (d.eq(1)) {
628
+ return new decimal_js_1.default(-Infinity);
629
+ }
630
+ const y = d.ln();
631
+ if (y.isZero()) {
632
+ return new decimal_js_1.default(-Infinity);
633
+ }
634
+ if (y.gt(EXPONENTIAL_ASYMPTOTIC_CUTOFF) || y.lt(-EXPONENTIAL_ASYMPTOTIC_CUTOFF)) {
635
+ let term = new decimal_js_1.default(1);
636
+ let sum = new decimal_js_1.default(1);
637
+ let best = term.abs();
638
+ for (let n = 1; n < ASYMPTOTIC_MAX_TERMS; n++) {
639
+ term = term.mul(n).div(y);
640
+ const at = term.abs();
641
+ if (at.gt(best)) {
642
+ break;
643
+ }
644
+ best = at;
645
+ sum = sum.plus(term);
646
+ if (at.lt(getSeriesError())) {
647
+ break;
648
+ }
649
+ }
650
+ return y.exp().mul(sum).div(y);
651
+ }
652
+ let term = y;
653
+ let sum = term;
654
+ for (let k = 1; k < POWER_SERIES_MAX_TERMS; k++) {
655
+ term = term
656
+ .mul(y)
657
+ .mul(k)
658
+ .div(new decimal_js_1.default(k + 1).mul(k + 1));
659
+ sum = sum.plus(term);
660
+ if (term.abs().lt(getSeriesError())) {
661
+ break;
662
+ }
663
+ }
664
+ return exports.EULER_GAMMA.plus(y.abs().ln()).plus(sum);
665
+ }