cos.js 1.2 KB

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