フィルターのクリア

Riemann sum multiple dimensions

1 回表示 (過去 30 日間)
Ema
Ema 2017 年 5 月 8 日
編集済み: Ema 2017 年 5 月 8 日
I have 2 tasks. a) Try to approximate the volume of a sphere with radius 1. Do this with riemann sum in matlab. What ive done in my code is to change from x,y,z to spheric coordinates with r,theta and phi. my code is :
r_max=1;
theta_max=pi;
phi_max=2*pi
nof_r=100;
nof_theta=100;
nof_phi=100;
dr=r_max/nof_r;
dtheta=theta_max/nof_theta;
dphi=phi_max/nof_phi;
I=0;
for i=1:nof_r
for j=1:nof_theta
for k=1:nof_phi
r=(i-1/2)*dr;
theta=(j-1/2)*dtheta;
phi=(k-1/2)*dphi
I=I+r^2*sin(theta)*dr*dtheta*dphi;
end % k
end % j
end % i
I think i got this one.
But in the second part. I have to approximate the volume of a sphere in 10 dimension were the real answer is pi^5/120. (radius 1) In the first part i did used spheric coordinates. Maybe i should have done this with something else? Because i have no idea how to express it with the same method in a 10th dimension.
  2 件のコメント
Jan
Jan 2017 年 5 月 8 日
Due to the lack of comments it is hard to guess the intention of the code. Stuffing multiple command in a line decreases the readability also. Remember that most of the members of the forum do not work with Riemann sums currently, in opposite to you.
Ema
Ema 2017 年 5 月 8 日
Ok, thank you for your answer. I will try to make my code somewhat more readable.

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

回答 (1 件)

Jan
Jan 2017 年 5 月 8 日
The question does not concern the implementation in Matlab, but the mathematical problem. See https://en.wikipedia.org/wiki/N-sphere for the definition of the volume elements of an N-sphere.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by