Python cmath.log()メソッド
例
複素数値の対数を求めます。
#Import cmath Library
import cmath
#print log value of some given
parameters
print (cmath.log(1+ 1j))
print (cmath.log(1, 2.5))
定義と使用法
このcmath.log()
メソッドは、複素数値の対数を返します。
単一の引数を使用すると、このメソッドは基数eを使用したその引数の自然対数を返します。
2つの引数を使用すると、このメソッドは最初の引数(x)の対数と2番目の引数(base)の底を返します。
構文
cmath.log(x, base)
パラメータ値
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' |
技術的な詳細
戻り値: | complex 数値の自然対数、または基数となる数値の対数を表す値 |
---|---|
Pythonバージョン: | バージョン2.4で変更 |
Python変更ログ: | 基本パラメータが追加されました |