f[x_]=Cos[x]-x;

a[1]=0;
b[1]=1;
Do[p[n]=N[(1/2) (a[n]+b[n])];If[N[f[b[n]] f[p[n]]]<0,a[n+1]=p[n];b[n+1]=b[n],a[n+1]=a[n];b[n+1]=p[n]],{n,1,20}]

TableForm[Table[{a[n],b[n],p[n],N[f[a[n]]],N[f[b[n]]],N[f[p[n]]]},{n,1,20}]]