sech.js 1.3 KB

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