As part of a homework assignment my program has to have a function which will carry out Simpson's method for integration. Anyway my function is given here:
When used with the values a=-1, b=1 and N=4, the values for funca and funcb give correct answers, however the result of functerm is a massive number (in the order of 10^238 or something) when it should be about 10. Can anyone spot where my mistake is being created?
double function1(double a, double b, int N)
double funca = sqrt(1+pow(a,4));
double funcb = sqrt(1+pow(b,4));
int count = 1;
if(count%=2 == 0)
result=(functerm + funca + funcb)*((b-a)/(3*N));
The formula for Simpson's rule was given on a sheet by the way, as neither myself nor my maths student friends seem to remember it as its given there.