nerdamer 1.1.13 → 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 +293 -312
  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 -426
  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 -4568
  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 -2675
  322. package/Extra.js +0 -622
  323. package/Solve.js +0 -1783
  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 -12510
  330. package/spec/LaTeX.spec.js +0 -302
  331. package/spec/TeXConvert.spec.js +0 -8
  332. package/spec/algebra.spec.js +0 -287
  333. package/spec/basic_parser.spec.js +0 -134
  334. package/spec/build.spec.js +0 -131
  335. package/spec/calculus.spec.js +0 -183
  336. package/spec/core.spec.js +0 -2970
  337. package/spec/extra.spec.js +0 -54
  338. package/spec/solve.spec.js +0 -126
  339. package/spec/support/jasmine.json +0 -11
  340. package/spec/support/utils.js +0 -42
  341. package/spec/text.spec.js +0 -132
@@ -0,0 +1,1444 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INVERSE_HYPERBOLIC_TRIG = exports.HYPERBOLIC_TRIG = exports.INVERSE_TRIG = exports.TRIG = exports.ACOTH = exports.ACSCH = exports.ASECH = exports.ATANH = exports.ASINH = exports.ACOSH = exports.COTH = exports.CSCH = exports.SECH = exports.TANH = exports.COSH = exports.SINH = exports.ATAN2 = exports.ACOT = exports.ACSC = exports.ASEC = exports.ATAN = exports.COT = exports.CSC = exports.SEC = exports.ACOS = exports.ASIN = exports.TAN = exports.SIN = exports.COS = exports.TRIG_FUNCTION_NAMES = void 0;
4
+ exports.cos = cos;
5
+ exports.sin = sin;
6
+ exports.tan = tan;
7
+ exports.sec = sec;
8
+ exports.csc = csc;
9
+ exports.cot = cot;
10
+ exports.acos = acos;
11
+ exports.asin = asin;
12
+ exports.atan = atan;
13
+ exports.asec = asec;
14
+ exports.acsc = acsc;
15
+ exports.acot = acot;
16
+ exports.atan2 = atan2;
17
+ exports.cosh = cosh;
18
+ exports.sinh = sinh;
19
+ exports.tanh = tanh;
20
+ exports.sech = sech;
21
+ exports.csch = csch;
22
+ exports.coth = coth;
23
+ exports.acosh = acosh;
24
+ exports.asinh = asinh;
25
+ exports.atanh = atanh;
26
+ exports.asech = asech;
27
+ exports.acsch = acsch;
28
+ exports.acoth = acoth;
29
+ const Expression_1 = require("../core/classes/expression/Expression");
30
+ const shortcuts_1 = require("../core/classes/expression/shortcuts");
31
+ const constants_1 = require("../core/classes/parser/constants");
32
+ const Rational_1 = require("../core/classes/rational/Rational");
33
+ const errors_1 = require("../core/errors");
34
+ const bigint_1 = require("../core/functions/bigint/bigint");
35
+ const Settings_1 = require("../core/Settings");
36
+ const geometry_1 = require("./geometry");
37
+ const math_1 = require("./math");
38
+ const math_2 = require("./math");
39
+ var constants_2 = require("../core/classes/parser/constants");
40
+ Object.defineProperty(exports, "TRIG_FUNCTION_NAMES", { enumerable: true, get: function () { return constants_2.TRIG_FUNCTION_NAMES; } });
41
+ Object.defineProperty(exports, "COS", { enumerable: true, get: function () { return constants_2.COS; } });
42
+ Object.defineProperty(exports, "SIN", { enumerable: true, get: function () { return constants_2.SIN; } });
43
+ Object.defineProperty(exports, "TAN", { enumerable: true, get: function () { return constants_2.TAN; } });
44
+ Object.defineProperty(exports, "ASIN", { enumerable: true, get: function () { return constants_2.ASIN; } });
45
+ Object.defineProperty(exports, "ACOS", { enumerable: true, get: function () { return constants_2.ACOS; } });
46
+ Object.defineProperty(exports, "SEC", { enumerable: true, get: function () { return constants_2.SEC; } });
47
+ Object.defineProperty(exports, "CSC", { enumerable: true, get: function () { return constants_2.CSC; } });
48
+ Object.defineProperty(exports, "COT", { enumerable: true, get: function () { return constants_2.COT; } });
49
+ Object.defineProperty(exports, "ATAN", { enumerable: true, get: function () { return constants_2.ATAN; } });
50
+ Object.defineProperty(exports, "ASEC", { enumerable: true, get: function () { return constants_2.ASEC; } });
51
+ Object.defineProperty(exports, "ACSC", { enumerable: true, get: function () { return constants_2.ACSC; } });
52
+ Object.defineProperty(exports, "ACOT", { enumerable: true, get: function () { return constants_2.ACOT; } });
53
+ Object.defineProperty(exports, "ATAN2", { enumerable: true, get: function () { return constants_2.ATAN2; } });
54
+ Object.defineProperty(exports, "SINH", { enumerable: true, get: function () { return constants_2.SINH; } });
55
+ Object.defineProperty(exports, "COSH", { enumerable: true, get: function () { return constants_2.COSH; } });
56
+ Object.defineProperty(exports, "TANH", { enumerable: true, get: function () { return constants_2.TANH; } });
57
+ Object.defineProperty(exports, "SECH", { enumerable: true, get: function () { return constants_2.SECH; } });
58
+ Object.defineProperty(exports, "CSCH", { enumerable: true, get: function () { return constants_2.CSCH; } });
59
+ Object.defineProperty(exports, "COTH", { enumerable: true, get: function () { return constants_2.COTH; } });
60
+ Object.defineProperty(exports, "ACOSH", { enumerable: true, get: function () { return constants_2.ACOSH; } });
61
+ Object.defineProperty(exports, "ASINH", { enumerable: true, get: function () { return constants_2.ASINH; } });
62
+ Object.defineProperty(exports, "ATANH", { enumerable: true, get: function () { return constants_2.ATANH; } });
63
+ Object.defineProperty(exports, "ASECH", { enumerable: true, get: function () { return constants_2.ASECH; } });
64
+ Object.defineProperty(exports, "ACSCH", { enumerable: true, get: function () { return constants_2.ACSCH; } });
65
+ Object.defineProperty(exports, "ACOTH", { enumerable: true, get: function () { return constants_2.ACOTH; } });
66
+ Object.defineProperty(exports, "TRIG", { enumerable: true, get: function () { return constants_2.TRIG; } });
67
+ Object.defineProperty(exports, "INVERSE_TRIG", { enumerable: true, get: function () { return constants_2.INVERSE_TRIG; } });
68
+ Object.defineProperty(exports, "HYPERBOLIC_TRIG", { enumerable: true, get: function () { return constants_2.HYPERBOLIC_TRIG; } });
69
+ Object.defineProperty(exports, "INVERSE_HYPERBOLIC_TRIG", { enumerable: true, get: function () { return constants_2.INVERSE_HYPERBOLIC_TRIG; } });
70
+ /**
71
+ * Gets the quadrant of the trig function
72
+ * @param x
73
+ * @returns
74
+ */
75
+ function getQuadrant(x) {
76
+ const pi = Rational_1.Rational.PI.toDecimal();
77
+ const twoPi = pi.times(2);
78
+ // Get the angle by removing multiples of pi
79
+ let theta = x.toDecimal().mod(twoPi);
80
+ // Make it a positive angle
81
+ if (theta.lt(0)) {
82
+ theta = theta.plus(twoPi);
83
+ }
84
+ const quadrant = Math.floor(Number(theta.div(pi.div(2)))) + 1;
85
+ // Ensure no more than 4
86
+ return Math.min(quadrant, 4);
87
+ }
88
+ /**
89
+ * Checks to see if a Expression is a multiple of pi. If so it returns the evaluated
90
+ * version. Otherwise, the Expression is untouched.
91
+ *
92
+ * @param x
93
+ * @returns
94
+ */
95
+ function toPiValue(x) {
96
+ let retval = x;
97
+ if (constants_1.PI.includes(x.value) && x.isLinear()) {
98
+ retval = x.evaluate({ [x.value]: `${Rational_1.Rational.PI}` });
99
+ }
100
+ return retval;
101
+ }
102
+ // function argNumDen(x: Expression, withR:true): [Expression, Expression, Expression];
103
+ // function argNumDen(x: Expression, withR:false): [Expression, Expression];
104
+ function argNumDen(x, withR = false) {
105
+ const arg = x.getArguments()[0];
106
+ const num = arg.getNumerator();
107
+ const den = arg.getDenominator();
108
+ const retval = [num, den];
109
+ if (withR) {
110
+ retval.push((0, geometry_1.hypot)(num, den));
111
+ }
112
+ return retval;
113
+ }
114
+ /**
115
+ * Computes the cosine of an expression. Returns exact symbolic values for
116
+ * well-known multiples of π (π/6, π/4, π/3, π/2, π, etc.).
117
+ *
118
+ * Cosine is an even function: `cos(-x)` automatically simplifies to `cos(x)`.
119
+ * Inverse trig compositions are resolved:
120
+ * - `cos(acos(x))` returns `x`
121
+ * - `cos(asin(x))` returns `sqrt(1 − x²)`
122
+ * - `cos(atan(x))` returns `1/sqrt(1 + x²)`
123
+ *
124
+ * @param x - The angle in radians.
125
+ * @returns The cosine of `x`.
126
+ * @throws {@link core!UndefinedError} If `x` is `±∞`.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * cos(0).text() // "1"
131
+ * cos('pi').text() // "-1"
132
+ * cos('pi/2').text() // "0"
133
+ * cos('pi/3').text() // "1/2"
134
+ * cos('pi/4').text() // "1/2*sqrt(2)"
135
+ * cos('pi/6').text() // "1/2*sqrt(3)"
136
+ *
137
+ * // Symbolic
138
+ * cos('x').text() // "cos(x)"
139
+ * ```
140
+ */
141
+ function cos(x) {
142
+ x = Expression_1.Expression.create(x);
143
+ let retval;
144
+ // cos(±∞) is undefined
145
+ if (x.isPosInf() || x.isNegInf()) {
146
+ throw new errors_1.UndefinedError((0, errors_1.message)('undefinedValue'));
147
+ }
148
+ // cos is an even function: cos(-x) = cos(x)
149
+ if (x.sign() === -1 && !x.isNUM()) {
150
+ return cos(x.neg());
151
+ }
152
+ const m = Math.abs(+x.getMultiplier());
153
+ if (m === 1 && x.isFunction(constants_1.ATAN)) {
154
+ const [, den, r] = argNumDen(x, true);
155
+ retval = den.div(r);
156
+ }
157
+ else if (m === 1 && x.isFunction(constants_1.ACOS)) {
158
+ retval = x.getArguments()[0];
159
+ }
160
+ else if (m === 1 && x.isFunction(constants_1.ASIN)) {
161
+ const [num, den] = argNumDen(x);
162
+ retval = (0, math_1.sqrt)(den.sq().minus(num.sq())).div(den);
163
+ }
164
+ else {
165
+ // Create a temporary variable. We can use this to substitute for pi and simplification
166
+ const t = toPiValue(x);
167
+ // A flag to check the quadrant. This should be done if a pi substitution was performed.
168
+ let checkQuadrant = true;
169
+ // The quadrants in which cosine is negative
170
+ const quadrants = [2, 3];
171
+ if (t.isNUM()) {
172
+ const a = t.getMultiplier();
173
+ // Check its ratio to pi
174
+ const r = a.div(Rational_1.Rational.PI);
175
+ // cos is one for all even pi and -1 for odd
176
+ if (r.isInteger()) {
177
+ // Return 1 or -1 for multiples of pi
178
+ retval = Expression_1.Expression.Number((0, bigint_1.isEven)(r.numerator) ? '1' : '-1');
179
+ }
180
+ else {
181
+ // Modify based on the denominator
182
+ switch (r.denominator) {
183
+ // n*pi/2
184
+ case 2n:
185
+ retval = (0, shortcuts_1.zero)();
186
+ break;
187
+ case 3n:
188
+ retval = (0, shortcuts_1.one)().div((0, shortcuts_1.two)());
189
+ break;
190
+ case 4n:
191
+ // Return 1/sqrt(2)
192
+ retval = (0, shortcuts_1.one)().div((0, math_1.sqrt)((0, shortcuts_1.two)()));
193
+ break;
194
+ case 6n:
195
+ // Return sqrt(3)/2
196
+ retval = (0, math_1.sqrt)((0, shortcuts_1.three)()).div((0, shortcuts_1.two)());
197
+ break;
198
+ default:
199
+ // Don't check the quadrant since no pi substitution was performed
200
+ checkQuadrant = false;
201
+ // If evaluate is called then return the value
202
+ if (Settings_1.Settings.EVALUATE) {
203
+ retval = Expression_1.Expression.Number(a.toDecimal().cos());
204
+ }
205
+ else {
206
+ // Otherwise return a symbolic function
207
+ retval = Expression_1.Expression.toFunction(constants_1.COS, [x]);
208
+ }
209
+ break;
210
+ }
211
+ if (checkQuadrant && r.denominator !== 2n && quadrants.includes(getQuadrant(a))) {
212
+ retval = retval.neg();
213
+ }
214
+ }
215
+ }
216
+ else if (Settings_1.Settings.EVALUATE && x.isComplex()) {
217
+ const re = x.realPart();
218
+ const im = x.imagPart();
219
+ retval = cos(re)
220
+ .times(cosh(im))
221
+ .minus(sin(re).times(sinh(im)).i());
222
+ }
223
+ else {
224
+ retval = Expression_1.Expression.toFunction(constants_1.COS, [x]);
225
+ }
226
+ }
227
+ return retval;
228
+ }
229
+ /**
230
+ * Computes the sine of an expression. Returns exact symbolic values for
231
+ * well-known multiples of π (π/6, π/4, π/3, π/2, π, etc.).
232
+ *
233
+ * Sine is an odd function: `sin(-x)` automatically simplifies to `-sin(x)`.
234
+ * Inverse trig compositions are resolved:
235
+ * - `sin(asin(x))` returns `x`
236
+ * - `sin(acos(x))` returns `sqrt(1 − x²)`
237
+ * - `sin(atan(x))` returns `x/sqrt(1 + x²)`
238
+ *
239
+ * @param x - The angle in radians.
240
+ * @returns The sine of `x`.
241
+ * @throws {@link core!UndefinedError} If `x` is `±∞`.
242
+ *
243
+ * @example
244
+ * ```ts
245
+ * sin(0).text() // "0"
246
+ * sin('pi').text() // "0"
247
+ * sin('pi/2').text() // "1"
248
+ * sin('pi/6').text() // "1/2"
249
+ * sin('pi/4').text() // "1/2*sqrt(2)"
250
+ * sin('pi/3').text() // "1/2*sqrt(3)"
251
+ *
252
+ * // Symbolic
253
+ * sin('x').text() // "sin(x)"
254
+ * ```
255
+ */
256
+ function sin(x) {
257
+ x = Expression_1.Expression.create(x);
258
+ let retval;
259
+ // sin(±∞) is undefined
260
+ if (x.isPosInf() || x.isNegInf()) {
261
+ throw new errors_1.UndefinedError((0, errors_1.message)('undefinedValue'));
262
+ }
263
+ // sin is an odd function: sin(-x) = -sin(x)
264
+ if (x.sign() === -1 && !x.isNUM()) {
265
+ return sin(x.neg()).neg();
266
+ }
267
+ const m = Math.abs(+x.getMultiplier());
268
+ if (m === 1 && x.isFunction(constants_1.ATAN)) {
269
+ const [num, , r] = argNumDen(x, true);
270
+ retval = num.div(r).times(x.sign());
271
+ }
272
+ else if (m === 1 && x.isFunction(constants_1.ASIN)) {
273
+ retval = x.getArguments()[0].times(x.sign());
274
+ }
275
+ else if (m === 1 && x.isFunction(constants_1.ACOS)) {
276
+ const [num, den] = argNumDen(x);
277
+ retval = (0, math_1.sqrt)(den.sq().minus(num.sq())).div(den).times(x.sign());
278
+ }
279
+ else {
280
+ // Create a temporary variable. We can use this to substitute for pi and simplification
281
+ const t = toPiValue(x);
282
+ // A flag to check the quadrant. This should be done if a pi substitution was performed.
283
+ let checkQuadrant = true;
284
+ // The quadrants in which the sine function is negative
285
+ const quadrants = [3, 4];
286
+ if (t.isNUM()) {
287
+ const a = t.getMultiplier();
288
+ // Check its ratio to pi
289
+ const r = a.div(Rational_1.Rational.PI);
290
+ if (r.isInteger()) {
291
+ // sin is zero for all multiples of pi
292
+ retval = (0, shortcuts_1.zero)();
293
+ }
294
+ else {
295
+ // Modify based on the denominator
296
+ switch (r.denominator) {
297
+ // n*pi/2
298
+ case 2n:
299
+ retval = (0, shortcuts_1.one)();
300
+ break;
301
+ case 3n:
302
+ // Return sqrt(3)/2
303
+ retval = (0, math_1.sqrt)((0, shortcuts_1.three)()).div((0, shortcuts_1.two)());
304
+ break;
305
+ case 4n:
306
+ // Return 1/sqrt(2)
307
+ retval = (0, shortcuts_1.one)().div((0, math_1.sqrt)((0, shortcuts_1.two)()));
308
+ break;
309
+ case 6n:
310
+ // Return 1/2
311
+ retval = (0, shortcuts_1.one)().div((0, shortcuts_1.two)());
312
+ break;
313
+ default:
314
+ // Don't check the quadrant since no pi substitution was performed
315
+ checkQuadrant = false;
316
+ // If evaluate is called then return the value
317
+ if (Settings_1.Settings.EVALUATE) {
318
+ retval = Expression_1.Expression.Number(a.toDecimal().sin());
319
+ }
320
+ else {
321
+ // Otherwise return a symbolic function
322
+ retval = Expression_1.Expression.toFunction(constants_1.SIN, [x]);
323
+ }
324
+ break;
325
+ }
326
+ if (checkQuadrant && quadrants.includes(getQuadrant(a))) {
327
+ retval = retval.neg();
328
+ }
329
+ }
330
+ }
331
+ else if (Settings_1.Settings.EVALUATE && x.isComplex()) {
332
+ const re = x.realPart();
333
+ const im = x.imagPart();
334
+ retval = sin(re)
335
+ .times(cosh(im))
336
+ .plus(cos(re).times(sinh(im)).i());
337
+ }
338
+ else {
339
+ retval = Expression_1.Expression.toFunction(constants_1.SIN, [x]);
340
+ }
341
+ }
342
+ return retval;
343
+ }
344
+ /**
345
+ * Computes the tangent of an expression.
346
+ *
347
+ * Tangent is an odd function: `tan(-x)` automatically simplifies to `-tan(x)`.
348
+ * Returns `0` for all integer multiples of π.
349
+ * Inverse trig compositions are resolved:
350
+ * - `tan(atan(x))` returns `x`
351
+ * - `tan(asin(x))` returns `x/sqrt(1 − x²)`
352
+ * - `tan(acos(x))` returns `sqrt(1 − x²)/x`
353
+ *
354
+ * @param x - The angle in radians.
355
+ * @returns The tangent of `x`.
356
+ * @throws {@link core!UndefinedError} If `x` is `±∞` or an odd multiple of `π/2`.
357
+ *
358
+ * @example
359
+ * ```ts
360
+ * tan(0).text() // "0"
361
+ * tan('pi').text() // "0"
362
+ * tan('pi/4').text() // "1"
363
+ *
364
+ * // Symbolic
365
+ * tan('x').text() // "tan(x)"
366
+ * ```
367
+ */
368
+ function tan(x) {
369
+ x = Expression_1.Expression.create(x);
370
+ let retval;
371
+ // tan(±∞) is undefined
372
+ if (x.isPosInf() || x.isNegInf()) {
373
+ throw new errors_1.UndefinedError((0, errors_1.message)('undefinedValue'));
374
+ }
375
+ // tan is an odd function: tan(-x) = -tan(x)
376
+ if (x.sign() === -1 && !x.isNUM()) {
377
+ return tan(x.neg()).neg();
378
+ }
379
+ const m = Math.abs(+x.getMultiplier());
380
+ if (m === 1 && x.isFunction(constants_1.ATAN)) {
381
+ retval = x.getArguments()[0].times(x.sign());
382
+ }
383
+ else if (m === 1 && x.isFunction(constants_1.ASIN)) {
384
+ const [num, den] = argNumDen(x);
385
+ retval = num.div((0, math_1.sqrt)(den.sq().minus(num.sq()))).times(x.sign());
386
+ }
387
+ else if (m === 1 && x.isFunction(constants_1.ACOS)) {
388
+ const [num, den] = argNumDen(x);
389
+ retval = (0, math_1.sqrt)(den.sq().minus(num.sq())).div(num).times(x.sign());
390
+ }
391
+ else {
392
+ const piDenominator = toPiValue(x).getMultiplier().div(Rational_1.Rational.PI).denominator;
393
+ // If it's a multiple of pi or zero
394
+ if (piDenominator === 1n || x.isZero()) {
395
+ retval = (0, shortcuts_1.zero)();
396
+ }
397
+ // Check for multiplier of pi/2 and throw if true
398
+ else if (piDenominator === 2n) {
399
+ throw new errors_1.UndefinedError((0, errors_1.message)('tanUndefined'));
400
+ }
401
+ else if (Settings_1.Settings.EVALUATE && x.isNUM()) {
402
+ retval = Expression_1.Expression.Number(x.getMultiplier().toDecimal().tan());
403
+ }
404
+ else if (Settings_1.Settings.EVALUATE && x.isComplex()) {
405
+ const dblRe = x.realPart().times(2);
406
+ const dblIm = x.imagPart().times(2);
407
+ const d = cos(dblRe).plus(cosh(dblIm));
408
+ retval = sin(dblRe).div(d).plus(sinh(dblIm).div(d).i());
409
+ }
410
+ else {
411
+ retval = sin(x).div(cos(x));
412
+ if (retval.hasFunction(constants_1.COS)) {
413
+ retval = Expression_1.Expression.toFunction(constants_1.TAN, [x]);
414
+ }
415
+ }
416
+ }
417
+ return retval;
418
+ }
419
+ /**
420
+ * Computes the secant of an expression: `sec(x) = 1/cos(x)`.
421
+ *
422
+ * Returns exact values at well-known angles by inverting the result of {@link cos}.
423
+ *
424
+ * @param x - The angle in radians.
425
+ * @returns The secant of `x`.
426
+ * @throws {@link core!UndefinedError} If `x` is `±∞` or an odd multiple of `π/2` (where `cos(x) = 0`).
427
+ *
428
+ * @example
429
+ * ```ts
430
+ * sec(0).text() // "1"
431
+ * sec('pi').text() // "-1"
432
+ * sec('pi/3').text() // "2"
433
+ * sec('pi/4').text() // "sqrt(2)"
434
+ *
435
+ * // Symbolic
436
+ * sec('x').text() // "sec(x)"
437
+ * ```
438
+ */
439
+ function sec(x) {
440
+ x = Expression_1.Expression.create(x);
441
+ // sec(±∞) is undefined
442
+ if (x.isPosInf() || x.isNegInf()) {
443
+ throw new errors_1.UndefinedError((0, errors_1.message)('undefinedValue'));
444
+ }
445
+ let retval;
446
+ if (Settings_1.Settings.EVALUATE && x.isComplex()) {
447
+ const re = x.realPart();
448
+ const im = x.imagPart();
449
+ const a = cos(re);
450
+ const b = cosh(im);
451
+ const c = sin(re);
452
+ const d = sinh(im);
453
+ const e = a.sq().times(b.sq()).plus(c.sq().times(d.sq()));
454
+ retval = a.times(b).div(e).plus(c.times(d).div(e).i());
455
+ }
456
+ else {
457
+ // sec(n*pi/2) is undefined
458
+ const cosVal = cos(x);
459
+ if (cosVal.isZero()) {
460
+ throw new errors_1.UndefinedError((0, errors_1.message)('secUndefined'));
461
+ }
462
+ retval = cosVal.invert();
463
+ if (retval.hasFunction(constants_1.COS)) {
464
+ retval = Expression_1.Expression.toFunction(constants_1.SEC, [x]);
465
+ }
466
+ }
467
+ return retval;
468
+ }
469
+ /**
470
+ * Computes the cosecant of an expression: `csc(x) = 1/sin(x)`.
471
+ *
472
+ * Returns exact values at well-known angles by inverting the result of {@link sin}.
473
+ *
474
+ * @param x - The angle in radians.
475
+ * @returns The cosecant of `x`.
476
+ * @throws {@link core!UndefinedError} If `x` is `±∞` or an integer multiple of `π` (where `sin(x) = 0`).
477
+ *
478
+ * @example
479
+ * ```ts
480
+ * csc('pi/2').text() // "1"
481
+ * csc('pi/6').text() // "2"
482
+ * csc('pi/4').text() // "sqrt(2)"
483
+ *
484
+ * // Symbolic
485
+ * csc('x').text() // "csc(x)"
486
+ * ```
487
+ */
488
+ function csc(x) {
489
+ x = Expression_1.Expression.create(x);
490
+ // csc(±∞) is undefined
491
+ if (x.isPosInf() || x.isNegInf()) {
492
+ throw new errors_1.UndefinedError((0, errors_1.message)('undefinedValue'));
493
+ }
494
+ let retval;
495
+ if (Settings_1.Settings.EVALUATE && x.isComplex()) {
496
+ const re = x.realPart();
497
+ const im = x.imagPart();
498
+ const a = sin(re);
499
+ const b = cosh(im);
500
+ const c = cos(re);
501
+ const d = sinh(im);
502
+ const e = a.sq().times(b.sq()).plus(c.sq().times(d.sq()));
503
+ retval = a.times(b).div(e).minus(c.times(d).div(e).i());
504
+ }
505
+ else {
506
+ // csc(n*pi) is undefined
507
+ const sinVal = sin(x);
508
+ if (sinVal.isZero()) {
509
+ throw new errors_1.UndefinedError((0, errors_1.message)('cscUndefined'));
510
+ }
511
+ retval = sinVal.invert();
512
+ if (retval.hasFunction(constants_1.SIN)) {
513
+ retval = Expression_1.Expression.toFunction(constants_1.CSC, [x]);
514
+ }
515
+ }
516
+ return retval;
517
+ }
518
+ /**
519
+ * Computes the cotangent of an expression: `cot(x) = cos(x)/sin(x)`.
520
+ *
521
+ * Returns exact values at well-known angles by dividing {@link cos} by {@link sin}.
522
+ *
523
+ * @param x - The angle in radians.
524
+ * @returns The cotangent of `x`.
525
+ * @throws {@link core!UndefinedError} If `x` is `±∞` or an integer multiple of `π` (where `sin(x) = 0`).
526
+ *
527
+ * @example
528
+ * ```ts
529
+ * cot('pi/4').text() // "1"
530
+ * cot('pi/3').text() // "1/3*sqrt(3)"
531
+ *
532
+ * // Symbolic
533
+ * cot('x').text() // "cot(x)"
534
+ * ```
535
+ */
536
+ function cot(x) {
537
+ x = Expression_1.Expression.create(x);
538
+ // cot(±∞) is undefined
539
+ if (x.isPosInf() || x.isNegInf()) {
540
+ throw new errors_1.UndefinedError((0, errors_1.message)('undefinedValue'));
541
+ }
542
+ let retval;
543
+ if (Settings_1.Settings.EVALUATE && x.isComplex()) {
544
+ const re = x.realPart();
545
+ const im = x.imagPart();
546
+ const a = sin(re);
547
+ const b = cos(re);
548
+ const c = sinh(im.times((0, shortcuts_1.two)()));
549
+ const d = cosh(im.times((0, shortcuts_1.two)()));
550
+ const e = cos(re.times((0, shortcuts_1.two)()));
551
+ const denom = d.minus(e);
552
+ retval = a.times(b).times((0, shortcuts_1.two)()).div(denom).plus(c.neg().div(denom).i());
553
+ }
554
+ else {
555
+ // cot(n*pi) is undefined
556
+ const sinVal = sin(x);
557
+ if (sinVal.isZero()) {
558
+ throw new errors_1.UndefinedError((0, errors_1.message)('cotUndefined'));
559
+ }
560
+ retval = cos(x).div(sinVal);
561
+ if (retval.hasFunction(constants_1.COS)) {
562
+ retval = Expression_1.Expression.toFunction(constants_1.COT, [x]);
563
+ }
564
+ }
565
+ return retval;
566
+ }
567
+ /**
568
+ * Computes the arccosine (inverse cosine) of an expression.
569
+ *
570
+ * Returns exact symbolic values involving π for well-known inputs:
571
+ * `0 → π/2`, `1/2 → π/3`, `1/√2 → π/4`, `√3/2 → π/6`, `1 → 0`.
572
+ * Uses the identity `acos(-x) = π − acos(x)` for negative arguments.
573
+ *
574
+ * For numeric inputs outside `[-1, 1]`, returns a complex result via
575
+ * `π/2 + asin(|x|)` with the appropriate sign adjustment.
576
+ *
577
+ * @param x - The input expression (domain `[-1, 1]` for real results).
578
+ * @returns The arccosine of `x` in radians.
579
+ * @throws {@link core!UndefinedError} If `x` is `±∞`.
580
+ *
581
+ * @example
582
+ * ```ts
583
+ * acos(1).text() // "0"
584
+ * acos(0).text() // "1/2*pi"
585
+ * acos('1/2').text() // "1/3*pi"
586
+ * acos('sqrt(2)^(-1)').text() // "1/4*pi"
587
+ * acos(-1).text() // "pi"
588
+ *
589
+ * // Symbolic
590
+ * acos('x').text() // "acos(x)"
591
+ * ```
592
+ */
593
+ function acos(x) {
594
+ x = Expression_1.Expression.create(x);
595
+ // acos(±∞) is undefined (domain is [-1, 1])
596
+ if (x.isPosInf() || x.isNegInf()) {
597
+ throw new errors_1.UndefinedError((0, errors_1.message)('undefinedValue'));
598
+ }
599
+ let retval;
600
+ if (Settings_1.Settings.EVALUATE && x.isNUM()) {
601
+ // Becomes complex between [-1, 1]
602
+ if (x.lt(-1) || x.gt(1)) {
603
+ const sgn = x.sign();
604
+ const halfPi = Expression_1.Expression.Pi().div((0, shortcuts_1.two)());
605
+ let asinX = asin(x.abs());
606
+ if (sgn === 1) {
607
+ asinX = asinX.neg();
608
+ }
609
+ retval = halfPi.plus(asinX);
610
+ }
611
+ else {
612
+ retval = Expression_1.Expression.Number(x.getMultiplier().toDecimal().acos());
613
+ }
614
+ }
615
+ else if (Settings_1.Settings.EVALUATE && x.isComplex()) {
616
+ const i = Expression_1.Expression.Img();
617
+ const a = (0, math_1.sqrt)((0, shortcuts_1.one)().minus(x.pow((0, shortcuts_1.two)())));
618
+ const b = i.times(x);
619
+ // Use formula: pi/2 - asin(x)
620
+ retval = Expression_1.Expression.Pi()
621
+ .div((0, shortcuts_1.two)())
622
+ .minus(i.times((0, math_2.log)(a.minus(b))))
623
+ .expand();
624
+ }
625
+ else if (!x.isComplex()) {
626
+ // Known values lookup using structural equality
627
+ const knownValues = [
628
+ [(0, shortcuts_1.zero)(), Expression_1.Expression.Pi().div((0, shortcuts_1.two)())],
629
+ [(0, shortcuts_1.one)().div((0, shortcuts_1.two)()), Expression_1.Expression.Pi().div((0, shortcuts_1.three)())],
630
+ [(0, shortcuts_1.one)().div((0, math_1.sqrt)((0, shortcuts_1.two)())), Expression_1.Expression.Pi().div((0, shortcuts_1.four)())],
631
+ [(0, math_1.sqrt)((0, shortcuts_1.three)()).div((0, shortcuts_1.two)()), Expression_1.Expression.Pi().div((0, shortcuts_1.six)())],
632
+ [(0, shortcuts_1.one)(), (0, shortcuts_1.zero)()],
633
+ ];
634
+ const absX = x.abs();
635
+ for (const [value, result] of knownValues) {
636
+ if (absX.eq(value)) {
637
+ // acos(-x) = π - acos(x)
638
+ retval = x.sign() === -1 ? Expression_1.Expression.Pi().minus(result) : result;
639
+ break;
640
+ }
641
+ }
642
+ }
643
+ if (retval === undefined) {
644
+ retval = Expression_1.Expression.toFunction(constants_1.ACOS, [x]);
645
+ }
646
+ return retval;
647
+ }
648
+ /**
649
+ * Computes the arcsine (inverse sine) of an expression.
650
+ *
651
+ * Returns exact symbolic values involving π for well-known inputs:
652
+ * `0 → 0`, `1/2 → π/6`, `1/√2 → π/4`, `√3/2 → π/3`, `1 → π/2`.
653
+ * Uses the identity `asin(-x) = -asin(x)` for negative arguments.
654
+ *
655
+ * For numeric inputs outside `[-1, 1]`, returns a complex result.
656
+ *
657
+ * @param x - The input expression (domain `[-1, 1]` for real results).
658
+ * @returns The arcsine of `x` in radians.
659
+ * @throws {@link core!UndefinedError} If `x` is `±∞`.
660
+ *
661
+ * @example
662
+ * ```ts
663
+ * asin(0).text() // "0"
664
+ * asin(1).text() // "1/2*pi"
665
+ * asin('1/2').text() // "1/6*pi"
666
+ * asin('sqrt(2)^(-1)').text() // "1/4*pi"
667
+ *
668
+ * // Symbolic
669
+ * asin('x').text() // "asin(x)"
670
+ * ```
671
+ */
672
+ function asin(x) {
673
+ x = Expression_1.Expression.create(x);
674
+ // asin(±∞) is undefined (domain is [-1, 1])
675
+ if (x.isPosInf() || x.isNegInf()) {
676
+ throw new errors_1.UndefinedError((0, errors_1.message)('undefinedValue'));
677
+ }
678
+ let retval;
679
+ if (Settings_1.Settings.EVALUATE && x.isNUM()) {
680
+ // asin has a domain of -1 to 1
681
+ if (x.lt((0, shortcuts_1.minusOne)()) || x.gt((0, shortcuts_1.one)())) {
682
+ const sgn = x.sign();
683
+ x = x.abs();
684
+ const xSqrMin1 = (0, math_1.sqrt)(x.sq().minus((0, shortcuts_1.one)()));
685
+ let halfPi = Expression_1.Expression.Pi().div((0, shortcuts_1.two)());
686
+ let i = Expression_1.Expression.Img();
687
+ if (sgn === -1) {
688
+ halfPi = halfPi.neg();
689
+ }
690
+ else {
691
+ i = i.neg();
692
+ }
693
+ retval = halfPi.plus(i.times((0, math_2.log)(x.plus(xSqrMin1))));
694
+ }
695
+ else {
696
+ retval = Expression_1.Expression.Number(x.getMultiplier().toDecimal().asin());
697
+ }
698
+ }
699
+ else if (Settings_1.Settings.EVALUATE && x.isComplex()) {
700
+ const i = Expression_1.Expression.Img();
701
+ const a = (0, math_1.sqrt)((0, shortcuts_1.one)().minus(x.pow((0, shortcuts_1.two)())));
702
+ const b = i.times(x);
703
+ retval = i.times((0, math_2.log)(a.minus(b))).expand();
704
+ }
705
+ else if (!x.isComplex()) {
706
+ // Known values lookup using structural equality
707
+ const knownValues = [
708
+ [(0, shortcuts_1.zero)(), (0, shortcuts_1.zero)()],
709
+ [(0, shortcuts_1.one)().div((0, shortcuts_1.two)()), Expression_1.Expression.Pi().div((0, shortcuts_1.six)())],
710
+ [(0, shortcuts_1.one)().div((0, math_1.sqrt)((0, shortcuts_1.two)())), Expression_1.Expression.Pi().div((0, shortcuts_1.four)())],
711
+ [(0, math_1.sqrt)((0, shortcuts_1.three)()).div((0, shortcuts_1.two)()), Expression_1.Expression.Pi().div((0, shortcuts_1.three)())],
712
+ [(0, shortcuts_1.one)(), Expression_1.Expression.Pi().div((0, shortcuts_1.two)())],
713
+ ];
714
+ const absX = x.abs();
715
+ for (const [value, result] of knownValues) {
716
+ if (absX.eq(value)) {
717
+ // asin(-x) = -asin(x)
718
+ retval = x.sign() === -1 ? result.neg() : result;
719
+ break;
720
+ }
721
+ }
722
+ }
723
+ if (retval === undefined) {
724
+ retval = Expression_1.Expression.toFunction(constants_1.ASIN, [x]);
725
+ }
726
+ return retval;
727
+ }
728
+ /**
729
+ * Computes the arctangent (inverse tangent) of an expression.
730
+ *
731
+ * Returns exact symbolic values involving π for well-known inputs:
732
+ * `0 → 0`, `1/√3 → π/6`, `1 → π/4`, `√3 → π/3`.
733
+ * Uses the identity `atan(-x) = -atan(x)` for negative arguments.
734
+ *
735
+ * At infinity: `atan(+∞) = π/2`, `atan(−∞) = −π/2`.
736
+ *
737
+ * @param x - The input expression.
738
+ * @returns The arctangent of `x` in radians.
739
+ *
740
+ * @example
741
+ * ```ts
742
+ * atan(0).text() // "0"
743
+ * atan(1).text() // "1/4*pi"
744
+ * atan('sqrt(3)').text() // "1/3*pi"
745
+ *
746
+ * // Symbolic
747
+ * atan('x').text() // "atan(x)"
748
+ * ```
749
+ */
750
+ function atan(x) {
751
+ x = Expression_1.Expression.create(x);
752
+ let retval;
753
+ // atan(∞) = π/2, atan(-∞) = -π/2
754
+ if (x.isPosInf() || x.isNegInf()) {
755
+ const halfPi = Expression_1.Expression.Pi().div((0, shortcuts_1.two)());
756
+ return x.isNegInf() ? halfPi.neg() : halfPi;
757
+ }
758
+ if (Settings_1.Settings.EVALUATE && x.isNUM()) {
759
+ retval = Expression_1.Expression.Number(x.getMultiplier().toDecimal().atan());
760
+ }
761
+ else if (Settings_1.Settings.EVALUATE && x.isComplex()) {
762
+ const i = Expression_1.Expression.Img();
763
+ const a = (0, math_2.log)(i.minus(x).div(i.plus(x)));
764
+ retval = i.neg().div((0, shortcuts_1.two)()).times(a).expand();
765
+ }
766
+ else if (!x.isComplex()) {
767
+ // Known values lookup using structural equality
768
+ const knownValues = [
769
+ [(0, shortcuts_1.zero)(), (0, shortcuts_1.zero)()],
770
+ [(0, math_1.sqrt)((0, shortcuts_1.three)()).invert(), Expression_1.Expression.Pi().div((0, shortcuts_1.six)())],
771
+ [(0, shortcuts_1.one)(), Expression_1.Expression.Pi().div((0, shortcuts_1.four)())],
772
+ [(0, math_1.sqrt)((0, shortcuts_1.three)()), Expression_1.Expression.Pi().div((0, shortcuts_1.three)())],
773
+ ];
774
+ const absX = x.abs();
775
+ for (const [value, result] of knownValues) {
776
+ if (absX.eq(value)) {
777
+ // atan(-x) = -atan(x)
778
+ retval = x.sign() === -1 ? result.neg() : result;
779
+ break;
780
+ }
781
+ }
782
+ }
783
+ if (!retval) {
784
+ retval = Expression_1.Expression.toFunction(constants_1.ATAN, [x]);
785
+ }
786
+ return retval;
787
+ }
788
+ /**
789
+ * Computes the arcsecant (inverse secant) of an expression: `asec(x) = acos(1/x)`.
790
+ *
791
+ * At infinity: `asec(±∞) = π/2`.
792
+ *
793
+ * @param x - The input expression (domain `|x| ≥ 1` for real results).
794
+ * @returns The arcsecant of `x` in radians.
795
+ *
796
+ * @example
797
+ * ```ts
798
+ * asec(1).text() // "0"
799
+ * asec(2).text() // "1/3*pi"
800
+ *
801
+ * // Symbolic
802
+ * asec('x').text() // "asec(x)"
803
+ * ```
804
+ */
805
+ function asec(x) {
806
+ x = Expression_1.Expression.create(x);
807
+ // asec(±∞) = π/2 (since 1/∞ → 0, and acos(0) = π/2)
808
+ if (x.isPosInf() || x.isNegInf()) {
809
+ return Expression_1.Expression.Pi().div((0, shortcuts_1.two)());
810
+ }
811
+ const retval = acos(x.invert());
812
+ // Check if it's just an inverted acos
813
+ if (retval.isFunction(constants_1.ACOS) && retval.getArguments()[0].eq(x.invert())) {
814
+ return Expression_1.Expression.toFunction(constants_1.ASEC, [x]);
815
+ }
816
+ return retval;
817
+ }
818
+ /**
819
+ * Computes the arccosecant (inverse cosecant) of an expression: `acsc(x) = asin(1/x)`.
820
+ *
821
+ * At infinity: `acsc(±∞) = 0`.
822
+ *
823
+ * @param x - The input expression (domain `|x| ≥ 1` for real results).
824
+ * @returns The arccosecant of `x` in radians.
825
+ *
826
+ * @example
827
+ * ```ts
828
+ * acsc(1).text() // "1/2*pi"
829
+ * acsc(2).text() // "1/6*pi"
830
+ *
831
+ * // Symbolic
832
+ * acsc('x').text() // "acsc(x)"
833
+ * ```
834
+ */
835
+ function acsc(x) {
836
+ x = Expression_1.Expression.create(x);
837
+ // acsc(±∞) = 0 (since 1/∞ → 0, and asin(0) = 0)
838
+ if (x.isPosInf() || x.isNegInf()) {
839
+ return (0, shortcuts_1.zero)();
840
+ }
841
+ const retval = asin(x.invert());
842
+ // Check if it's just an inverted acos
843
+ if (retval.isFunction(constants_1.ASIN) && retval.getArguments()[0].eq(x.invert())) {
844
+ return Expression_1.Expression.toFunction(constants_1.ACSC, [x]);
845
+ }
846
+ return retval;
847
+ }
848
+ /**
849
+ * Computes the arccotangent (inverse cotangent) of an expression: `acot(x) = atan(1/x)`.
850
+ *
851
+ * At infinity: `acot(+∞) = 0`, `acot(−∞) = π`.
852
+ *
853
+ * @param x - The input expression.
854
+ * @returns The arccotangent of `x` in radians.
855
+ *
856
+ * @example
857
+ * ```ts
858
+ * acot(1).text() // "1/4*pi"
859
+ *
860
+ * // Symbolic
861
+ * acot('x').text() // "acot(x)"
862
+ * ```
863
+ */
864
+ function acot(x) {
865
+ x = Expression_1.Expression.create(x);
866
+ let retval;
867
+ // The real principal branch of acot is (0, π), with the endpoint limits
868
+ // acot(∞) = 0 and acot(-∞) = π.
869
+ if (x.isPosInf() || x.isNegInf()) {
870
+ retval = x.isNegInf() ? Expression_1.Expression.Pi() : (0, shortcuts_1.zero)();
871
+ }
872
+ else if (x.isZero()) {
873
+ retval = Expression_1.Expression.Pi().div((0, shortcuts_1.two)());
874
+ }
875
+ else {
876
+ retval = atan(x.invert());
877
+ if (retval.isFunction(constants_1.ATAN) && retval.getArguments()[0].eq(x.invert())) {
878
+ retval = Expression_1.Expression.toFunction(constants_1.ACOT, [x]);
879
+ }
880
+ else if (x.isNUM() && x.sign() === -1) {
881
+ retval = Expression_1.Expression.Pi().plus(retval);
882
+ }
883
+ }
884
+ return retval;
885
+ }
886
+ /**
887
+ * Computes the two-argument arctangent `atan2(y, x)`, which returns the angle
888
+ * in radians between the positive x-axis and the point `(x, y)`.
889
+ *
890
+ * Unlike {@link atan}, `atan2` correctly handles all four quadrants and returns
891
+ * values in the range `(−π, π]`. Returns exact multiples of π where possible.
892
+ *
893
+ * @param y - The y-coordinate.
894
+ * @param x - The x-coordinate.
895
+ * @returns The angle in radians.
896
+ * @throws {@link core!UndefinedError} If both `x` and `y` are zero, or both are `±∞`.
897
+ *
898
+ * @see https://en.wikipedia.org/wiki/Atan2
899
+ *
900
+ * @example
901
+ * ```ts
902
+ * atan2(1, 1).text() // "1/4*pi"
903
+ * atan2(0, 1).text() // "0"
904
+ * atan2(1, 0).text() // "1/2*pi"
905
+ * atan2(-1, 0).text() // "-1/2*pi"
906
+ *
907
+ * // Symbolic
908
+ * atan2('y', 'x').text() // "atan2(y, x)"
909
+ * ```
910
+ */
911
+ function atan2(y, x) {
912
+ x = Expression_1.Expression.create(x);
913
+ y = Expression_1.Expression.create(y);
914
+ if (x.isZero() && y.isZero()) {
915
+ throw new errors_1.UndefinedError((0, errors_1.message)('atan2Undefined'));
916
+ }
917
+ // atan2(±∞, ±∞) is undefined
918
+ if ((x.isPosInf() || x.isNegInf()) && (y.isPosInf() || y.isNegInf())) {
919
+ throw new errors_1.UndefinedError((0, errors_1.message)('atan2Undefined'));
920
+ }
921
+ // atan2(y, ∞) = 0, atan2(y, -∞) = π or -π depending on sign of y
922
+ if (x.isPosInf() || x.isNegInf()) {
923
+ if (x.isNegInf()) {
924
+ return y.sign() === -1 ? Expression_1.Expression.Pi().neg() : Expression_1.Expression.Pi();
925
+ }
926
+ return (0, shortcuts_1.zero)();
927
+ }
928
+ // atan2(∞, x) = π/2, atan2(-∞, x) = -π/2
929
+ if (y.isPosInf() || y.isNegInf()) {
930
+ const halfPi = Expression_1.Expression.Pi().div((0, shortcuts_1.two)());
931
+ return y.isNegInf() ? halfPi.neg() : halfPi;
932
+ }
933
+ let retval;
934
+ if (x.isNUM() && y.isNUM()) {
935
+ // Since it relies on our implementation of atan, we don't need to check for Settings.EVALUATE
936
+ const b = y.getMultiplier();
937
+ const a = x.getMultiplier();
938
+ if (a.gt((0, shortcuts_1.zero)())) {
939
+ retval = atan(y.div(x));
940
+ }
941
+ else if (a.lt('0') && b.gte('0')) {
942
+ retval = atan(y.div(x)).plus(Expression_1.Expression.Pi());
943
+ }
944
+ else if (a.lt('0') && b.lt('0')) {
945
+ retval = atan(y.div(x)).plus(Expression_1.Expression.Pi().neg());
946
+ }
947
+ else if (a.eq('0') && b.gt((0, shortcuts_1.zero)())) {
948
+ retval = Expression_1.Expression.Pi().div((0, shortcuts_1.two)());
949
+ }
950
+ else {
951
+ retval = Expression_1.Expression.Pi().neg().div((0, shortcuts_1.two)());
952
+ }
953
+ }
954
+ else {
955
+ retval = Expression_1.Expression.toFunction(constants_1.ATAN2, [y, x]);
956
+ }
957
+ return retval;
958
+ }
959
+ /**
960
+ * Computes the hyperbolic cosine of an expression.
961
+ *
962
+ * - `cosh(0) = 1`
963
+ * - `cosh(±∞) = +∞`
964
+ * - For complex inputs: `cosh(a + bi) = cosh(a)·cos(b) + i·sinh(a)·sin(b)`
965
+ *
966
+ * @param x - The input expression.
967
+ * @returns The hyperbolic cosine of `x`.
968
+ *
969
+ * @example
970
+ * ```ts
971
+ * cosh(0).text() // "1"
972
+ *
973
+ * // Symbolic
974
+ * cosh('x').text() // "cosh(x)"
975
+ * ```
976
+ */
977
+ function cosh(x) {
978
+ x = Expression_1.Expression.create(x);
979
+ let retval;
980
+ // cosh(±∞) = ∞
981
+ if (x.isPosInf() || x.isNegInf()) {
982
+ return Expression_1.Expression.Inf();
983
+ }
984
+ // cosh(0) = 1
985
+ if (x.isZero()) {
986
+ retval = (0, shortcuts_1.one)();
987
+ }
988
+ else if (Settings_1.Settings.EVALUATE && x.isNUM()) {
989
+ retval = Expression_1.Expression.Number(x.getMultiplier().toDecimal().cosh());
990
+ }
991
+ else if (Settings_1.Settings.EVALUATE && x.isComplex()) {
992
+ const re = x.realPart();
993
+ const im = x.imagPart();
994
+ retval = cosh(re)
995
+ .times(cos(im))
996
+ .plus(sinh(re).times(sin(im)).i());
997
+ }
998
+ else {
999
+ retval = Expression_1.Expression.toFunction(constants_1.COSH, [x]);
1000
+ }
1001
+ return retval;
1002
+ }
1003
+ /**
1004
+ * Computes the hyperbolic sine of an expression.
1005
+ *
1006
+ * - `sinh(0) = 0`
1007
+ * - `sinh(+∞) = +∞`, `sinh(−∞) = −∞`
1008
+ * - For complex inputs: `sinh(a + bi) = sinh(a)·cos(b) + i·cosh(a)·sin(b)`
1009
+ *
1010
+ * @param x - The input expression.
1011
+ * @returns The hyperbolic sine of `x`.
1012
+ *
1013
+ * @example
1014
+ * ```ts
1015
+ * sinh(0).text() // "0"
1016
+ *
1017
+ * // Symbolic
1018
+ * sinh('x').text() // "sinh(x)"
1019
+ * ```
1020
+ */
1021
+ function sinh(x) {
1022
+ x = Expression_1.Expression.create(x);
1023
+ let retval;
1024
+ // sinh(∞) = ∞, sinh(-∞) = -∞
1025
+ if (x.isPosInf() || x.isNegInf()) {
1026
+ return x.isNegInf() ? Expression_1.Expression.NegInf() : Expression_1.Expression.Inf();
1027
+ }
1028
+ // sinh(0) = 0
1029
+ if (x.isZero()) {
1030
+ retval = (0, shortcuts_1.zero)();
1031
+ }
1032
+ else if (Settings_1.Settings.EVALUATE && x.isNUM()) {
1033
+ retval = Expression_1.Expression.Number(x.getMultiplier().toDecimal().sinh());
1034
+ }
1035
+ else if (Settings_1.Settings.EVALUATE && x.isComplex()) {
1036
+ const re = x.realPart();
1037
+ const im = x.imagPart();
1038
+ retval = sinh(re)
1039
+ .times(cos(im))
1040
+ .plus(cosh(re).times(sin(im)).i());
1041
+ }
1042
+ else {
1043
+ retval = Expression_1.Expression.toFunction(constants_1.SINH, [x]);
1044
+ }
1045
+ return retval;
1046
+ }
1047
+ /**
1048
+ * Computes the hyperbolic tangent of an expression.
1049
+ *
1050
+ * - `tanh(0) = 0`
1051
+ * - `tanh(+∞) = 1`, `tanh(−∞) = −1`
1052
+ * - For complex inputs, uses the identity `tanh(z) = sinh(z)/cosh(z)` with
1053
+ * component-wise evaluation.
1054
+ *
1055
+ * @param x - The input expression.
1056
+ * @returns The hyperbolic tangent of `x`.
1057
+ *
1058
+ * @example
1059
+ * ```ts
1060
+ * tanh(0).text() // "0"
1061
+ *
1062
+ * // Symbolic
1063
+ * tanh('x').text() // "tanh(x)"
1064
+ * ```
1065
+ */
1066
+ function tanh(x) {
1067
+ x = Expression_1.Expression.create(x);
1068
+ let retval;
1069
+ // tanh(∞) = 1, tanh(-∞) = -1
1070
+ if (x.isPosInf() || x.isNegInf()) {
1071
+ return x.isNegInf() ? (0, shortcuts_1.one)().neg() : (0, shortcuts_1.one)();
1072
+ }
1073
+ // tanh(0) = 0
1074
+ if (x.isZero()) {
1075
+ retval = (0, shortcuts_1.zero)();
1076
+ }
1077
+ else if (Settings_1.Settings.EVALUATE && x.isNUM()) {
1078
+ retval = Expression_1.Expression.Number(x.getMultiplier().toDecimal().tanh());
1079
+ }
1080
+ else if (Settings_1.Settings.EVALUATE && x.isComplex()) {
1081
+ const re = x.realPart();
1082
+ const im = x.imagPart();
1083
+ const num = sinh(re)
1084
+ .times(cos(im))
1085
+ .plus(cosh(re).times(sin(im)).i());
1086
+ const den = cosh(re)
1087
+ .times(cos(im))
1088
+ .plus(sinh(re).times(sin(im)).i());
1089
+ retval = num.div(den);
1090
+ }
1091
+ else {
1092
+ retval = Expression_1.Expression.toFunction(constants_1.TANH, [x]);
1093
+ }
1094
+ return retval;
1095
+ }
1096
+ /**
1097
+ * Computes the hyperbolic secant of an expression: `sech(x) = 1/cosh(x)`.
1098
+ *
1099
+ * - `sech(0) = 1`
1100
+ * - `sech(±∞) = 0`
1101
+ *
1102
+ * @param x - The input expression.
1103
+ * @returns The hyperbolic secant of `x`.
1104
+ *
1105
+ * @example
1106
+ * ```ts
1107
+ * sech(0).text() // "1"
1108
+ *
1109
+ * // Symbolic
1110
+ * sech('x').text() // "sech(x)"
1111
+ * ```
1112
+ */
1113
+ function sech(x) {
1114
+ x = Expression_1.Expression.create(x);
1115
+ // sech(±∞) = 0
1116
+ if (x.isPosInf() || x.isNegInf()) {
1117
+ return (0, shortcuts_1.zero)();
1118
+ }
1119
+ let retval = (0, shortcuts_1.one)().div(cosh(x));
1120
+ if (retval.hasFunction(constants_1.COSH)) {
1121
+ retval = Expression_1.Expression.toFunction(constants_1.SECH, [x]);
1122
+ }
1123
+ return retval;
1124
+ }
1125
+ /**
1126
+ * Computes the hyperbolic cosecant of an expression: `csch(x) = 1/sinh(x)`.
1127
+ *
1128
+ * - `csch(±∞) = 0`
1129
+ * - `csch(0)` is undefined.
1130
+ *
1131
+ * @param x - The input expression.
1132
+ * @returns The hyperbolic cosecant of `x`.
1133
+ * @throws {@link core!UndefinedError} If `x` is `0`.
1134
+ *
1135
+ * @example
1136
+ * ```ts
1137
+ * // Symbolic
1138
+ * csch('x').text() // "csch(x)"
1139
+ * ```
1140
+ */
1141
+ function csch(x) {
1142
+ x = Expression_1.Expression.create(x);
1143
+ // csch(±∞) = 0
1144
+ if (x.isPosInf() || x.isNegInf()) {
1145
+ return (0, shortcuts_1.zero)();
1146
+ }
1147
+ // csch(0) is undefined
1148
+ if (x.isZero()) {
1149
+ throw new errors_1.UndefinedError((0, errors_1.message)('cschUndefined'));
1150
+ }
1151
+ let retval = (0, shortcuts_1.one)().div(sinh(x));
1152
+ if (retval.hasFunction(constants_1.SINH)) {
1153
+ retval = Expression_1.Expression.toFunction(constants_1.CSCH, [x]);
1154
+ }
1155
+ return retval;
1156
+ }
1157
+ /**
1158
+ * Computes the hyperbolic cotangent of an expression: `coth(x) = 1/tanh(x)`.
1159
+ *
1160
+ * - `coth(+∞) = 1`, `coth(−∞) = −1`
1161
+ * - `coth(0)` is undefined.
1162
+ *
1163
+ * @param x - The input expression.
1164
+ * @returns The hyperbolic cotangent of `x`.
1165
+ * @throws {@link core!UndefinedError} If `x` is `0`.
1166
+ *
1167
+ * @example
1168
+ * ```ts
1169
+ * // Symbolic
1170
+ * coth('x').text() // "coth(x)"
1171
+ * ```
1172
+ */
1173
+ function coth(x) {
1174
+ x = Expression_1.Expression.create(x);
1175
+ // coth(∞) = 1, coth(-∞) = -1
1176
+ if (x.isPosInf() || x.isNegInf()) {
1177
+ return x.isNegInf() ? (0, shortcuts_1.one)().neg() : (0, shortcuts_1.one)();
1178
+ }
1179
+ // coth(0) is undefined
1180
+ if (x.isZero()) {
1181
+ throw new errors_1.UndefinedError((0, errors_1.message)('cothUndefined'));
1182
+ }
1183
+ let retval = (0, shortcuts_1.one)().div(tanh(x));
1184
+ if (retval.hasFunction(constants_1.TANH)) {
1185
+ retval = Expression_1.Expression.toFunction(constants_1.COTH, [x]);
1186
+ }
1187
+ return retval;
1188
+ }
1189
+ /**
1190
+ * Computes the inverse hyperbolic cosine of an expression.
1191
+ *
1192
+ * - `acosh(1) = 0`
1193
+ * - `acosh(0) = iπ/2`
1194
+ * - `acosh(+∞) = +∞`
1195
+ * - For inputs less than 1, returns a complex result via `log(x + sqrt(x²−1))`.
1196
+ *
1197
+ * @param x - The input expression (domain `[1, ∞)` for real results).
1198
+ * @returns The inverse hyperbolic cosine of `x`.
1199
+ * @throws {@link core!UndefinedError} If `x` is `−∞`.
1200
+ *
1201
+ * @example
1202
+ * ```ts
1203
+ * acosh(1).text() // "0"
1204
+ *
1205
+ * // Symbolic
1206
+ * acosh('x').text() // "acosh(x)"
1207
+ * ```
1208
+ */
1209
+ function acosh(x) {
1210
+ x = Expression_1.Expression.create(x);
1211
+ // acosh(∞) = ∞, acosh(-∞) is undefined (domain is [1, ∞))
1212
+ if (x.isPosInf() || x.isNegInf()) {
1213
+ if (x.isNegInf()) {
1214
+ throw new errors_1.UndefinedError((0, errors_1.message)('undefinedValue'));
1215
+ }
1216
+ return Expression_1.Expression.Inf();
1217
+ }
1218
+ // The domain is [1, infinity]
1219
+ let retval;
1220
+ if (x.isOne()) {
1221
+ retval = (0, shortcuts_1.zero)();
1222
+ }
1223
+ else if (x.isZero()) {
1224
+ // acosh(0) = i*pi/2
1225
+ retval = Expression_1.Expression.Pi().div((0, shortcuts_1.two)()).times(Expression_1.Expression.Img());
1226
+ }
1227
+ else if (Settings_1.Settings.EVALUATE) {
1228
+ if (x.isComplex() || x.lt('1')) {
1229
+ const a = (0, math_1.sqrt)(x.plus((0, shortcuts_1.one)()));
1230
+ const b = (0, math_1.sqrt)(x.minus((0, shortcuts_1.one)()));
1231
+ const c = x.plus(a.times(b));
1232
+ retval = (0, math_2.log)(c);
1233
+ }
1234
+ else {
1235
+ retval = Expression_1.Expression.Number(x.getMultiplier().toDecimal().acosh());
1236
+ }
1237
+ }
1238
+ if (!retval) {
1239
+ retval = Expression_1.Expression.toFunction(constants_1.ACOSH, [x]);
1240
+ }
1241
+ return retval;
1242
+ }
1243
+ /**
1244
+ * Computes the inverse hyperbolic sine of an expression.
1245
+ *
1246
+ * - `asinh(0) = 0`
1247
+ * - `asinh(+∞) = +∞`, `asinh(−∞) = −∞`
1248
+ * - For complex inputs, uses `log(x + sqrt(x² + 1))`.
1249
+ *
1250
+ * @param x - The input expression.
1251
+ * @returns The inverse hyperbolic sine of `x`.
1252
+ *
1253
+ * @example
1254
+ * ```ts
1255
+ * asinh(0).text() // "0"
1256
+ *
1257
+ * // Symbolic
1258
+ * asinh('x').text() // "asinh(x)"
1259
+ * ```
1260
+ */
1261
+ function asinh(x) {
1262
+ x = Expression_1.Expression.create(x);
1263
+ // asinh(∞) = ∞, asinh(-∞) = -∞
1264
+ if (x.isPosInf() || x.isNegInf()) {
1265
+ return x.isNegInf() ? Expression_1.Expression.NegInf() : Expression_1.Expression.Inf();
1266
+ }
1267
+ let retval;
1268
+ if (x.isZero()) {
1269
+ retval = (0, shortcuts_1.zero)();
1270
+ }
1271
+ else if (Settings_1.Settings.EVALUATE) {
1272
+ if (x.isComplex()) {
1273
+ retval = (0, math_2.log)(x.plus((0, math_1.sqrt)(x.sq().plus((0, shortcuts_1.one)()))));
1274
+ }
1275
+ else {
1276
+ retval = Expression_1.Expression.Number(x.getMultiplier().toDecimal().asinh());
1277
+ }
1278
+ }
1279
+ if (!retval) {
1280
+ retval = Expression_1.Expression.toFunction(constants_1.ASINH, [x]);
1281
+ }
1282
+ return retval;
1283
+ }
1284
+ /**
1285
+ * Computes the inverse hyperbolic tangent of an expression.
1286
+ *
1287
+ * - `atanh(0) = 0`
1288
+ * - For inputs outside `(-1, 1)` or complex inputs, uses the identity
1289
+ * `atanh(z) = (1/2)·ln((1 + z)/(1 − z))`.
1290
+ *
1291
+ * @param x - The input expression (domain `(-1, 1)` for real results).
1292
+ * @returns The inverse hyperbolic tangent of `x`.
1293
+ * @throws {@link core!UndefinedError} If `x` is `±∞` or exactly `1`.
1294
+ *
1295
+ * @example
1296
+ * ```ts
1297
+ * atanh(0).text() // "0"
1298
+ *
1299
+ * // Symbolic
1300
+ * atanh('x').text() // "atanh(x)"
1301
+ * ```
1302
+ */
1303
+ function atanh(x) {
1304
+ x = Expression_1.Expression.create(x);
1305
+ // atanh(±∞) is undefined (domain is (-1, 1))
1306
+ if (x.isPosInf() || x.isNegInf()) {
1307
+ throw new errors_1.UndefinedError((0, errors_1.message)('undefinedValue'));
1308
+ }
1309
+ let retval;
1310
+ if (x.isZero()) {
1311
+ retval = (0, shortcuts_1.zero)();
1312
+ }
1313
+ else if (x.isOne()) {
1314
+ throw new errors_1.UndefinedError((0, errors_1.message)('atanhUndefined'));
1315
+ }
1316
+ else if (Settings_1.Settings.EVALUATE) {
1317
+ if (x.isComplex() || x.lt((0, shortcuts_1.minusOne)()) || x.gt((0, shortcuts_1.one)())) {
1318
+ //atanh(z) = (1/2) * ln((1 + z) / (1 - z))
1319
+ retval = (0, math_2.log)((0, shortcuts_1.one)().plus(x).div((0, shortcuts_1.one)().minus(x)))
1320
+ .div((0, shortcuts_1.two)())
1321
+ .expand();
1322
+ }
1323
+ else {
1324
+ retval = Expression_1.Expression.Number(x.getMultiplier().toDecimal().atanh());
1325
+ }
1326
+ }
1327
+ if (!retval) {
1328
+ retval = Expression_1.Expression.toFunction(constants_1.ATANH, [x]);
1329
+ }
1330
+ return retval;
1331
+ }
1332
+ /**
1333
+ * Computes the inverse hyperbolic secant of an expression: `asech(x) = acosh(1/x)`.
1334
+ *
1335
+ * For real evaluation, uses the identity `asech(x) = ln((1 + sqrt(1/x² − 1))/x)`.
1336
+ *
1337
+ * @param x - The input expression (domain `(0, 1]` for real results).
1338
+ * @returns The inverse hyperbolic secant of `x`.
1339
+ * @throws {@link core!UndefinedError} If `x` is `±∞`.
1340
+ *
1341
+ * @example
1342
+ * ```ts
1343
+ * asech(1).text() // "0"
1344
+ *
1345
+ * // Symbolic
1346
+ * asech('x').text() // "asech(x)"
1347
+ * ```
1348
+ */
1349
+ function asech(x) {
1350
+ x = Expression_1.Expression.create(x);
1351
+ // asech(±∞) is undefined (domain is (0, 1])
1352
+ if (x.isPosInf() || x.isNegInf()) {
1353
+ throw new errors_1.UndefinedError((0, errors_1.message)('undefinedValue'));
1354
+ }
1355
+ let retval;
1356
+ if (Settings_1.Settings.EVALUATE) {
1357
+ if (x.isComplex()) {
1358
+ retval = acosh(x.invert());
1359
+ }
1360
+ else {
1361
+ const a = (0, shortcuts_1.one)().div(x);
1362
+ const b = (0, math_1.sqrt)((0, shortcuts_1.one)().div(x.sq()).minus((0, shortcuts_1.one)()));
1363
+ retval = (0, math_2.log)(b.plus(a));
1364
+ }
1365
+ }
1366
+ if (!retval) {
1367
+ retval = Expression_1.Expression.toFunction(constants_1.ASECH, [x]);
1368
+ }
1369
+ return retval;
1370
+ }
1371
+ /**
1372
+ * Computes the inverse hyperbolic cosecant of an expression: `acsch(x) = asinh(1/x)`.
1373
+ *
1374
+ * - `acsch(±∞) = 0`
1375
+ * - For real evaluation, uses the identity `acsch(x) = ln((1 + sqrt(1/x² + 1))/x)`.
1376
+ *
1377
+ * @param x - The input expression.
1378
+ * @returns The inverse hyperbolic cosecant of `x`.
1379
+ *
1380
+ * @example
1381
+ * ```ts
1382
+ * // Symbolic
1383
+ * acsch('x').text() // "acsch(x)"
1384
+ * ```
1385
+ */
1386
+ function acsch(x) {
1387
+ x = Expression_1.Expression.create(x);
1388
+ // acsch(±∞) = 0
1389
+ if (x.isPosInf() || x.isNegInf()) {
1390
+ return (0, shortcuts_1.zero)();
1391
+ }
1392
+ let retval;
1393
+ if (Settings_1.Settings.EVALUATE) {
1394
+ if (x.isComplex()) {
1395
+ retval = asinh(x.invert());
1396
+ }
1397
+ else {
1398
+ const a = (0, shortcuts_1.one)().div(x);
1399
+ const b = (0, math_1.sqrt)((0, shortcuts_1.one)().div(x.sq()).plus((0, shortcuts_1.one)()));
1400
+ retval = (0, math_2.log)(b.plus(a));
1401
+ }
1402
+ }
1403
+ if (!retval) {
1404
+ retval = Expression_1.Expression.toFunction(constants_1.ACSCH, [x]);
1405
+ }
1406
+ return retval;
1407
+ }
1408
+ /**
1409
+ * Computes the inverse hyperbolic cotangent of an expression: `acoth(x) = atanh(1/x)`.
1410
+ *
1411
+ * - `acoth(±∞) = 0`
1412
+ * - For real evaluation, uses the identity `acoth(x) = (1/2)·ln((x + 1)/(x − 1))`.
1413
+ *
1414
+ * @param x - The input expression (domain `|x| > 1` for real results).
1415
+ * @returns The inverse hyperbolic cotangent of `x`.
1416
+ *
1417
+ * @example
1418
+ * ```ts
1419
+ * // Symbolic
1420
+ * acoth('x').text() // "acoth(x)"
1421
+ * ```
1422
+ */
1423
+ function acoth(x) {
1424
+ x = Expression_1.Expression.create(x);
1425
+ // acoth(±∞) = 0
1426
+ if (x.isPosInf() || x.isNegInf()) {
1427
+ return (0, shortcuts_1.zero)();
1428
+ }
1429
+ let retval;
1430
+ if (Settings_1.Settings.EVALUATE) {
1431
+ if (x.isComplex()) {
1432
+ retval = atanh(x.invert());
1433
+ }
1434
+ else {
1435
+ retval = (0, math_2.log)(x.plus((0, shortcuts_1.one)()).div(x.minus((0, shortcuts_1.one)())))
1436
+ .div((0, shortcuts_1.two)())
1437
+ .expand();
1438
+ }
1439
+ }
1440
+ if (!retval) {
1441
+ retval = Expression_1.Expression.toFunction(constants_1.ACOTH, [x]);
1442
+ }
1443
+ return retval;
1444
+ }