n_arr = [9 19 49 99];

prev_h = 0.2;
x = 0.2:0.2:1;
f = -exp(x - 1);
ts = exp(-1)*(exp(x) - 1);
ns1 = s1(f, 4);			% s1 is a function that computes solution with scheme S1,
ns2 = s2(f, 4);			% input data is f at x_1, ... x_{n+1} and n
prev_e1 = max(abs(ts - ns1'));
prev_e2 = max(abs(ts - ns2'));
[4 prev_h prev_e1 prev_e2]

for k=1:length(n_arr)
  h = 1 / (n_arr(k) + 1);
  x = h:h:1;
  f = -exp(x - 1);
  ts = exp(-1)*(exp(x) - 1);
  ns1 = s1(f, n_arr(k));
  ns2 = s2(f, n_arr(k));
  e1 = max(abs(ts - ns1'));
  e2 = max(abs(ts - ns2'));
  r1 = log(e1 / prev_e1) / log(h / prev_h);
  r2 = log(e2 / prev_e2) / log(h / prev_h);
  [n_arr(k) h e1 e2 r1 r2]
  prev_e1 = e1; prev_e2 = e2; prev_h = h;
end
