UNPKG

mathjs

Version:

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif

56 lines (54 loc) 1.5 kB
import { factory } from '../../utils/factory'; import { deepMap } from '../../utils/collection'; import { asecNumber } from '../../plain/number'; var name = 'asec'; var dependencies = ['typed', 'config', 'Complex', 'BigNumber']; export var createAsec = /* #__PURE__ */ factory(name, dependencies, function (_ref) { var typed = _ref.typed, config = _ref.config, Complex = _ref.Complex, _BigNumber = _ref.BigNumber; /** * Calculate the inverse secant of a value. Defined as `asec(x) = acos(1/x)`. * * For matrices, the function is evaluated element wise. * * Syntax: * * math.asec(x) * * Examples: * * math.asec(0.5) // returns 1.0471975511965979 * math.asec(math.sec(1.5)) // returns 1.5 * * math.asec(2) // returns 0 + 1.3169578969248166 i * * See also: * * acos, acot, acsc * * @param {number | Complex | Array | Matrix} x Function input * @return {number | Complex | Array | Matrix} The arc secant of x */ var asec = typed(name, { number: function number(x) { if (x <= -1 || x >= 1 || config.predictable) { return asecNumber(x); } return new Complex(x, 0).asec(); }, Complex: function Complex(x) { return x.asec(); }, BigNumber: function BigNumber(x) { return new _BigNumber(1).div(x).acos(); }, 'Array | Matrix': function ArrayMatrix(x) { return deepMap(x, asec); } }); return asec; });