index i: 0 1 2 3 4 temp u[i]: 0 0 0 0 1This represents a temperature distribution where the right-most cell is "hot," at temperature 1 and the other cells are "cold," at temperature 0.
What is the temperatue u at future times, given that (a) the temperatures are held fixed at the ends of the rod and (b) the rest of the rod is well insulated? To answer this question we make use of the following physical principle:
The rate of change of the temperature at a given point is proportional to the difference between the average temperature near the point and the temperature at the point.Let us see how this applies to our model, in which we have divided the rod into finitely many cells each of which has a unique temperature. This is, of course an approximation, since the temperature in a cell will in fact vary. However, if the cell is small, the approximation will be a good one. Now, assuming that u[i] is the temperature of the i-th cell at time t, let uu[i] denote the temperature of the i-th cell at time t + h, where h is small. Then our principle reads
uu[i] = u[i] + k( u[i-1] + u[i+1] )/2 - u[i] ) for i = 1..N-2Here k is the constant of proportionality. Note that when k = 1, this is particularly simple:
uu[i] = ( u[i-1] + u[i+1] )/2 for i = 1..N-2
It is not difficult to write a program which computes and displays the future temperatures of a thin, insulated rod given a temperature distribution at time t = 0. Here is an outline for it:
PSEUDOPROGRAM: Constants: N, the number of cells T, the number of time steps Variables: u, an array which holds the current temperature distribution uu, an array which holds the "next" temperature distribution Program: Set up the array u; Print it out; For t from 1 to T: Compute uu from u Print out uu Copy uu into u