#include <gpk_std.h>
#include <assert.h>
#include <math.h>
#include "romberg.h"

/* good for a function going as 1/x^2. */


struct xx_s     {void *cc; integrand_function ff;};
LOCAL double funclog(double x, void *q, int nc);

method_fr mid_inv2(integrand_function func, double a, double b,
				int n, void *c, int nc)
{
 struct xx_s q;

 assert(a>0.0 && b>0.0);
 q.cc = (void *)c;
 q.ff = func;
 return midpnt(funclog, -1/a, -1/b, n, (void *)(&q), nc);
}

LOCAL double funclog(double x, void *qq, int nc)
{
 struct xx_s *q = (struct xx_s *)qq;
 return (*q->ff)(-1/x, q->cc, nc)/(x*x);
}
