acsc.js 1.3 KB

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