jiangchengfeiyi-xiaochengxu/node_modules/mathjs/lib/cjs/function/trigonometry/tanh.js
2025-01-02 11:13:50 +08:00

44 lines
1.2 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createTanh = void 0;
var _factory = require("../../utils/factory.js");
var _number = require("../../utils/number.js");
const name = 'tanh';
const dependencies = ['typed'];
const createTanh = exports.createTanh = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
let {
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: _number.tanh,
'Complex | BigNumber': x => x.tanh()
});
});