cos.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createCos = void 0;
  6. var _factory = require("../../utils/factory.js");
  7. var _trigUnit = require("./trigUnit.js");
  8. var name = 'cos';
  9. var dependencies = ['typed'];
  10. var createCos = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
  11. var typed = _ref.typed;
  12. var trigUnit = (0, _trigUnit.createTrigUnit)({
  13. typed: typed
  14. });
  15. /**
  16. * Calculate the cosine of a value.
  17. *
  18. * To avoid confusion with the matrix cosine, this function does not
  19. * apply to matrices.
  20. *
  21. * Syntax:
  22. *
  23. * math.cos(x)
  24. *
  25. * Examples:
  26. *
  27. * math.cos(2) // returns number -0.4161468365471422
  28. * math.cos(math.pi / 4) // returns number 0.7071067811865475
  29. * math.cos(math.unit(180, 'deg')) // returns number -1
  30. * math.cos(math.unit(60, 'deg')) // returns number 0.5
  31. *
  32. * const angle = 0.2
  33. * math.pow(math.sin(angle), 2) + math.pow(math.cos(angle), 2) // returns number ~1
  34. *
  35. * See also:
  36. *
  37. * cos, tan
  38. *
  39. * @param {number | BigNumber | Complex | Unit} x Function input
  40. * @return {number | BigNumber | Complex} Cosine of x
  41. */
  42. return typed(name, {
  43. number: Math.cos,
  44. 'Complex | BigNumber': function ComplexBigNumber(x) {
  45. return x.cos();
  46. }
  47. }, trigUnit);
  48. });
  49. exports.createCos = createCos;