acosh.js 1.2 KB

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