B.Sc.
(H) Physics Semester 5 Computational Physics
August 27-28, 2020 Time Limit : 4 Hrs
Name Roll No.
The following rules apply:
i
Question: 1 2 3 Total
lh
• Each step carries weight.
De
Points: 0 5 5 10
• Step should be commented.
Score:
of
• Answers must be supported.
ty
rsi
Experiment 2
Linear Algebra : Rank and Inverse of Matrix
ive
Gauss Elimination
Un
This experiment is programming exercise to find rank of a matrix by Gauss Elim-
ination method and use it to find determine the possibility of solutions to a set of
linear equations. This experiment also requires to find the inverse of a matrix by
g
Gauss-Jordan method.
r
s.o
For an n × m matrix A, the rank r(A) can be defined as :
sic
• The rank, r(A), of a matrix A is the order of the largest square sub-matrix of
hy
A whose determinant is not equal to zero.
ssp
• The rank, r(A), of a matrix A is the maximum number of linearly independent
vectors that can be formed by the row vectors of the matrix.
The Gauss-Elimination involves elementary row operations to row reduce the ma-
trix A into it’s echelon form EA . The number of non-zero row vectors is then the
e
rank of the matrix.
eg
oll
Another useful theorem is :
Let A be the n × m coefficient matrix of the set of n linear algebraic equations
aC
Ax = B and let A|B be the n × (m + 1) augmented matrix of the system. If
als
• r(A) = r(A|B) = m, there is a unique solution
• r(A) = r(A|B) < m, there are infinitely many solutions expressible in terms
Kh
of m − r(A) parameters
TB
• r(A) < r(A|B), there are no solutions.
SG
B.Sc. (H) Physics Semester 5 Page 2 of 3 August 27-28, 2020
Methodology
Consider any matrix 3 × 3 ( later you can try to generalize to an n × m matrix ).
a11 a12 a13
A = a21 a22 a23
a31 a32 a33
1. Find the size of the rows rA and size of column cA and check whether they are equal (prelim-
lh i
inary condition check for a square matrix).
De
2. Augment the matrix A with an Identity matrix I to get augA = [A|I] and store size of row
and column respectively of matrix augA as raugA and caugA
of
3. Make a choice of the pivot. (i) Choose the biggest element and shift accordingly as the new
a11 (ii) divide by the new a11 to start with as long as a11 6= 0. (You may like to choose a pivot
ty
only for multiplication and not for division).
rsi
4. Apply the rule : Target Row = (- Target Value) * Pivot Row + Target Row.
ive
5. Achieve a lower triangular zero in the matrix, the echelon form EA after performing the row
operations
e13 |
Un
e11 e12 e13 e11 e12
EA = 0 e22 e23 & EaugA = 0 e22 e23 | I 0
0 0 e33 0 0 e33 |
6. Check the value of the determinant which will be the product of the diagonal elements e11 ∗
e22 ∗ e33 of the echelon matrix EA . If determinant is not zero then proceed with the Gauss-
g
Jordan method to find the inverse of A. But if determinant is zero then rank r(A) ≤ 3 and
r
you should stop as the matrix A will be Singular.
s.o
7. Reduce e12 , e13 and e23 to zero by further elementary row operations to get the diagonal DA
sic
form of A
d11 0 0 |
0
hy
augA = 0 d22 0
| O
0 0 d33 |
ssp
8. If DA is further reduced to Identity matrix, the matrix O reduces to A−1 . Check the matrix
A−1 ∗ A = I.
e
eg
oll
aC
als
Kh
TB
SG
B.Sc. (H) Physics Semester 5 Page 3 of 3 August 27-28, 2020
1. Method
(a) (0 points) (Inverse from Row Operations)
Write the procedure to find inverse of a matrix using the row operations.
(b) (0 points) (Condition for Existence)
Also write the necessary and sufficient conditions for existence of the inverse.
2. Coding
(a) (1 point) (Augmentation)
lh i
(Condition) Check the primary condition for inverse.
(Augmentation) Write the augmented matrix.
De
(b) (2 points) (Inverse)
(Gauss Jordan Method) Find the inverse of the matrix A.
of
(c) (2 points) (Rank and Existence of Type of Solution)
(Gauss Elimination Method) For the given set of linear algebraic equations Ax = B,
ty
find the ranks of the matrix A and A|B and predict the solutions.
rsi
3. Applications
ive
(a) (21/2 points) (Test Matrices for Inverse)
2 1 −2 0 1 1 0 0 1 0 0 1 0 1 2
Un
B1 = 3 2 2 ; 1 0 1 ; 1 0 1 ; 1 0 1 ; 1 2 3
5 4 3 1 1 0 1 1 0 1 0 0 3 1 1
(b) (21/2 points) (Simultaneous Equations for Existence of Solutions)
Solve the over-determined system
r g
x1 + x2 = 4
s.o
3x1 − 4x2 = 9
5x1 − 2x2 = 17
sic
Solve the under-determined system
hy
x1 + x2 + x3 + x4 = 0
x1 + 3x2 + 2x3 + 4x4 = 0
ssp
2x1 + x3 − x4 = 0
e
eg
oll
aC
als
Kh
TB
SG