#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define f(x) (cos(x)-x) /* $B2r$/$Y$-J}Dx<0(B */
int main(void){
    int i;
    double a,b,c,f1,f2,f3;
    a = (double)0;
    b = 1.57;
    f1 = f(a);
    f2 = f(b);
    for(i = 1; i <= 10000; i++){
        c = (a + b)/2;
        f3 = f(c);
        printf("%3d: h=%18.15lf,x=%18.15lf, value: %18.15lf\n",i,b-c,c,f3);
        if (b-c<1.0e-16) break;
        if( f1*f3 < 0) b = c;
        else a = c;
    }
    return 0;
}
