These notes will guide you through the steps necessary to solve Laplace's equation.
Although this equation occurs in many different contexts in science and engineering, it is
most intuitive when applied to the problem of calculating the temperature on a metal plate
that is heated or cooled at the edges and at various points inside the plate. You can also
find this problem described as an electrostatics problem in the books on reserve in the
library. (Some of you may even remember doing this electrostatics experiment using carbon
paper and a voltmeter in second semester physics laboratory.)
Let me be specific. Imagine that a square plate that has its edges fixed at zero
degree. In the interior of the plate there is a long narrow region that is heated to +10
degree and a second region that is cooled to - 10 degree. How do you find the temperature
at other points inside the plate that are not being heated or cooled?
Begin by dividing the plate using a grid of equally spaced points as shown above. A measurement of the temperature at all the grid points produces a matrix of numbers, T[i , j], with the first index specifying the grid row and the second index specifying the grid column. The temperature is known at all grid points that lie along the edge and at all grid points that are being heated or cooled. These temperature values are called boundary conditions. They are represented as white squares in the figure. The only temperatures that we need to calculate are those temperatures at points that are not on a boundary. These are the temperatures inside the blue squares. The algorithm is amazingly simple: at any grid point not on a boundary the temperature will be the average of the temperatures at the four nearest neighbors. The only catch is that you must perform these calculations at every grid point at the same time. You cannot, for example, calculate T[4,5] using the following code
T[4,5] := ( T[3,5]+T[5,5]+T[4,4]+T[4,6] )/4
because this would change the T[4,5] matrix value and you need this value when you
calculate the T[4,6] value. This problem is easily solved if you define a second matrix to
hold the newly calculated values. After you are done calculating the entire grid you can
copy the new values back into the original temperature array. Don't forget to reset the
boundary conditions since the temperature on these grid points never changes.
The above process is repeated over and over again-something the computer likes to do-until the array of values stops changing by some small predetermined amount. One hundredth of a degree would be a reasonable error for this problem. The method that you are using is called the relaxation method in most books.