Double integral using matlab multiplication

2 ビュー (過去 30 日間)
Saqeeb Adnan
Saqeeb Adnan 2022 年 4 月 12 日
編集済み: Torsten 2022 年 4 月 13 日
Hello, I want to calculate the double integral of an expression (not given here) using matrix multiplication. Using integral2 doesnot work for my case because of singularity issues I will have in that problem. So, first I'm trying out some basic double integral using matrix multiplication but those are not giving me the accurate answer I get calculating analytically.
Integration of sin(th).cos(phi) d(th)d(phi) in the limit of th=0 to pi and phi=0 to 2pi
th=0:pi/180:pi; %theta
phi=0:pi/180:2*pi; %phi
dth2=th(6)-th(5); dphi=phi(6)-phi(5);
int= (dphi.*ones(1,length(phi)))* (cos(phi)'*sin(th))*(dth.*ones(1,length(th)))'; %integration by matrix multiplication
I get answer of 0.0349 instead of 0. Increasing step size to a very massive number helps but that's unreasonable.
Can anyone help, where I'm doing wrong

採用された回答

Torsten
Torsten 2022 年 4 月 12 日
th=pi/(2*180):pi/180:pi-pi/(2*180); %theta
phi=pi/(2*180):pi/180:2*pi-pi/(2*180); %phi
dth=th(6)-th(5); dphi=phi(6)-phi(5);
intvalue= (dphi.*ones(1,length(phi)))* (cos(phi)'*sin(th))*(dth.*ones(1,length(th)))'
  2 件のコメント
Saqeeb Adnan
Saqeeb Adnan 2022 年 4 月 12 日
Thank you so much. So, the singularity at pi/2 was the reason.
Torsten
Torsten 2022 年 4 月 12 日
編集済み: Torsten 2022 年 4 月 13 日
No. In order to approximate a two-dimensional integral, you always have to take the value of the function at the center of a cell, not at the boundary, and multiply it with the area of that cell.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by