Python 求曲线面积
求曲线交点
#求曲线交点
import numpy as np
from shapely.geometry import LineString
x = np.arange(-9,9,0.001)
y1 = x
y2 = x**3
line_1 = LineString(np.column_stack((x,y1)))
line_2 = LineString(np.column_stack((x,y2)))
inter = line_1.intersection(line_2)
for i in inter:
print(np.round(i))
已知端点求积分
#求曲线面积
import numpy as np
x = np.arange(0,1,0.000001)
y = np.zeros(len(x))+2 #np.sqrt(1-x**2)
print(np.trapz(y, x, dx = 0.001))
或
#求曲线面积
from scipy import integrate
import numpy as np
def f(x):
return np.sin(x)
print(integrate.quad(f, -4, 4))
print(integrate.quad(np.sin, -4, 4))
参考
https://www.bilibili.com/video/av583623229/