Metoda cmath.log() Pythona
Przykład
Znajdź logarytm wartości zespolonej:
#Import cmath Library
import cmath
#print log value of some given
parameters
print (cmath.log(1+ 1j))
print (cmath.log(1, 2.5))
Definicja i użycie
Metoda cmath.log()
zwraca logarytm wartości zespolonej.
Z pojedynczym argumentem ta metoda zwraca logarytm naturalny tego argumentu o podstawie e.
Z dwoma argumentami ta metoda zwraca logarytm pierwszego argumentu (x) z podstawą drugiego argumentu (baza).
Składnia
cmath.log(x, base)
Wartości parametrów
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' |
Szczegóły techniczne
Wartość zwrotu: | Wartość complex reprezentująca logarytm naturalny liczby lub logarytm liczby o podstawie |
---|---|
Wersja Pythona: | Zmieniono w wersji 2.4 |
Dziennik zmian Pythona: | Dodano parametr bazowy |