usencrypt.exp#
- usencrypt.exp(x, n=50, debug=False)#
Computes the exponential of \(x\) using \(n\) iterations of the Taylor series approximation method.
- Parameters
x (
usencrypt.cipher.Float
orfloat
) – The input value.n (
int
) – The number of iterations for the Taylor series approximation method. Defaults to50
.
- Returns
The exponential of
x
.- Return type
Note
Using about 50 iterations of the Taylor series gives us error-free precision on the range \(−9 < x < 20\).
Warning
The total range of numbers we can represent with our 64 bits is from \(2^{-32}\) to \(2^{31}\). Ideally with the exponential, we would be able to cover calculations up to the range \(x = 22\). Currently, the series method fails to do that.
- Examples
>>> import usencrypt as ue >>> a = ue.encrypt(2.0) >>> a_exp = ue.exp(a) >>> a_exp (0x7f843af52c40) Float: 0x7cda4283cad131a5d7fe9dae55a7b2a9bd5988755b61bfbae75d0f98885c32b0 >>> ue.decrypt(a_exp) 2.117000014986843