CS计算机代考程序代写 Practice: Calculate $\int_1^2\frac{exp(-x)}{-x}dx$

Practice: Calculate $\int_1^2\frac{exp(-x)}{-x}dx$
In [1]:
import numpy as np
In [2]:
a = 1
b = 2
In [3]:
N = 1000
x = np.random.rand(N)
In [4]:
y = a+(b-a)*x
In [5]:
gx = np.exp(-y)/(-y)*(b-a)

np.mean(gx)
Out[5]:
-0.17455772651477353
In [ ]: