First some helpful code concerning linear algebra. The code is included in math module.
Two classes were introduced : Vector and Matrix to store float numbers and where indexes start from 1.
To read : ala= matrixA[row,column], to write set(matrixA,row,column).
Module math contains two procedures to solve linear equations. First is gaussSeidelIteration procedure
– equations are solved by iterive Gauss-Seidel method.
The method is convergent if matrix is diagonaly dominant - diagonal element is greater than sum of other row elements
– situation that takes place for finite difference equations.
Second procedure is solveUsingLUFact where LU factorization method is used to solve linear equations.
First example shows how to solve differential equations using finite difference method.
The example describes how to build equations matrix for heat flow.
Second example shows how to solve nonlinear differential equations where Newton method to find zeros of a function is used.