我最近一直在學習如何在python中執行雙積分。這是我在用的:在限制矩陣上執行雙積分
myint = dblquad(lambda xa,xb: np.exp(-(xa-xb)**2),-np.inf,x1,lambda x: -np.inf, lambda x: x2)
,並用於測試目的,我選擇x1和x2是說5和10這似乎是工作。
但實際上,我的x1 = [1,2,3,4,5]和x2 = [5,6,7,8,9],我希望對每個x1組合執行雙重積分和x2即矩陣。我想可以用2來做這個循環,但我認爲可能有更好的方法。
所以我的問題只是 - 如何在極限矩陣上執行雙重積分。
謝謝。
編輯:
我得到以下警告:
UserWarning: The maximum number of subdivisions (50) has been achieved.
If increasing the limit yields no improvement it is advised to analyze
the integrand in order to determine the difficulties. If the position of a
local difficulty can be determined (singularity, discontinuity) one will
probably gain from splitting up the interval and calling the integrator
on the subranges. Perhaps a special-purpose integrator should be used.
這是否意味着它不收斂?我不太瞭解這個消息。
當我的情節:
y = exp(-(x-5)^2)
例如,它只是看起來像高斯曲線,因此不存在問題進行積分,對嗎?是因爲雙重積分的問題嗎?
謝謝。
編輯:
啊,我明白了。謝謝拉曼沙阿,我現在明白了這個問題。
確定操作,這個積分收斂? – Stefan
Stefan的評論很重要,使用'x1,x2 =(5,10)'給出警告,說明積分器不能收斂。考慮增加細分的數量。 – Hooked
如果您只集成了高斯函數,則應該查看特殊函數(例如錯誤函數)來實現其功能。這可能會更快,更準確。編輯:我認爲你有不同的東西,因爲對於xa = xb,被積函數爲1會一直回到-infinity。 –