n = 8;
a = -4*ones(n,1);
b = ones(n,1);
c = ones(n,1);
f = ones(n,1);
x = tridiag(a,b,c,f);

A = diag(b(2:end), -1) + diag(a) + diag(c(1:end-1),1);
A\f -x
