sin.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { factory } from '../../utils/factory.js';
  2. import { createTrigUnit } from './trigUnit.js';
  3. var name = 'sin';
  4. var dependencies = ['typed'];
  5. export var createSin = /* #__PURE__ */factory(name, dependencies, _ref => {
  6. var {
  7. typed
  8. } = _ref;
  9. var trigUnit = createTrigUnit({
  10. typed
  11. });
  12. /**
  13. * Calculate the sine of a value.
  14. *
  15. * To avoid confusion with the matrix sine, this function does not apply
  16. * to matrices.
  17. *
  18. * Syntax:
  19. *
  20. * math.sin(x)
  21. *
  22. * Examples:
  23. *
  24. * math.sin(2) // returns number 0.9092974268256813
  25. * math.sin(math.pi / 4) // returns number 0.7071067811865475
  26. * math.sin(math.unit(90, 'deg')) // returns number 1
  27. * math.sin(math.unit(30, '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} Sine of x
  38. */
  39. return typed(name, {
  40. number: Math.sin,
  41. 'Complex | BigNumber': x => x.sin()
  42. }, trigUnit);
  43. });