acosh.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createAcosh = void 0;
  6. var _factory = require("../../utils/factory.js");
  7. var _index = require("../../plain/number/index.js");
  8. var name = 'acosh';
  9. var dependencies = ['typed', 'config', 'Complex'];
  10. var createAcosh = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
  11. var typed = _ref.typed,
  12. config = _ref.config,
  13. Complex = _ref.Complex;
  14. /**
  15. * Calculate the hyperbolic arccos of a value,
  16. * defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.
  17. *
  18. * For matrices, the function is evaluated element wise.
  19. *
  20. * Syntax:
  21. *
  22. * math.acosh(x)
  23. *
  24. * Examples:
  25. *
  26. * math.acosh(1.5) // returns 0.9624236501192069
  27. *
  28. * See also:
  29. *
  30. * cosh, asinh, atanh
  31. *
  32. * @param {number | BigNumber | Complex} x Function input
  33. * @return {number | BigNumber | Complex} Hyperbolic arccosine of x
  34. */
  35. return typed(name, {
  36. number: function number(x) {
  37. if (x >= 1 || config.predictable) {
  38. return (0, _index.acoshNumber)(x);
  39. }
  40. if (x <= -1) {
  41. return new Complex(Math.log(Math.sqrt(x * x - 1) - x), Math.PI);
  42. }
  43. return new Complex(x, 0).acosh();
  44. },
  45. Complex: function Complex(x) {
  46. return x.acosh();
  47. },
  48. BigNumber: function BigNumber(x) {
  49. return x.acosh();
  50. }
  51. });
  52. });
  53. exports.createAcosh = createAcosh;