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