ClearAll[x, f, trueAns, d, phi, h, i, j]

x = Pi/4.0

f[x_] := Cos[x];

trueAns = -Sin[x]

phi[x_, h_] := (f[x + h] - f[x - h])/(2 h);

h = 0.1;

For[i = 0, 
      i < 4, i++, 
d[i, 0] = 
        phi[x, h/(2^i)]; 
For[j = 1, 
        j ≤  
          i, j++, 
d[i, j] = 
            d[i, j - 
                  1] + (1/((4^j) - 1)) (d[i, j - 1] - 
                    d[i - 1, 
                      j - 1]);
];
]

Table[d[i, j], {i, 0, 3}, {j, 0, i}] // TableForm

(* Now,  
      print out the error for each entry in the above table *)

Table[d[i, j] - trueAns, {i, 0, 3}, {j, 0, i}] // TableForm