/* Integral of exp(-PI*x*x)^2 sinc(PI*x)^2 on the complement of [-1,1], done with Romberg integration */ #include #include #include #define PI 3.14159265358979323 #define JMAX 15 /* Recursion depth limit. */ /* Function to integrate: */ double f(double t) { double x, y; if(t==0) y = 1.0; else { x = PI*t; y = exp(-t*t)*sin(x)/x; } return y*y; } /* Recursive composite trapezoidal rule increment on 2^J segments of [a,b]: */ double rcti(double a, double b, int j) { double h, sum; int n, k; assert(a=0); assert(j<30); n = 1<