With only one dimension, and applying the finite difference method, we obtained the equation, for integer index i which can range from 1 to N as in equation (2.9). So the core algorithm aside from housekeeping procedures simply is:
for each time step in var i for j 2:N-1 u[i+1][j] = z * (u[i][j-1] + u[i][j+1]) + (1-z) * u[i][j]; end for end for
Of course, assuming that u is a 2 dimensional array with which the first component represents the time step and second component is the discretized index.
Using this algorithm, a program called poissonRod was written. The result is represented in Figure 3.1 where