cot.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createCot = void 0;
  6. var _factory = require("../../utils/factory.js");
  7. var _index = require("../../plain/number/index.js");
  8. var _trigUnit = require("./trigUnit.js");
  9. var name = 'cot';
  10. var dependencies = ['typed', 'BigNumber'];
  11. var createCot = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
  12. var typed = _ref.typed,
  13. _BigNumber = _ref.BigNumber;
  14. var trigUnit = (0, _trigUnit.createTrigUnit)({
  15. typed: typed
  16. });
  17. /**
  18. * Calculate the cotangent of a value. Defined as `cot(x) = 1 / tan(x)`.
  19. *
  20. * To avoid confusion with the matrix cotangent, this function does not
  21. * apply to matrices.
  22. *
  23. * Syntax:
  24. *
  25. * math.cot(x)
  26. *
  27. * Examples:
  28. *
  29. * math.cot(2) // returns number -0.45765755436028577
  30. * 1 / math.tan(2) // returns number -0.45765755436028577
  31. *
  32. * See also:
  33. *
  34. * tan, sec, csc
  35. *
  36. * @param {number | Complex | Unit | Array | Matrix} x Function input
  37. * @return {number | Complex | Array | Matrix} Cotangent of x
  38. */
  39. return typed(name, {
  40. number: _index.cotNumber,
  41. Complex: function Complex(x) {
  42. return x.cot();
  43. },
  44. BigNumber: function BigNumber(x) {
  45. return new _BigNumber(1).div(x.tan());
  46. }
  47. }, trigUnit);
  48. });
  49. exports.createCot = createCot;