atanh.js 1.2 KB

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