This program is designed to solve the heat equation (five-point pattern) in a two-dimensional domain on uniform grids. Boundary conditions – linear interpolation between the corners of the region. The value in the corners is 10, 20, 30, 20. The algorithm is as follows:
- First we fill in the boundaries of the array.
- Then, in a loop, we run through all the elements of the array except the boundary ones and calculate them as the average between the four neighbors, and save the result to a new array. Then we subtract the old array from the new one element by element and find the maximum. That's how we found the error. We repeat this procedure until the error becomes less than we need or until the number of iterations exceeds the limit we have set.