#include /* * Romberg integration * D.N.Harris@damtp.cam.ac.uk * 2002-03-29 */ double f(double x) /* define integrand */ { return sin(x*x); } int MainCL() { double result, error_estimate; int subintervals; subintervals = 1; while (subintervals < 8) { /* Note that RombergCL stores an estimate of the error in the variable specified by the fourth parameter, hence we must provide a pointer to error_estimate using the & operator. */ result = RombergCL(f, 0., 1., &error_estimate, subintervals); printf("%5i %10.5f %10.1e\n", subintervals, result, error_estimate); subintervals = subintervals + 1; } }