tanh.js 1.1 KB

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