Solving the Heat Equation (DD case) using the Discrete Sine Transform
Contents
You first have to download m-files
Download the m-files sintr.m , isintr.m , colorcurves.m and put them in the same directory as your other m-files.
Solve heat equation 
We want to find a function
for
,
such that


where
is a given function on
.
Boundary conditions: At the endpoints we have DIRICHLET conditions
and
.
The method of Separation of Variables gives the following Solution Formula:
First find the sine series
. Let
for
. Then the solution
is given by

Example: given initial temperature 
fct = @(x) x; % given function for initial temperature N = 100; % use spacing 1/100 for x x = (1:N-1)'/N; % only interior nodes (column vector) g = fct(x); % evaluate g for 1/N,...,(N-1)/N (column vector) b = sintr(g); % take Discrete Sine Transform t = 0:.005:.05; % find solution for these t-values (row vector) kv = (1:N-1)'; % column vector of k-values muv = kv*pi; % column vector of mu-values W = exp(-muv.^2*t); % array of exp(-mu_k^2*t) for k=1...N-1, for all t-values % (column vector)*(row vector) gives array U = isintr(diag(b)*W); % multiply 1st row by b(1), 2nd row by b(2), ... % then take Inverse Sine Transform of each column colorcurves(x,t,U); axis tight xlabel('x'); ylabel('t'); title('temperature u(x,t) for t=0,.005,...,.05')
Show solution as graph over (x,t) plane
view(160,30)