- Asked 4/13
- 2075 Baisakh · 8 marks
- 2072 Asoj · 8 marks
- 2069 Bhadra · 8 marks
- 2070 Bhadra · 8 marks
Gauss-Jordan pseudo-code
Short answer
Gauss-Jordan method reduces augmented matrix [A|b] to [I|x] by row operations. Algorithm: for k=1 to n, find pivot row with max |a[p][k]|, swap if needed, normalize pivot row, then eliminate column k from all other rows. Solution x[i] = a[i][n+1].
Write a pseudo-code (algorithm) to solve a system of linear equations Ax = b of 'N' unknowns using the Gauss Jordan method.
Gauss-Jordan method reduces the augmented matrix [A | b] to [I | x] using row operations, so the solution is read directly without back substitution. Partial pivoting is included for safety.
Pseudo-code
Algorithm: Gauss-Jordan method
Input : n, matrix a[1..n][1..n+1] (augmented [A | b])
Output: solution x[1..n]
1. Read n and the augmented matrix a
2. For k = 1 to n do
3. // partial pivoting
Find row p (k <= p <= n) with largest |a[p][k]|
If a[p][k] = 0 then
print "No unique solution"; stop
If p != k then swap row p and row k
4. // normalise pivot row
piv = a[k][k]
For j = k to n+1 do
a[k][j] = a[k][j] / piv
End for
5. // eliminate column k from all other rows
For i = 1 to n do
If i != k then
m = a[i][k]
For j = k to n+1 do
a[i][j] = a[i][j] - m * a[k][j]
End for
End if
End for
6. End for
7. For i = 1 to n do
x[i] = a[i][n+1]
End for
8. Print x[1..n]
9. Stop
Notes
- The final coefficient matrix is the identity, so x[i] is the last column.
- Operations count is about n³/2 multiplications, more than Gauss elimination (n³/3).
- The same procedure applied to [A | I] gives the inverse of A.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Gauss elimination/Jordan with pivoting · Numerical Method, chapter 3 · asked 2×
- Gauss elimination, partial pivoting, 4 unknowns · Numerical Method, chapter 3 · asked 4×
- Gauss-Seidel: four unknowns · Numerical Method, chapter 3
- Bisection method pseudo-code · Numerical Method, chapter 2 · asked 3×
- Gauss-Jordan inverse of matrix · Numerical Method, chapter 3
- False position pseudo-code · Numerical Method, chapter 2 · asked 2×
- Algorithm/pseudo-code for software PID · Embedded System, chapter 7 · asked 3×
- Algorithm versus pseudo-code · Computer Programming, chapter 2
- Is y[n] = ax[n] + b linear · Signals and Systems, chapter 6 · asked 4×
- CG algorithm; Gauss-Seidel numerical · Computational Techniques in Civil Engineering, chapter 2