atanh.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createAtanh = void 0;
  6. var _factory = require("../../utils/factory.js");
  7. var _index = require("../../plain/number/index.js");
  8. var name = 'atanh';
  9. var dependencies = ['typed', 'config', 'Complex'];
  10. var createAtanh = /* #__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 arctangent of a value,
  16. * defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.
  17. *
  18. * To avoid confusion with the matrix hyperbolic arctangent, this function
  19. * does not apply to matrices.
  20. *
  21. * Syntax:
  22. *
  23. * math.atanh(x)
  24. *
  25. * Examples:
  26. *
  27. * math.atanh(0.5) // returns 0.5493061443340549
  28. *
  29. * See also:
  30. *
  31. * acosh, asinh
  32. *
  33. * @param {number | BigNumber | Complex} x Function input
  34. * @return {number | BigNumber | Complex} Hyperbolic arctangent of x
  35. */
  36. return typed(name, {
  37. number: function number(x) {
  38. if (x <= 1 && x >= -1 || config.predictable) {
  39. return (0, _index.atanhNumber)(x);
  40. }
  41. return new Complex(x, 0).atanh();
  42. },
  43. Complex: function Complex(x) {
  44. return x.atanh();
  45. },
  46. BigNumber: function BigNumber(x) {
  47. return x.atanh();
  48. }
  49. });
  50. });
  51. exports.createAtanh = createAtanh;