sech.js 1.0 KB

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