20 #define MACHINE_PRECISION 2.2204e-16
22 #define ALPHA 0.816496580927726
23 #define BETA 0.447213595499958
26 static int Termination2;
28 static double AdaptLobStep(
float (*f)(
float,
const void*),
double a,
double b,
29 double fa,
double fb,
double Tol,
double hmin,
const void *Param);
43 float AdaptLob(
float (*f)(
float,
const void*),
float a,
float b,
44 float Tol,
const void *Param)
47 return (
float)AdaptLobStep(f, a, b, f(a, Param), f(b, Param),
52 static double AdaptLobStep(
float (*f)(
float,
const void*),
double a,
double b,
53 double fa,
double fb,
double Tol,
double hmin,
const void *Param)
55 double m, h, Q, fmll, fml, fm, fmr, fmrr;
61 if(h < hmin || m == a || m == b)
65 fprintf(stderr,
"Minimum step size reached.\n");
72 fmll = f(m -
ALPHA*h, Param);
73 fml = f(m -
BETA*h, Param);
75 fmr = f(m +
BETA*h, Param);
76 fmrr = f(m +
ALPHA*h, Param);
77 Q = (h/1470.0)*(77.0*(fa + fb) + 432.0*(fmll + fmrr)
78 + 625.0*(fml + fmr) + 672.0*fm);
80 if(fabs(Q - (h/6.0)*(fa + fb + 5.0*(fml + fmr))) <= Tol)
83 return (
double)AdaptLobStep(f, a, m -
ALPHA*h, fa, fmll, Tol, hmin, Param)
84 + (double)AdaptLobStep(f, m -
ALPHA*h, m -
BETA*h, fmll, fml, Tol, hmin, Param)
85 + (double)AdaptLobStep(f, m -
BETA*h, m, fml, fm, Tol, hmin, Param)
86 + (double)AdaptLobStep(f, m, m +
BETA*h, fm, fmr, Tol, hmin, Param)
87 + (double)AdaptLobStep(f, m +
BETA*h, m +
ALPHA*h, fmr, fmrr, Tol, hmin, Param)
88 + (double)AdaptLobStep(f, m +
ALPHA*h, b, fmrr, fb, Tol, hmin, Param);