#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "bisection.h"

double func(double x) {
    return x * sin(x) - 1;
}

int main(int argc, char *argv[]) {
    unsigned int steps, i, begin, end;
    double bisection;

    if( argc != 3 ) {
        printf("Usage: %s BEGIN END\n", argv[0]);
        return 1;
    }

    begin = atoi(argv[1]);
    end = atoi(argv[2]);

    for( i = begin; i <= end; i++ ) {
        bisection = bisec(&func, 0, 2, pow(10, -1.0 * i), &steps, 100000);
        printf("zero point: %.30f for epsilon = 1e-%d (%d steps)\n", bisection, i, steps);
    }

    return 0;
}
