- #1
Illania
- 26
- 0
Homework Statement
I have an algorithm that implements Gaussian elimination. According to the text, with some modification of the indices and their in the loops, I should be able to have this algorithm perform Gauss-Jordan elimination. I also have to reduce the matrix to reduced row-echelon form, but for now I cannot figure out how I would go about modifying the indices to perform Gauss-Jordan elimination.
Homework Equations
The input is a matrix A[1...n, 1...n] and column vector b[1...n]
The output is an upper triangular matrix.
Code:
for i←1 to n do A[i, n+1]←b[i]
for i←1 to n−1 do
pivot ← i
for j←i+1 to n do
if |A[j, i]| > |A[pivot, i]|, pivot←j
for k←i to n+1 do
swap(A[i, k],A[pivot, k])
for j←i+1 to n do
scale←A[j, i]/A[i, i]
for k←i to n+1 do
A[j, k]←A[j, k]−A[i, k]∗scale
The Attempt at a Solution
I have performed Gaussian Elimination on a maxtrix with 3 rows and 4 columns. This leaves a matrix with the form:
Code:
x[SUB]1[/SUB] y[SUB]1[/SUB] z[SUB]1[/SUB] b[SUB]1[/SUB]
0 y[SUB]2[/SUB] z[SUB]2[/SUB] b[SUB]2[/SUB]
0 0 z[SUB]3[/SUB] b[SUB]3[/SUB]
I understand that y1, z1, and z2 also need to be eliminated, but I can't see how to do this with the current algorithm. Could someone kindly give me a push in the right direction here?