Implementation and package functions
Above, it was shown that we need to solve the equation:
where A is the coefficient matrix, given in Equations (6.14) and (6.17), φ is the vector that we are trying to find and represents, for example, the temperature at the grid points. The vector b has elements given by the source term and grid distance for interior grid point, as well as the boundary conditions for boundary points. We may write this as:
To solve the Poisson equation, we basically need to:
1. Specify the source term and the boundary values.
2. Generate the coefficient matrix.
3. Solve the linear equation system.
In addition, we need to convert between the vector and matrix arrays for the two-dimensional case.
Since b is given by the problem, we only need to create the coefficient matrix. We will choose here to program one Octave function that generates the matrix for the one-dimensional Poisson equation and another function that generates the matrix for the two-dimensional case...