#include #include #include #include "opt.h" #define Debug 0 #define Static static dbl f (dbl x) { return sin(x) - 0.50; } /* find a solution of sin(x) - 0.5 = 0 between 0.0 and M_PI/2 */ main() { dbl a, b, z; status stat, IntervalReduction(); a = 0.00; b = M_PI/2.00; fprintf(stderr, "%lf %lf\n", f(a), f(b)); stat = IntervalReduction(f, a, b, &z, 1000, 1.0e-6); if (stat == success) { fprintf(stderr, "zero = %lf\n", z); fprintf(stderr, "true = %lf\n", M_PI/6); } else { fprintf(stderr, "stat = %d\n", stat); } }