I have a function written to calculate an integral using rectangles. I get this error: 'cannot convert double to double (*) (double) in assignment'.
But whenever I remove one of the doubles something is undeclared. Can anyone tell me what I need to fix?
double rect_integral(double a, double b, int n, int f)
{
switch (f)
{
case 1: fx = func_1; break;
case 2: fx = func_2; break;
case 3: fx = func_3; break;
case 4: fx = func_4; break;
case 5: fx = func_5; break;
}
double height;
double total_area;
double width;
double area;
width = (b-a)/n;
total_area=0;
x = a;
for (int i=1; i <= n; i++) {
x+=width;
total_area+=width*fx(x);
}
return total_area;
}