csc.js (1555B)
1 "use strict"; 2 3 Object.defineProperty(exports, "__esModule", { 4 value: true 5 }); 6 exports.createCsc = void 0; 7 8 var _factory = require("../../utils/factory.js"); 9 10 var _collection = require("../../utils/collection.js"); 11 12 var _index = require("../../plain/number/index.js"); 13 14 var name = 'csc'; 15 var dependencies = ['typed', 'BigNumber']; 16 var createCsc = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) { 17 var typed = _ref.typed, 18 _BigNumber = _ref.BigNumber; 19 20 /** 21 * Calculate the cosecant of a value, defined as `csc(x) = 1/sin(x)`. 22 * 23 * For matrices, the function is evaluated element wise. 24 * 25 * Syntax: 26 * 27 * math.csc(x) 28 * 29 * Examples: 30 * 31 * math.csc(2) // returns number 1.099750170294617 32 * 1 / math.sin(2) // returns number 1.099750170294617 33 * 34 * See also: 35 * 36 * sin, sec, cot 37 * 38 * @param {number | Complex | Unit | Array | Matrix} x Function input 39 * @return {number | Complex | Array | Matrix} Cosecant of x 40 */ 41 return typed(name, { 42 number: _index.cscNumber, 43 Complex: function Complex(x) { 44 return x.csc(); 45 }, 46 BigNumber: function BigNumber(x) { 47 return new _BigNumber(1).div(x.sin()); 48 }, 49 Unit: function Unit(x) { 50 if (!x.hasBase(x.constructor.BASE_UNITS.ANGLE)) { 51 throw new TypeError('Unit in function csc is no angle'); 52 } 53 54 return this(x.value); 55 }, 56 'Array | Matrix': function ArrayMatrix(x) { 57 return (0, _collection.deepMap)(x, this); 58 } 59 }); 60 }); 61 exports.createCsc = createCsc;