function [A,b] = mkd1d(p,f,l,n)

h = l/(n+1);
B = ones(n,1)*[-1,2,-1];
A = (p/h^2) * spdiags(B,-1:1,n,n);
x = h*[1:n]';
b = f(x);