cot.js 1.1 KB

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