acoth.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { factory } from '../../utils/factory.js';
  2. import { acothNumber } from '../../plain/number/index.js';
  3. var name = 'acoth';
  4. var dependencies = ['typed', 'config', 'Complex', 'BigNumber'];
  5. export var createAcoth = /* #__PURE__ */factory(name, dependencies, _ref => {
  6. var {
  7. typed,
  8. config,
  9. Complex,
  10. BigNumber: _BigNumber
  11. } = _ref;
  12. /**
  13. * Calculate the hyperbolic arccotangent of a value,
  14. * defined as `acoth(x) = atanh(1/x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.
  15. *
  16. * To avoid confusion with the matrix hyperbolic arccotangent, this
  17. * function does not apply to matrices.
  18. *
  19. * Syntax:
  20. *
  21. * math.acoth(x)
  22. *
  23. * Examples:
  24. *
  25. * math.acoth(0.5) // returns 0.8047189562170503
  26. *
  27. * See also:
  28. *
  29. * acsch, asech
  30. *
  31. * @param {number | BigNumber | Complex} x Function input
  32. * @return {number | BigNumber | Complex} Hyperbolic arccotangent of x
  33. */
  34. return typed(name, {
  35. number: function number(x) {
  36. if (x >= 1 || x <= -1 || config.predictable) {
  37. return acothNumber(x);
  38. }
  39. return new Complex(x, 0).acoth();
  40. },
  41. Complex: function Complex(x) {
  42. return x.acoth();
  43. },
  44. BigNumber: function BigNumber(x) {
  45. return new _BigNumber(1).div(x).atanh();
  46. }
  47. });
  48. });