Riemann sum multiple dimensions
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Jan
il 8 Mag 2017
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.
Risposte (1)
Jan
il 8 Mag 2017
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.
0 Commenti
Vedere anche
Categorie
Scopri di più su Mathematics and Optimization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!