feat:node-modules

This commit is contained in:
houjunxiang
2025-11-24 10:26:18 +08:00
parent 753766893b
commit 8a3e48d856
8825 changed files with 567399 additions and 1 deletions

View File

@@ -0,0 +1,49 @@
import { factory } from '../../utils/factory.js';
var name = 'acos';
var dependencies = ['typed', 'config', 'Complex'];
export var createAcos = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
config,
Complex
} = _ref;
/**
* Calculate the inverse cosine of a value.
*
* To avoid confusion with the matrix arccosine, this function does not
* apply to matrices.
*
* Syntax:
*
* math.acos(x)
*
* Examples:
*
* math.acos(0.5) // returns number 1.0471975511965979
* math.acos(math.cos(1.5)) // returns number 1.5
*
* math.acos(2) // returns Complex 0 + 1.3169578969248166 i
*
* See also:
*
* cos, atan, asin
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} The arc cosine of x
*/
return typed(name, {
number: function number(x) {
if (x >= -1 && x <= 1 || config.predictable) {
return Math.acos(x);
} else {
return new Complex(x, 0).acos();
}
},
Complex: function Complex(x) {
return x.acos();
},
BigNumber: function BigNumber(x) {
return x.acos();
}
});
});

View File

@@ -0,0 +1,49 @@
import { factory } from '../../utils/factory.js';
import { acoshNumber } from '../../plain/number/index.js';
var name = 'acosh';
var dependencies = ['typed', 'config', 'Complex'];
export var createAcosh = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
config,
Complex
} = _ref;
/**
* Calculate the hyperbolic arccos of a value,
* defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.
*
* For matrices, the function is evaluated element wise.
*
* Syntax:
*
* math.acosh(x)
*
* Examples:
*
* math.acosh(1.5) // returns 0.9624236501192069
*
* See also:
*
* cosh, asinh, atanh
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} Hyperbolic arccosine of x
*/
return typed(name, {
number: function number(x) {
if (x >= 1 || config.predictable) {
return acoshNumber(x);
}
if (x <= -1) {
return new Complex(Math.log(Math.sqrt(x * x - 1) - x), Math.PI);
}
return new Complex(x, 0).acosh();
},
Complex: function Complex(x) {
return x.acosh();
},
BigNumber: function BigNumber(x) {
return x.acosh();
}
});
});

View File

@@ -0,0 +1,42 @@
import { factory } from '../../utils/factory.js';
import { acotNumber } from '../../plain/number/index.js';
var name = 'acot';
var dependencies = ['typed', 'BigNumber'];
export var createAcot = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
BigNumber: _BigNumber
} = _ref;
/**
* Calculate the inverse cotangent of a value, defined as `acot(x) = atan(1/x)`.
*
* To avoid confusion with the matrix arccotanget, this function does not
* apply to matrices.
*
* Syntax:
*
* math.acot(x)
*
* Examples:
*
* math.acot(0.5) // returns number 1.1071487177940904
* math.acot(2) // returns number 0.4636476090008061
* math.acot(math.cot(1.5)) // returns number 1.5
*
* See also:
*
* cot, atan
*
* @param {number | BigNumber| Complex} x Function input
* @return {number | BigNumber| Complex} The arc cotangent of x
*/
return typed(name, {
number: acotNumber,
Complex: function Complex(x) {
return x.acot();
},
BigNumber: function BigNumber(x) {
return new _BigNumber(1).div(x).atan();
}
});
});

View File

@@ -0,0 +1,48 @@
import { factory } from '../../utils/factory.js';
import { acothNumber } from '../../plain/number/index.js';
var name = 'acoth';
var dependencies = ['typed', 'config', 'Complex', 'BigNumber'];
export var createAcoth = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
config,
Complex,
BigNumber: _BigNumber
} = _ref;
/**
* Calculate the inverse hyperbolic tangent of a value,
* defined as `acoth(x) = atanh(1/x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.
*
* To avoid confusion with the matrix inverse hyperbolic tangent, this
* function does not apply to matrices.
*
* Syntax:
*
* math.acoth(x)
*
* Examples:
*
* math.acoth(0.5) // returns 0.8047189562170503
*
* See also:
*
* acsch, asech
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} Hyperbolic arccotangent of x
*/
return typed(name, {
number: function number(x) {
if (x >= 1 || x <= -1 || config.predictable) {
return acothNumber(x);
}
return new Complex(x, 0).acoth();
},
Complex: function Complex(x) {
return x.acoth();
},
BigNumber: function BigNumber(x) {
return new _BigNumber(1).div(x).atanh();
}
});
});

View File

@@ -0,0 +1,49 @@
import { factory } from '../../utils/factory.js';
import { acscNumber } from '../../plain/number/index.js';
var name = 'acsc';
var dependencies = ['typed', 'config', 'Complex', 'BigNumber'];
export var createAcsc = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
config,
Complex,
BigNumber: _BigNumber
} = _ref;
/**
* Calculate the inverse cosecant of a value, defined as `acsc(x) = asin(1/x)`.
*
* To avoid confusion with the matrix arccosecant, this function does not
* apply to matrices.
*
* Syntax:
*
* math.acsc(x)
*
* Examples:
*
* math.acsc(2) // returns 0.5235987755982989
* math.acsc(0.5) // returns Complex 1.5707963267948966 -1.3169578969248166i
* math.acsc(math.csc(1.5)) // returns number ~1.5
*
* See also:
*
* csc, asin, asec
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} The arc cosecant of x
*/
return typed(name, {
number: function number(x) {
if (x <= -1 || x >= 1 || config.predictable) {
return acscNumber(x);
}
return new Complex(x, 0).acsc();
},
Complex: function Complex(x) {
return x.acsc();
},
BigNumber: function BigNumber(x) {
return new _BigNumber(1).div(x).asin();
}
});
});

View File

@@ -0,0 +1,41 @@
import { factory } from '../../utils/factory.js';
import { acschNumber } from '../../plain/number/index.js';
var name = 'acsch';
var dependencies = ['typed', 'BigNumber'];
export var createAcsch = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
BigNumber: _BigNumber
} = _ref;
/**
* Calculate the inverse hyperbolic cosecant of a value,
* defined as `acsch(x) = asinh(1/x) = ln(1/x + sqrt(1/x^2 + 1))`.
*
* To avoid confusion with the matrix inverse hyperbolic cosecant, this function
* does not apply to matrices.
*
* Syntax:
*
* math.acsch(x)
*
* Examples:
*
* math.acsch(0.5) // returns 1.4436354751788103
*
* See also:
*
* asech, acoth
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} Hyperbolic arccosecant of x
*/
return typed(name, {
number: acschNumber,
Complex: function Complex(x) {
return x.acsch();
},
BigNumber: function BigNumber(x) {
return new _BigNumber(1).div(x).asinh();
}
});
});

View File

@@ -0,0 +1,50 @@
import { factory } from '../../utils/factory.js';
import { asecNumber } from '../../plain/number/index.js';
var name = 'asec';
var dependencies = ['typed', 'config', 'Complex', 'BigNumber'];
export var createAsec = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
config,
Complex,
BigNumber: _BigNumber
} = _ref;
/**
* Calculate the inverse secant of a value. Defined as `asec(x) = acos(1/x)`.
*
* To avoid confusion with the matrix arcsecant, this function does not
* apply to matrices.
*
* Syntax:
*
* math.asec(x)
*
* Examples:
*
* math.asec(2) // returns 1.0471975511965979
* math.asec(math.sec(1.5)) // returns 1.5
*
* math.asec(0.5) // returns Complex 0 + 1.3169578969248166i
*
* See also:
*
* acos, acot, acsc
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} The arc secant of x
*/
return 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();
}
});
});

View File

@@ -0,0 +1,53 @@
import { factory } from '../../utils/factory.js';
import { asechNumber } from '../../plain/number/index.js';
var name = 'asech';
var dependencies = ['typed', 'config', 'Complex', 'BigNumber'];
export var createAsech = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
config,
Complex,
BigNumber: _BigNumber
} = _ref;
/**
* Calculate the hyperbolic arcsecant of a value,
* defined as `asech(x) = acosh(1/x) = ln(sqrt(1/x^2 - 1) + 1/x)`.
*
* To avoid confusion with the matrix hyperbolic arcsecant, this function
* does not apply to matrices.
*
* Syntax:
*
* math.asech(x)
*
* Examples:
*
* math.asech(0.5) // returns 1.3169578969248166
*
* See also:
*
* acsch, acoth
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} Hyperbolic arcsecant of x
*/
return typed(name, {
number: function number(x) {
if (x <= 1 && x >= -1 || config.predictable) {
var xInv = 1 / x;
if (xInv > 0 || config.predictable) {
return asechNumber(x);
}
var ret = Math.sqrt(xInv * xInv - 1);
return new Complex(Math.log(ret - xInv), Math.PI);
}
return new Complex(x, 0).asech();
},
Complex: function Complex(x) {
return x.asech();
},
BigNumber: function BigNumber(x) {
return new _BigNumber(1).div(x).acosh();
}
});
});

View File

@@ -0,0 +1,49 @@
import { factory } from '../../utils/factory.js';
var name = 'asin';
var dependencies = ['typed', 'config', 'Complex'];
export var createAsin = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
config,
Complex
} = _ref;
/**
* Calculate the inverse sine of a value.
*
* To avoid confusion with the matric arcsine, this function does not apply
* to matrices.
*
* Syntax:
*
* math.asin(x)
*
* Examples:
*
* math.asin(0.5) // returns number 0.5235987755982989
* math.asin(math.sin(1.5)) // returns number ~1.5
*
* math.asin(2) // returns Complex 1.5707963267948966 -1.3169578969248166i
*
* See also:
*
* sin, atan, acos
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} The arc sine of x
*/
return typed(name, {
number: function number(x) {
if (x >= -1 && x <= 1 || config.predictable) {
return Math.asin(x);
} else {
return new Complex(x, 0).asin();
}
},
Complex: function Complex(x) {
return x.asin();
},
BigNumber: function BigNumber(x) {
return x.asin();
}
});
});

View File

@@ -0,0 +1,40 @@
import { factory } from '../../utils/factory.js';
import { asinhNumber } from '../../plain/number/index.js';
var name = 'asinh';
var dependencies = ['typed'];
export var createAsinh = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed
} = _ref;
/**
* Calculate the hyperbolic arcsine of a value,
* defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.
*
* To avoid confusion with the matrix hyperbolic arcsine, this function
* does not apply to matrices.
*
* Syntax:
*
* math.asinh(x)
*
* Examples:
*
* math.asinh(0.5) // returns 0.48121182505960347
*
* See also:
*
* acosh, atanh
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} Hyperbolic arcsine of x
*/
return typed('asinh', {
number: asinhNumber,
Complex: function Complex(x) {
return x.asinh();
},
BigNumber: function BigNumber(x) {
return x.asinh();
}
});
});

View File

@@ -0,0 +1,42 @@
import { factory } from '../../utils/factory.js';
var name = 'atan';
var dependencies = ['typed'];
export var createAtan = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed
} = _ref;
/**
* Calculate the inverse tangent of a value.
*
* To avoid confusion with matrix arctangent, this function does not apply
* to matrices.
*
* Syntax:
*
* math.atan(x)
*
* Examples:
*
* math.atan(0.5) // returns number 0.4636476090008061
* math.atan(2) // returns number 1.1071487177940904
* math.atan(math.tan(1.5)) // returns number 1.5
*
* See also:
*
* tan, asin, acos
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} The arc tangent of x
*/
return typed('atan', {
number: function number(x) {
return Math.atan(x);
},
Complex: function Complex(x) {
return x.atan();
},
BigNumber: function BigNumber(x) {
return x.atan();
}
});
});

View File

@@ -0,0 +1,89 @@
import { factory } from '../../utils/factory.js';
import { createMatAlgo02xDS0 } from '../../type/matrix/utils/matAlgo02xDS0.js';
import { createMatAlgo03xDSf } from '../../type/matrix/utils/matAlgo03xDSf.js';
import { createMatAlgo09xS0Sf } from '../../type/matrix/utils/matAlgo09xS0Sf.js';
import { createMatAlgo11xS0s } from '../../type/matrix/utils/matAlgo11xS0s.js';
import { createMatAlgo12xSfs } from '../../type/matrix/utils/matAlgo12xSfs.js';
import { createMatrixAlgorithmSuite } from '../../type/matrix/utils/matrixAlgorithmSuite.js';
var name = 'atan2';
var dependencies = ['typed', 'matrix', 'equalScalar', 'BigNumber', 'DenseMatrix', 'concat'];
export var createAtan2 = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
matrix,
equalScalar,
BigNumber,
DenseMatrix,
concat
} = _ref;
var matAlgo02xDS0 = createMatAlgo02xDS0({
typed,
equalScalar
});
var matAlgo03xDSf = createMatAlgo03xDSf({
typed
});
var matAlgo09xS0Sf = createMatAlgo09xS0Sf({
typed,
equalScalar
});
var matAlgo11xS0s = createMatAlgo11xS0s({
typed,
equalScalar
});
var matAlgo12xSfs = createMatAlgo12xSfs({
typed,
DenseMatrix
});
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
typed,
matrix,
concat
});
/**
* Calculate the inverse tangent function with two arguments, y/x.
* By providing two arguments, the right quadrant of the computed angle can be
* determined.
*
* For matrices, the function is evaluated element wise.
*
* Syntax:
*
* math.atan2(y, x)
*
* Examples:
*
* math.atan2(2, 2) / math.pi // returns number 0.25
*
* const angle = math.unit(60, 'deg') // returns Unit 60 deg
* const x = math.cos(angle)
* const y = math.sin(angle)
*
* math.atan(2) // returns number 1.1071487177940904
*
* See also:
*
* tan, atan, sin, cos
*
* @param {number | Array | Matrix} y Second dimension
* @param {number | Array | Matrix} x First dimension
* @return {number | Array | Matrix} Four-quadrant inverse tangent
*/
return typed(name, {
'number, number': Math.atan2,
// Complex numbers doesn't seem to have a reasonable implementation of
// atan2(). Even Matlab removed the support, after they only calculated
// the atan only on base of the real part of the numbers and ignored
// the imaginary.
'BigNumber, BigNumber': (y, x) => BigNumber.atan2(y, x)
}, matrixAlgorithmSuite({
scalar: 'number | BigNumber',
SS: matAlgo09xS0Sf,
DS: matAlgo03xDSf,
SD: matAlgo02xDS0,
Ss: matAlgo11xS0s,
sS: matAlgo12xSfs
}));
});

View File

@@ -0,0 +1,47 @@
import { factory } from '../../utils/factory.js';
import { atanhNumber } from '../../plain/number/index.js';
var name = 'atanh';
var dependencies = ['typed', 'config', 'Complex'];
export var createAtanh = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
config,
Complex
} = _ref;
/**
* Calculate the hyperbolic arctangent of a value,
* defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.
*
* To avoid confusion with the matrix hyperbolic arctangent, this function
* does not apply to matrices.
*
* Syntax:
*
* math.atanh(x)
*
* Examples:
*
* math.atanh(0.5) // returns 0.5493061443340549
*
* See also:
*
* acosh, asinh
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} Hyperbolic arctangent of x
*/
return typed(name, {
number: function number(x) {
if (x <= 1 && x >= -1 || config.predictable) {
return atanhNumber(x);
}
return new Complex(x, 0).atanh();
},
Complex: function Complex(x) {
return x.atanh();
},
BigNumber: function BigNumber(x) {
return x.atanh();
}
});
});

View File

@@ -0,0 +1,44 @@
import { factory } from '../../utils/factory.js';
import { createTrigUnit } from './trigUnit.js';
var name = 'cos';
var dependencies = ['typed'];
export var createCos = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed
} = _ref;
var trigUnit = createTrigUnit({
typed
});
/**
* Calculate the cosine of a value.
*
* To avoid confusion with the matrix cosine, this function does not
* apply to matrices.
*
* Syntax:
*
* math.cos(x)
*
* Examples:
*
* math.cos(2) // returns number -0.4161468365471422
* math.cos(math.pi / 4) // returns number 0.7071067811865475
* math.cos(math.unit(180, 'deg')) // returns number -1
* math.cos(math.unit(60, 'deg')) // returns number 0.5
*
* const angle = 0.2
* math.pow(math.sin(angle), 2) + math.pow(math.cos(angle), 2) // returns number ~1
*
* See also:
*
* cos, tan
*
* @param {number | BigNumber | Complex | Unit} x Function input
* @return {number | BigNumber | Complex} Cosine of x
*/
return typed(name, {
number: Math.cos,
'Complex | BigNumber': x => x.cos()
}, trigUnit);
});

View File

@@ -0,0 +1,35 @@
import { factory } from '../../utils/factory.js';
import { cosh as coshNumber } from '../../utils/number.js';
var name = 'cosh';
var dependencies = ['typed'];
export var createCosh = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed
} = _ref;
/**
* Calculate the hyperbolic cosine of a value,
* defined as `cosh(x) = 1/2 * (exp(x) + exp(-x))`.
*
* To avoid confusion with the matrix hyperbolic cosine, this function does
* not apply to matrices.
*
* Syntax:
*
* math.cosh(x)
*
* Examples:
*
* math.cosh(0.5) // returns number 1.1276259652063807
*
* See also:
*
* sinh, tanh
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} Hyperbolic cosine of x
*/
return typed(name, {
number: coshNumber,
'Complex | BigNumber': x => x.cosh()
});
});

View File

@@ -0,0 +1,42 @@
import { factory } from '../../utils/factory.js';
import { cotNumber } from '../../plain/number/index.js';
import { createTrigUnit } from './trigUnit.js';
var name = 'cot';
var dependencies = ['typed', 'BigNumber'];
export var createCot = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
BigNumber: _BigNumber
} = _ref;
var trigUnit = createTrigUnit({
typed
});
/**
* Calculate the cotangent of a value. Defined as `cot(x) = 1 / tan(x)`.
*
* To avoid confusion with the matrix cotangent, this function does not
* apply to matrices.
*
* Syntax:
*
* math.cot(x)
*
* Examples:
*
* math.cot(2) // returns number -0.45765755436028577
* 1 / math.tan(2) // returns number -0.45765755436028577
*
* See also:
*
* tan, sec, csc
*
* @param {number | Complex | Unit | Array | Matrix} x Function input
* @return {number | Complex | Array | Matrix} Cotangent of x
*/
return typed(name, {
number: cotNumber,
Complex: x => x.cot(),
BigNumber: x => new _BigNumber(1).div(x.tan())
}, trigUnit);
});

View File

@@ -0,0 +1,39 @@
import { factory } from '../../utils/factory.js';
import { cothNumber } from '../../plain/number/index.js';
var name = 'coth';
var dependencies = ['typed', 'BigNumber'];
export var createCoth = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
BigNumber: _BigNumber
} = _ref;
/**
* Calculate the hyperbolic cotangent of a value,
* defined as `coth(x) = 1 / tanh(x)`.
*
* To avoid confusion with the matrix hyperbolic cotangent, this function
* does not apply to matrices.
*
* Syntax:
*
* math.coth(x)
*
* Examples:
*
* // coth(x) = 1 / tanh(x)
* math.coth(2) // returns 1.0373147207275482
* 1 / math.tanh(2) // returns 1.0373147207275482
*
* See also:
*
* sinh, tanh, cosh
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} Hyperbolic cotangent of x
*/
return typed(name, {
number: cothNumber,
Complex: x => x.coth(),
BigNumber: x => new _BigNumber(1).div(x.tanh())
});
});

View File

@@ -0,0 +1,42 @@
import { factory } from '../../utils/factory.js';
import { cscNumber } from '../../plain/number/index.js';
import { createTrigUnit } from './trigUnit.js';
var name = 'csc';
var dependencies = ['typed', 'BigNumber'];
export var createCsc = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
BigNumber: _BigNumber
} = _ref;
var trigUnit = createTrigUnit({
typed
});
/**
* Calculate the cosecant of a value, defined as `csc(x) = 1/sin(x)`.
*
* To avoid confusion with the matrix cosecant, this function does not
* apply to matrices.
*
* Syntax:
*
* math.csc(x)
*
* Examples:
*
* math.csc(2) // returns number 1.099750170294617
* 1 / math.sin(2) // returns number 1.099750170294617
*
* See also:
*
* sin, sec, cot
*
* @param {number | BigNumber | Complex | Unit} x Function input
* @return {number | BigNumber | Complex} Cosecant of x
*/
return typed(name, {
number: cscNumber,
Complex: x => x.csc(),
BigNumber: x => new _BigNumber(1).div(x.sin())
}, trigUnit);
});

View File

@@ -0,0 +1,39 @@
import { factory } from '../../utils/factory.js';
import { cschNumber } from '../../plain/number/index.js';
var name = 'csch';
var dependencies = ['typed', 'BigNumber'];
export var createCsch = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
BigNumber: _BigNumber
} = _ref;
/**
* Calculate the hyperbolic cosecant of a value,
* defined as `csch(x) = 1 / sinh(x)`.
*
* To avoid confusion with the matrix hyperbolic cosecant, this function
* does not apply to matrices.
*
* Syntax:
*
* math.csch(x)
*
* Examples:
*
* // csch(x) = 1/ sinh(x)
* math.csch(0.5) // returns 1.9190347513349437
* 1 / math.sinh(0.5) // returns 1.9190347513349437
*
* See also:
*
* sinh, sech, coth
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} Hyperbolic cosecant of x
*/
return typed(name, {
number: cschNumber,
Complex: x => x.csch(),
BigNumber: x => new _BigNumber(1).div(x.sinh())
});
});

View File

@@ -0,0 +1,42 @@
import { factory } from '../../utils/factory.js';
import { secNumber } from '../../plain/number/index.js';
import { createTrigUnit } from './trigUnit.js';
var name = 'sec';
var dependencies = ['typed', 'BigNumber'];
export var createSec = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
BigNumber: _BigNumber
} = _ref;
var trigUnit = createTrigUnit({
typed
});
/**
* Calculate the secant of a value, defined as `sec(x) = 1/cos(x)`.
*
* To avoid confusion with the matrix secant, this function does not
* apply to matrices.
*
* Syntax:
*
* math.sec(x)
*
* Examples:
*
* math.sec(2) // returns number -2.4029979617223822
* 1 / math.cos(2) // returns number -2.4029979617223822
*
* See also:
*
* cos, csc, cot
*
* @param {number | BigNumber | Complex | Unit} x Function input
* @return {number | BigNumber | Complex} Secant of x
*/
return typed(name, {
number: secNumber,
Complex: x => x.sec(),
BigNumber: x => new _BigNumber(1).div(x.cos())
}, trigUnit);
});

View File

@@ -0,0 +1,39 @@
import { factory } from '../../utils/factory.js';
import { sechNumber } from '../../plain/number/index.js';
var name = 'sech';
var dependencies = ['typed', 'BigNumber'];
export var createSech = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
BigNumber: _BigNumber
} = _ref;
/**
* Calculate the hyperbolic secant of a value,
* defined as `sech(x) = 1 / cosh(x)`.
*
* To avoid confusion with the matrix hyperbolic secant, this function does
* not apply to matrices.
*
* Syntax:
*
* math.sech(x)
*
* Examples:
*
* // sech(x) = 1/ cosh(x)
* math.sech(0.5) // returns 0.886818883970074
* 1 / math.cosh(0.5) // returns 0.886818883970074
*
* See also:
*
* cosh, csch, coth
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} Hyperbolic secant of x
*/
return typed(name, {
number: sechNumber,
Complex: x => x.sech(),
BigNumber: x => new _BigNumber(1).div(x.cosh())
});
});

View File

@@ -0,0 +1,44 @@
import { factory } from '../../utils/factory.js';
import { createTrigUnit } from './trigUnit.js';
var name = 'sin';
var dependencies = ['typed'];
export var createSin = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed
} = _ref;
var trigUnit = createTrigUnit({
typed
});
/**
* Calculate the sine of a value.
*
* To avoid confusion with the matrix sine, this function does not apply
* to matrices.
*
* Syntax:
*
* math.sin(x)
*
* Examples:
*
* math.sin(2) // returns number 0.9092974268256813
* math.sin(math.pi / 4) // returns number 0.7071067811865475
* math.sin(math.unit(90, 'deg')) // returns number 1
* math.sin(math.unit(30, 'deg')) // returns number 0.5
*
* const angle = 0.2
* math.pow(math.sin(angle), 2) + math.pow(math.cos(angle), 2) // returns number ~1
*
* See also:
*
* cos, tan
*
* @param {number | BigNumber | Complex | Unit} x Function input
* @return {number | BigNumber | Complex} Sine of x
*/
return typed(name, {
number: Math.sin,
'Complex | BigNumber': x => x.sin()
}, trigUnit);
});

View File

@@ -0,0 +1,35 @@
import { factory } from '../../utils/factory.js';
import { sinhNumber } from '../../plain/number/index.js';
var name = 'sinh';
var dependencies = ['typed'];
export var createSinh = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed
} = _ref;
/**
* Calculate the hyperbolic sine of a value,
* defined as `sinh(x) = 1/2 * (exp(x) - exp(-x))`.
*
* To avoid confusion with the matrix hyperbolic sine, this function does
* not apply to matrices.
*
* Syntax:
*
* math.sinh(x)
*
* Examples:
*
* math.sinh(0.5) // returns number 0.5210953054937474
*
* See also:
*
* cosh, tanh
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} Hyperbolic sine of x
*/
return typed(name, {
number: sinhNumber,
'Complex | BigNumber': x => x.sinh()
});
});

View File

@@ -0,0 +1,41 @@
import { factory } from '../../utils/factory.js';
import { createTrigUnit } from './trigUnit.js';
var name = 'tan';
var dependencies = ['typed'];
export var createTan = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed
} = _ref;
var trigUnit = createTrigUnit({
typed
});
/**
* Calculate the tangent of a value. `tan(x)` is equal to `sin(x) / cos(x)`.
*
* To avoid confusion with the matrix tangent, this function does not apply
* to matrices.
*
* Syntax:
*
* math.tan(x)
*
* Examples:
*
* math.tan(0.5) // returns number 0.5463024898437905
* math.sin(0.5) / math.cos(0.5) // returns number 0.5463024898437905
* math.tan(math.pi / 4) // returns number 1
* math.tan(math.unit(45, 'deg')) // returns number 1
*
* See also:
*
* atan, sin, cos
*
* @param {number | BigNumber | Complex | Unit} x Function input
* @return {number | BigNumber | Complex} Tangent of x
*/
return typed(name, {
number: Math.tan,
'Complex | BigNumber': x => x.tan()
}, trigUnit);
});

View File

@@ -0,0 +1,38 @@
import { factory } from '../../utils/factory.js';
import { tanh as _tanh } from '../../utils/number.js';
var name = 'tanh';
var dependencies = ['typed'];
export var createTanh = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed
} = _ref;
/**
* Calculate the hyperbolic tangent of a value,
* defined as `tanh(x) = (exp(2 * x) - 1) / (exp(2 * x) + 1)`.
*
* To avoid confusion with matrix hyperbolic tangent, this function does
* not apply to matrices.
*
* Syntax:
*
* math.tanh(x)
*
* Examples:
*
* // tanh(x) = sinh(x) / cosh(x) = 1 / coth(x)
* math.tanh(0.5) // returns 0.46211715726000974
* math.sinh(0.5) / math.cosh(0.5) // returns 0.46211715726000974
* 1 / math.coth(0.5) // returns 0.46211715726000974
*
* See also:
*
* sinh, cosh, coth
*
* @param {number | BigNumber | Complex} x Function input
* @return {number | BigNumber | Complex} Hyperbolic tangent of x
*/
return typed('tanh', {
number: _tanh,
'Complex | BigNumber': x => x.tanh()
});
});

View File

@@ -0,0 +1,14 @@
import { factory } from '../../utils/factory.js';
export var createTrigUnit = /* #__PURE__ */factory('trigUnit', ['typed'], _ref => {
var {
typed
} = _ref;
return {
Unit: typed.referToSelf(self => x => {
if (!x.hasBase(x.constructor.BASE_UNITS.ANGLE)) {
throw new TypeError('Unit in function cot is no angle');
}
return typed.find(self, x.valueType())(x.value);
})
};
});