Python cmath.log() Metodo
Esempio
Trova il logaritmo di un valore complesso:
#Import cmath Library
import cmath
#print log value of some given
parameters
print (cmath.log(1+ 1j))
print (cmath.log(1, 2.5))
Definizione e utilizzo
Il cmath.log()
metodo restituisce il logaritmo di un valore complesso.
Con un singolo argomento, questo metodo restituisce il logaritmo naturale di quell'argomento con base e.
Con due argomenti, questo metodo restituisce il logaritmo del primo argomento (x) con la base del secondo argomento (base).
Sintassi
cmath.log(x, base)
Valori dei parametri
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' |
Dettagli tecnici
Valore di ritorno: | Un complex valore, che rappresenta il logaritmo naturale di un numero o il logaritmo del numero in base |
---|---|
Versione Python: | Modificato nella versione 2.4 |
Registro delle modifiche di Python: | Il parametro di base è stato aggiunto |