function u = P16forward(N) % P16FORWARD compute and plot parts of forward heat equation problem % requires circu.m h = 1/N; x = (0:h:1-h)'; % H is discretization of -d^2/dx^2 + 3 I because heat eqn is 0 = u'' - 3 u + f H = - (1/(h*h)) * circu([-2 1 zeros(1,N-3) 1]') + 3 * eye(N); c = [5 1 4]; f = c(1) * exp(-20*abs(x-.4)) + c(2) * exp(-40*abs(x-.5)) + c(3) * exp(-20*abs(x-.75)); u = H \ f; plot(x,f,'o-',x,10*u,'*-') legend('heat source f(x)','temperature soln, scaled for clarity: 10 * u(x)')