Python 求曲线面积

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/

    原文作者:咿呀咿呀哟咿呀
    原文地址: https://blog.csdn.net/EnHengNa/article/details/120159876
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞