I think I'm doing everything correctly but for some reason the program refuses to compute, it just freezes.

I'm given an equation for a curve, and for certain values of x and y along that I want to take the double integral and set that over the double integral of the whole curve and compute that fraction.

To do this I loop through values of x and y and then multiply them to get the double integral of the whole curve.

For the isolated section of the curve I substitute a new variable z for y and then within the x loop I cycle through z values for each value of x and if x and z are within certain values I compute the smaller integral.

I then set the two integrals over each other and compute that fraction.

What am I doing wrong?

Code:`#include <stdio.h>`

#include <math.h>

#define STEP 5.556e-5

int main() {

float a=0.3489, b=0.255, R=0.68085, xlimit=0.2799, zlimit=-0.0008;

float utotalarea=0;

float vtotalarea=0;

float x, xarea, xtotalarea=0;

float y, yarea, ytotalarea=0;

float z, zarea;

float result, result2, fraction;

//First loop through x values.

for (x=STEP; x<=10; x=x+STEP){

xarea=0.5*(exp(-log(2)*pow(x/a,2)-1)+exp(-log(2)*pow((x-STEP)/a,2)-1))*STEP;

xtotalarea=xtotalarea+xarea;

//Next, loop through z values for each x value. Note: z is really y, its a different variable here in order to calculate the integral for certain x and y values.

for (z=STEP; z<=10; z=z+STEP){

zarea=0.5*(exp(-log(2)*pow(z/b,2)-1) + exp(-log(2)*pow((z-STEP)/b,2)-1))*STEP;

//If x and z are within certain values take integral.

if((pow(x-xlimit,2)+pow(z-zlimit,2))<=pow(R,2)){

utotalarea=utotalarea+xarea;

vtotalarea=vtotalarea+zarea;

}

}

}

//Now, loop through all y values.

for (y=STEP; y<=10; y=y+STEP){

yarea=0.5*(exp(-log(2)*pow(y/b,2)-1)+exp(-log(2)*pow((y-STEP)/b,2)-1))*STEP;

ytotalarea=ytotalarea+yarea;

}

//Compute double integral for the whole curve.

result=xtotalarea*ytotalarea;

//Compute double integral for the certain x and z values.

result2=utotalarea*vtotalarea;

//Set the smaller integral over the larger integral.

fraction=result2/result;

//print the fraction.

printf("%.5f\n", fraction);

}