coth.js 1.0 KB

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