math.cbrt(x)x 的立方根。math.cbrt(x)
x (float): 要計算立方根的數值。x 的立方根。import math
print(math.cbrt(27)) # 輸出: 3.0
math.exp(x)e 的 x 次方,即 e**x。math.exp(x)
x (float): 指數。e 的 x 次方。import math
print(math.exp(1)) # 輸出: 2.718281828459045
math.exp2(x)2 的 x 次方。math.exp2(x)
x (float): 指數。2 的 x 次方。import math
print(math.exp2(3)) # 輸出: 8.0
math.expm1(x)e 的 x 次方減去 1,即 e**x - 1,對於接近零的 x 提供更高精度。math.expm1(x)
x (float): 指數。e**x - 1。import math
print(math.expm1(1e-5)) # 輸出: 1.0000050000166668e-05
math.log(x[, base])x 在指定基數下的對數,默認基數為 e。math.log(x[, base])
x (float): 要計算對數的數值。base (float, 可選): 對數的基數,默認為 e。x 在指定基數下的對數。import math
print(math.log(10)) # 輸出: 2.302585092994046 (自然對數)
print(math.log(100, 10)) # 輸出: 2.0 (以 10 為基數)
math.log1p(x)1 + x 的自然對數,對於接近零的 x 提供更高精度。math.log1p(x)
x (float): 要計算的數值。1 + x 的自然對數。import math
print(math.log1p(1e-5)) # 輸出: 1.0000050000287824e-05