tanh.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createTanh = void 0;
  6. var _factory = require("../../utils/factory.js");
  7. var _number = require("../../utils/number.js");
  8. var name = 'tanh';
  9. var dependencies = ['typed'];
  10. var createTanh = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
  11. var typed = _ref.typed;
  12. /**
  13. * Calculate the hyperbolic tangent of a value,
  14. * defined as `tanh(x) = (exp(2 * x) - 1) / (exp(2 * x) + 1)`.
  15. *
  16. * To avoid confusion with matrix hyperbolic tangent, this function does
  17. * not apply to matrices.
  18. *
  19. * Syntax:
  20. *
  21. * math.tanh(x)
  22. *
  23. * Examples:
  24. *
  25. * // tanh(x) = sinh(x) / cosh(x) = 1 / coth(x)
  26. * math.tanh(0.5) // returns 0.46211715726000974
  27. * math.sinh(0.5) / math.cosh(0.5) // returns 0.46211715726000974
  28. * 1 / math.coth(0.5) // returns 0.46211715726000974
  29. *
  30. * See also:
  31. *
  32. * sinh, cosh, coth
  33. *
  34. * @param {number | BigNumber | Complex} x Function input
  35. * @return {number | BigNumber | Complex} Hyperbolic tangent of x
  36. */
  37. return typed('tanh', {
  38. number: _number.tanh,
  39. 'Complex | BigNumber': function ComplexBigNumber(x) {
  40. return x.tanh();
  41. }
  42. });
  43. });
  44. exports.createTanh = createTanh;