% Ex. 2.14 Scheme 2 
% f length n+1 (includes f(1))
function sol = s2(f, n)

h = 1 / (n + 1);
A = diag([2*ones(1, n+1) 1]) - diag(ones(1,n+1), 1) - diag([ones(1,n) 0], -1);
A(n+2, n) = -1;
b = [h*h * f 2*h];

s = A \ b';
sol = s(1:(n+1));