2019-03-04
阅读量:
1961
exp() - 1和expm1有什么区别
expm1():
如果我们总能计算exp()然后从中减去1,那么为什么甚至会创建方法会有一个问题。第一个原因是价值exp() - 1
在数学和科学应用和公式中被大量使用。
最重要的原因是,对于x的较小值,小于e-10的数量级,expm1()
方法给出的结果更准确exp() - 1
。
代码#:比较expm1()和exp() - 1
# Python3 code to demonstrate
# the application of expm1()
import math
# initializing the value
test_int = 1e-10
# checking expm1() values
# expm1() is more accurate
print ("The value with exp()-1 : " + str(math.exp(test_int)-1))
print ("The value with expm1() : " + str(math.expm1(test_int)))
输出 :
The value with exp()-1 : 1.000000082740371e-10
The value with expm1() : 1.00000000005e-10






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论