2.2 画出函数图形

点击查看代码
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import quad
 
def fun(t, x):
    return np.exp(-t) * (t ** (x - 1))
 
 
x = np.linspace(0, 10, 100)  # x 的范围
y = [quad(fun, 0, np.inf, args=i)[0] for i in x]  # 计算积分
 
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('$ y = \int_0^{\infty} e^{-t} \cdot t^{x-1} dt $')
plt.grid(True)
plt.show()
 
print("学号:3004")
![](https://img2024.cnblogs.com/blog/3513959/202410/3513959-20241014221650639-181772701.png)

posted on 2024-09-06 16:20  黄元元  阅读(32)  评论(0编辑  收藏  举报