Demos of solving the heat distribution problem. Problem: Given a square room with the walls at freezing (0 degrees C) and a radiator at 100 degrees C in the middle of the front wall, determine the temperature throughout the interior of the room. Approach: Discretize the room into a grid of 100 by 100 points (10,000 points in all). At each point, the temperature will be approximately the average of the surrounding points. First approach: We use Jacobi's method. Initialize each point to temperature 0, and then repeat the following iteration: replace each point's temp by the average of its surrounding points' temps. Points next to the walls get the specified boundary values (0 or 100) as part of their average. To see one iteration at a time of this approach, say to Matlab: >> jacobi; To see 1000 iterations (or whatever), say: >> jacobi(1000); Second approach: We rearrange the equation for each point's temp so that the variables are on the left and the constant term is on the right. (In the middle of the region, each equation has five variables and the constant is zero. At the edge, each equation has two or three variables and the constant is the boundary value of 0 or 100.) This gives us a system of 10,000 linear equations in 10,000 variables, which we write in matrix form as A*x = b, where A is a 10,000-by-10,000 matrix of coefficients, b is a 10,000-vector of constants, and x is a 10,000-vector of the unknown temperatures. There are many ways to solve linear equation systems, including Jacobi's method. To try out Matlab's method (which is based on Gaussian elimination), say >> load heatproblem % File heatproblem.mat contains A and b >> x = A \ b; % This solves the equations for x >> surfc(reshape(x,100,100)) % This reshapes the x vector % into a square grid and then plots it.