usencrypt.tanh#
- usencrypt.tanh(x, debug=False)#
Computes the hyperbolic tangent of \(x\) using the definition \(\tanh(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}\).
- Parameters
x (
cipher.Float
orfloat
) – The input value.- Returns
The hyperbolic tangent of
x
.- Return type
Warning
The precision of this function is largely dependent on the precision of the
usencrypt.exp()
function. See the warnings forusencrypt.exp()
.See also
- Examples
>>> import usencrypt as ue >>> a = ue.encrypt(0.75) >>> a_tanh = ue.tanh(a) >>> a_tanh (0x7f843a4af3a0) Float: 0x3078bb8849f5db024314264c3458ad37a87eb0ed47db3171aa37a6ede1f30d3a >>> ue.decrypt(a_tanh) 0.6351489531807601