Module 2
- We will have to enter the adjacency or the Coefficient matrix into
A
, which we obtain by extracting the coefficients from the system of linear equations. - We will have to ensure that this matrix
A
is diagonally dominant, which is a condition for this method to function properly. - We also feed in the RHS values into
b
. - We also need to key in the initial solution that we can decide upon based on the question in hand.
- We should also enter the
accuracy_decimal
, which is the decimal place accuracy to which answer should be obtained, the number of iterations taken by the code depends on this value. - To prevent the non-convergence condition, the code will proceed till a maximum of
20 iterations
is reached. - The code prints the
estimated value
at theend of every iteration
along with theerror
which is also essential in this method.
- We will have to perform an
LU Decomposition
of the coefficient matrixA
and feed them intoL
andU
for the Lower and the Upper diagonal Matrices respectively. - Though this process can be automated by the
lu()
function, the results obtained here does not match with the ones obtained by the method followed by us currrently. Using that too should yield you the same end result, but I am currently also focussed more on the output of each step than the final result. - We will have to ensure that all the leading sub-matrices of the matrix
A
has a non-zero determinant. - We also feed in the RHS values into
b
. - The code prints the
L inverse
,Z
whereZ=L_inv*b
,U inverse
, and the final resultX
.
- We will have to enter the adjacency or the Coefficient matrix into
A
, which we obtain by extracting the coefficients from the system of linear equations. - We have to ensure that
A
is a tri-diagonal system. - We also feed in the RHS values into
b
. - The code prints the
d
-- diagonal elements,a
-- upper diagonal elements,b
-- lower diagonal elements,r
-- rhs or residue values, thea
, andr
values during theForward elimination
step, thex
values during theBackward Substitution
step, and the finalX
values which is the solution to the system of equations.
4. Power Method
- We will have to enter the matrix into
A
. - We also need to key in the initial solution into
X_cur
that we can decide upon based on the question in hand. - We should also enter the
accuracy_decimal
, which is the decimal place accuracy to which answer should be obtained, the number of iterations taken by the code depends on this value. - To prevent the non-convergence condition, the code will proceed till a maximum of
20 iterations
is reached. - The code displays the
P
,X
, and the normalzing value which is the maximum value among theP
values, all for every iteration. - The final
X_cur
displayed is thedominant eigen value
of the entered matrix
Coming Soon