Professional Documents
Culture Documents
Introduction:
We will discuss only direct methods such as Gaussian elimination (the
preferred method of solving system of equation) which is based on LU-
or PLU-decomposition of the matrix of the system where we reduce the
matrix A to an upper triangular form using forward elimination and
then solve the resulting triangular system by backward substitution. In
this process, we factor the matrix A into a product of two matrices: a
lower triangular matrix L and an upper triangular matrix U. We need
the permutation matrix P in our decomposition, which enables us to
interchange two rows in cases where the process can not be carried out
without interchanging of rows. If the matrix A is square and invertible,
we can multiply both sides of the system Ax=b by the inverse A-1 on the
left, and obtain the formula for the solution of the system: x =A-1 b. This
method has many disadvantages such as it is more costly, and its
accuracy of the resulting solution will be worse than if LU-
decomposition is used. The last method is to use reduced row echelon
form, this method is theoretically equivalent to using Gauss-Jordan
elimination, but the solution of this method has larger error than Gauss
elimination and take more time to compute.
Results
1. We will generate matrix A which is magic matrix (a square
matrix that sum of elements of each row equal to the sum of
elements of each column) and b is a column vector.
Backslash “\” operator is based on LU- or P LU decomposition of
the matrix A and x=A\b will produce the solution of the system
Ax=b with the highest possible accuracy and shortest
computational time.
r is the residual which is the difference between the approximate
numerical solution (Ax) and the actual solution of system (b)
r=Ax-b
the resulting r as expected is very close to zero as shown in figure
3.1 which means that the solution will be close enough to the
exact solution
Fig 3.1
Fig 3.2