MTH308 and MTH308B Lab Assignment 3
MTH308 and MTH308B Lab Assignment 3
MTH 308 and & MTH 308B: Numerical Analysis and Scientific
Computing-I
January-April 2024, IIT Kanpur
1. Write a C program on Gaussina Elimination (on n×n system) with backward substitution.
Hint: (You can use the following algorithm)
INPUT : Number of unknowns and equations n, the augmented matrix A = [aij ] for
1 ≤ i ≤ n and 1 ≤ j ≤ n + 1.
OUTPUT: The solution vector x = [xj ] or message that the system has no unique solution.
Step-1: For i = 1, 2, . . . , n − 1 do Steps 2 to 4.
1
h i
1
aij − i−1
P
Step-5: For j = i + 1, . . . , n, set uij = lii k=1 ik kj ,
l u
h Pi−1 i
1
lji = uii aji − k=1 ljk uki .
Pn−1
Step-6: Select lnn and unn satisfying lnn unn = ann − k=1 lnk ukn .
Step-7:
OUTPUT (lij for j = 1, . . . , i and i = 1, . . . , n); and
OUTPUT (uij for j = i, . . . , n and i = 1, . . . , n);
STOP.
End.