The cmath.log()
function returns the natural logarithm of a given complex number.
cmath.log(x[, base])
x |
The value(real or complex) whose logarithm we want. If the argument is a real number, it is first converted to a complex number before the operation. |
base |
This optional argument indicates the base to be used in calculating the logarithm. If the base is not specified, natural logarithm (base e) is used. |
The function returns a complex number representing the logarithm of x
to the given base.
import cmath
print(cmath.log(2))
print(cmath.log(2 + 3j))
print(cmath.log(1 + 0.5j))
print(cmath.log(10 + -10j))