Método Python cmath.log()
Ejemplo
Encuentra el logaritmo de un valor complejo:
#Import cmath Library
import cmath
#print log value of some given
parameters
print (cmath.log(1+ 1j))
print (cmath.log(1, 2.5))
Definición y uso
El cmath.log()
método devuelve el logaritmo de un valor complejo.
Con un solo argumento, este método devuelve el logaritmo natural de ese argumento con base e.
Con dos argumentos, este método devuelve el logaritmo del primer argumento (x) con la base del segundo argumento (base).
Sintaxis
cmath.log(x, base)
Valores paramétricos
Parameter | Description |
---|---|
x | Required. Specifies the value to calculate the logarithm for. If the value is 0 or a negative number, it returns a ValueError. If the value is not a number, it returns a TypeError |
base | Optional. The logarithmic base to use. Default is 'e' |
Detalles técnicos
Valor devuelto: | Un complex valor, que representa el logaritmo natural de un número, o el logaritmo de un número en base |
---|---|
Versión de Python: | Cambiado en la versión 2.4 |
Registro de cambios de Python: | Se agregó el parámetro base. |