asin.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { factory } from '../../utils/factory.js';
  2. var name = 'asin';
  3. var dependencies = ['typed', 'config', 'Complex'];
  4. export var createAsin = /* #__PURE__ */factory(name, dependencies, _ref => {
  5. var {
  6. typed,
  7. config,
  8. Complex
  9. } = _ref;
  10. /**
  11. * Calculate the inverse sine of a value.
  12. *
  13. * To avoid confusion with the matric arcsine, this function does not apply
  14. * to matrices.
  15. *
  16. * Syntax:
  17. *
  18. * math.asin(x)
  19. *
  20. * Examples:
  21. *
  22. * math.asin(0.5) // returns number 0.5235987755982989
  23. * math.asin(math.sin(1.5)) // returns number ~1.5
  24. *
  25. * math.asin(2) // returns Complex 1.5707963267948966 -1.3169578969248166i
  26. *
  27. * See also:
  28. *
  29. * sin, atan, acos
  30. *
  31. * @param {number | BigNumber | Complex} x Function input
  32. * @return {number | BigNumber | Complex} The arc sine of x
  33. */
  34. return typed(name, {
  35. number: function number(x) {
  36. if (x >= -1 && x <= 1 || config.predictable) {
  37. return Math.asin(x);
  38. } else {
  39. return new Complex(x, 0).asin();
  40. }
  41. },
  42. Complex: function Complex(x) {
  43. return x.asin();
  44. },
  45. BigNumber: function BigNumber(x) {
  46. return x.asin();
  47. }
  48. });
  49. });