为什么 1**Inf == 1 ?
我相信它应该是 NaN,就像 Inf-Inf 或 Inf/Inf 一样。
如何在 python 中对 float 求幂? exp(y*log(x)) 会得到正确的结果:/
请您参考如下方法:
你是对的,数学上,the value of 1∞ is indeterminate .
但是,在这种情况下,Python 并没有完全遵循数学原理。 The document of math.pow说:
math.pow(x, y)Return
xraised to the powery. Exceptional cases follow Annex ‘F’ of the C99 standard as far as possible. In particular,pow(1.0, x)andpow(x, 0.0)always return1.0, even whenxis a zero or a NaN.
