计算指数函数导数的极限

Calculate the limit of the derivative of an exponential function

我正在尝试编写一个程序来计算指数函数导数的极限。我已经让程序使用数据类型 float 工作。但是它的精度有点低。我曾尝试使用 decimal 数据类型,但无法使其与 math.exp 一起使用,我可以绕过它吗?只是想完成基本的计算并将其放入我的程序中。

import decimal
import math

a = decimal.Decimal('2.0')
h = decimal.Decimal('0.1')

d=decimal.Decimal((a*(math.exp(a*(a+h))-(math.exp(a*(a)))))/h)
print(d)

您需要使用十进制库的指数函数。在此页面中搜索 "exp(":

https://docs.python.org/2/library/decimal.html

您还应该设置精度。