|
Dear gnu g++:
I like to solve couble integral on a circle
I simplify it , then get
(not 100% sure, but almost)
so I try to ckeck it by numerical way (computer software programming)
the following is my simple c program to get area under curve by accumulate trapzoides
-----------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
int main() { int i, j; double step, sum, x[10001], z[10001]; i=0; j=0; sum=0.0;
step = 6.0/10000.0;
x[0]=z[0]=-3.0; for (i=0; i<10000; i++) x[i+1]=z[i+1]=x[i]+step; for (i=0; i<10000; i++)
&nbs, x[10001], z[10001]; i=0; j=0; sum=0.0;
step = 6.0/10000.0;
x[0]=z[0]=-3.0; for (i=0; i<10000; i++) x[i+1]=z[i+1]=x[i]+step; for (i=0; i<10000; i++)
for (j=0; j<10000; j++) if ((x[i]*x[i]+z[j]*z[j]) < 9.0) sum = sum + ((9.0*x[i+1]*x[i+1]-3.0*z[j+1])+(9.0*x[i]*x[i]-3.0*z[j]))* step * 0.5; printf("sum = %f\n", sum);
} ------------------------------------------------------------------------------------------------------------------------ tested in my gcc 3.3.3 cygwin xp
$ ./a.exe
sum = 954212.727469 ------- which is not what I expected
like to see any advice
eric
|
<<inline: clip_image002.gif>>
<<inline: clip_image002.gif>>
_______________________________________________ Help-gplusplus mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gplusplus
