python如何使用log power?
How to use log power in python?
如果我被要求 P(t)=log(V(t)I(t)) 其中 log 是以 e 为底的自然对数。 V(t) 代表电压,I(t) 代表电流。
在我的程序中,我应该输入
def logpower(voltage,current):
p = math.log(voltage*current,math.e)
return p
或
def logpower(voltage,current):
p = math.log(voltage*current)
return p
https://docs.python.org/3/library/math.html#math.log
math.log(x[, base])
With one argument, return the natural logarithm of x (to base e).
With two arguments, return the logarithm of x to the given base,
calculated as log(x)/log(base).
所以你的两个例子都是正确的,但 p = math.log(voltage*current)
看起来更清楚了
如果我被要求 P(t)=log(V(t)I(t)) 其中 log 是以 e 为底的自然对数。 V(t) 代表电压,I(t) 代表电流。 在我的程序中,我应该输入
def logpower(voltage,current):
p = math.log(voltage*current,math.e)
return p
或
def logpower(voltage,current):
p = math.log(voltage*current)
return p
https://docs.python.org/3/library/math.html#math.log
math.log(x[, base])
With one argument, return the natural logarithm of x (to base e).
With two arguments, return the logarithm of x to the given base, calculated as log(x)/log(base).
所以你的两个例子都是正确的,但 p = math.log(voltage*current)
看起来更清楚了