作者zoeredbird (柔依‧紅鳥)
標題Re: 廢文
時間2023-11-22 17:51:30
差不多應該可以算是同一個系列的
from scipy import integrate
n = int(input("最高次方: "))
# 設定積分範圍
a = int(input("積分下限: ")) # 積分下限
b = int(input("積分上限: ")) # 積分上限
# 定義要積分的函數
def f(x):
if n - 1 <= 0:
return 0
else:
return x ** n
# 計算積分
result, error = integrate.quad(f, a, b)
# 顯示積分結果
print(f"積分結果: {result}")
--
※ 發信站: 批踢踢實業坊(ptt-web.org.tw), 來自: 116.241.162.180 (臺灣)
※ 文章網址: https://ptt-web.org.tw/Marginalman/M.1700646692.A.D64
推 scmono: 這三小 11/22 17:52