usencrypt.log#

usencrypt.log(x, n=23, debug=False)#

Computes the natural logarithm of \(x\) using the Newton-Raphson method.

Parameters
  • x (usencrypt.cipher.Float or float) – The input value.

  • n (int) – The number of iterations for the Newton-Raphson method. Defaults to 23.

Returns

The natural logarithm of x.

Return type

usencrypt.cipher.Float or float

Note

  • It takes 23 iterations of Newton-Raphson to converge in range that does not cause overflow.

  • Depends on the usencrypt.exp() function.

Warning

Overflow occurs around the range of \(x = 60\) due to exponentiation occurring in the Newton-Raphson process.

See also

Examples
>>> import usencrypt as ue
>>> a = ue.encrypt(0.75)
>>> a_log = ue.log(a)
>>> a_log
(0x7f845beec820) Float: 0xd75d61fd0708dfa3bd415f181af990dcc7777a13df0656a5f238310a9bc9d74d
>>> ue.decrypt(a_log)
-0.2876820743549615