rowswap;

Calculate

? rowswap;

Calculate

rowswap;

Calculate

? rowswap;

Calculate

### rowswap

Run Example
```(%i1)/*	Eileen M. Dioquino	2010-36416	exer 8: Gauss Jordan*//*	Given Equations*/	eq[1]: [3*x1 + 4*x2 + 5*x3 - 2*x4 - 4*x5 = 10];
(%o1)              [- 4 x5 - 2 x4 + 5 x3 + 4 x2 + 3 x1 = 10]
(%i2) 	eq[2]: [-2*x1 - 3*x2 + 4*x3 - 3*x4 + 5*x5 = 8];
(%o2)               [5 x5 - 3 x4 + 4 x3 - 3 x2 - 2 x1 = 8]
(%i3) 	eq[3]: [4*x1 + 2*x2 + 6*x3 - 2*x4 - 5*x5 = 6];
(%o3)              [- 5 x5 - 2 x4 + 6 x3 + 2 x2 + 4 x1 = 6]
(%i4) 	eq[4]: [6*x1 + 2*x2 + 8*x3 - x4 - x5 = 9];
(%o4)                [- x5 - x4 + 8 x3 + 2 x2 + 6 x1 = 9]
(%i5) 	eq[5]: [5*x1 + 3*x2 + 7*x3 + 9*x4 + x5 = 0];
(%o5)                [x5 + 9 x4 + 7 x3 + 3 x2 + 5 x1 = 0]
(%i6) /*	Loop for getting the augmented coeffient matrix of each equations*/	for i: 1 step 1 while i <
6 do(    		display(M[i]: augcoefmatrix (eq[i], [x1, x2, x3, x4, x5]))	);
M  = [ 3  4  5  - 2  - 4  - 10 ]
1

M  = [ - 2  - 3  4  - 3  5  - 8 ]
2

M  = [ 4  2  6  - 2  - 5  - 6 ]
3

M  = [ 6  2  8  - 1  - 1  - 9 ]
4

M  = [ 5  3  7  9  1  0 ]
5

(%o6)                                done
(%i7) /*	Combine matrices to form the main one*/	A: matrix ([M[1]], [M[2]], [M[3]], [M[4]], [M[5]]);
[ [ 3  4  5  - 2  - 4  - 10 ]  ]
[                              ]
[ [ - 2  - 3  4  - 3  5  - 8 ] ]
[                              ]
(%o7)                  [  [ 4  2  6  - 2  - 5  - 6 ]  ]
[                              ]
[  [ 6  2  8  - 1  - 1  - 9 ]  ]
[                              ]
[     [ 5  3  7  9  1  0 ]     ]
(%i8) 	B: mat_unblocker (A);
[  3    4   5  - 2  - 4  - 10 ]
[                             ]
[ - 2  - 3  4  - 3   5   - 8  ]
[                             ]
(%o8)                   [  4    2   6  - 2  - 5  - 6  ]
[                             ]
[  6    2   8  - 1  - 1  - 9  ]
[                             ]
[  5    3   7   9    1    0   ]
(%i9) /*	Compare first row elements for first pivoting*/	a: B[1][1];
(%o9)                                  3
(%i10) 	b: B[2][1];
(%o10)                                - 2
(%i11) 	c: B[3][1];
(%o11)                                 4
(%i12) 	d: B[4][1];
(%o12)                                 6
(%i13) 	e: B[5][1];
(%o13)                                 5
(%i14) 	PE: max(a,b,c,d,e);
(%o14)                                 6
(%i15) 	/*get the row number of PE*/	C : rowswap (B, 1, 4);
[  6    2   8  - 1  - 1  - 9  ]
[                             ]
[ - 2  - 3  4  - 3   5   - 8  ]
[                             ]
(%o15)                  [  4    2   6  - 2  - 5  - 6  ]
[                             ]
[  3    4   5  - 2  - 4  - 10 ]
[                             ]
[  5    3   7   9    1    0   ]
(%i16) 	display(C);
[  6    2   8  - 1  - 1  - 9  ]
[                             ]
[ - 2  - 3  4  - 3   5   - 8  ]
[                             ]
C = [  4    2   6  - 2  - 5  - 6  ]
[                             ]
[  3    4   5  - 2  - 4  - 10 ]
[                             ]
[  5    3   7   9    1    0   ]

(%o16)                               done
(%i17) 	/*normalize matrix*/	for i: 1 step 1 while i <
6 do(	C[1][i]: C[1][i]/PE	);
(%o17)                               done
(%i18) 	display(C);
[       1   4    1    1       ]
[  1    -   -  - -  - -  - 9  ]
[       3   3    6    6       ]
[                             ]
[ - 2  - 3  4  - 3   5   - 8  ]
C = [                             ]
[  4    2   6  - 2  - 5  - 6  ]
[                             ]
[  3    4   5  - 2  - 4  - 10 ]
[                             ]
[  5    3   7   9    1    0   ]

(%o18)                               done
(%i19) ```
Run Example
```eq[1]: [3*v + 4*w + 5*x - 2*y - 4*z = 10];
(%o1)                [- 4 z - 2 y + 5 x + 4 w + 3 v = 10]
(%i2) eq[2]: [-2*v - 3*w + 4*x - 3*y + 5*z = 8];
(%o2)                  [5 z - 3 y + 4 x - 3 w - 2 v = 8]
(%i3) eq[3]: [4*v + 2*w + 6*x - 2*y - 5*z = 6];
(%o3)                 [- 5 z - 2 y + 6 x + 2 w + 4 v = 6]
(%i4) eq[4]: [6*v + 2*w + 8*x - y - z = 9];
(%o4)                   [- z - y + 8 x + 2 w + 6 v = 9]
(%i5) eq[5]: [5*v + 3*w + 7*x + 9*y + z = 0];
(%o5)                   [z + 9 y + 7 x + 3 w + 5 v = 0]
(%i6) for i:1 step 1 while i<
6 do(    display(M[i]: augcoefmatrix (eq[i], [v, w, x, y, z])));
M  = [ 3  4  5  - 2  - 4  - 10 ]
1

M  = [ - 2  - 3  4  - 3  5  - 8 ]
2

M  = [ 4  2  6  - 2  - 5  - 6 ]
3

M  = [ 6  2  8  - 1  - 1  - 9 ]
4

M  = [ 5  3  7  9  1  0 ]
5

(%o6)                                done
(%i7) A: matrix ([M[1]], [M[2]], [M[3]], [M[4]], [M[5]]);
[ [ 3  4  5  - 2  - 4  - 10 ]  ]
[                              ]
[ [ - 2  - 3  4  - 3  5  - 8 ] ]
[                              ]
(%o7)                  [  [ 4  2  6  - 2  - 5  - 6 ]  ]
[                              ]
[  [ 6  2  8  - 1  - 1  - 9 ]  ]
[                              ]
[     [ 5  3  7  9  1  0 ]     ]
(%i8) B: mat_unblocker (A);
[  3    4   5  - 2  - 4  - 10 ]
[                             ]
[ - 2  - 3  4  - 3   5   - 8  ]
[                             ]
(%o8)                   [  4    2   6  - 2  - 5  - 6  ]
[                             ]
[  6    2   8  - 1  - 1  - 9  ]
[                             ]
[  5    3   7   9    1    0   ]
(%i9) a: B[1][1];
(%o9)                                  3
(%i10) b: B[2][1];
(%o10)                                - 2
(%i11) PE: max(a,b);
(%o11)                                 3
(%i12) if b >
a then C : rowswap (B, 1, 2)    else C: B;
[  3    4   5  - 2  - 4  - 10 ]
[                             ]
[ - 2  - 3  4  - 3   5   - 8  ]
[                             ]
(%o12)                  [  4    2   6  - 2  - 5  - 6  ]
[                             ]
[  6    2   8  - 1  - 1  - 9  ]
[                             ]
[  5    3   7   9    1    0   ]
(%i13) D: ptriangularize (C, z);
[ 3   4    5    - 2    - 4    - 10  ]
[                                   ]
[      1   22     13    7       44  ]
[ 0  - -   --   - --    -     - --  ]
[      3   3      3     3       3   ]
[                                   ]
[ 0   0   - 74   44    - 23    154  ]
(%o13)               [                                   ]
[                49    246      143 ]
[ 0   0    0     --    ---    - --- ]
[                37    37       37  ]
[                                   ]
[                       2399  1968  ]
[ 0   0    0     0    - ----  ----  ]
[                        49    49   ]
(%i14) for i : 1 step 1 while i <
6 do(	display(		j:D[i][1],		k:D[i][2],		l:D[i][3],		m:D[i][4],		eq[i]: (j*v + k*w + l*x + m*y + n*z = o)			)		);
j = 3

k = 4

l = 5

m = - 2

n z - 2 y + 5 x + 4 w + 3 v = o

j = 0

1
k = - -
3

22
l = --
3

13
m = - --
3

13 y   22 x   w
n z - ---- + ---- - - = o
3      3     3

j = 0

k = 0

l = - 74

m = 44

n z + 44 y - 74 x = o

j = 0

k = 0

l = 0

49
m = --
37

49 y
n z + ---- = o
37

j = 0

k = 0

l = 0

m = 0

n z = o

(%o14)                               done
(%i15) ```
Run Example
```m:matrix([1,1,1,1,0,0],[1,1,0,0,1,0],[1,0,0,0,0,1]);
[ 1  1  1  1  0  0 ]
[                  ]
(%o1)                        [ 1  1  0  0  1  0 ]
[                  ]
[ 1  0  0  0  0  1 ]
(%i2) m2:rowop(m,2,3,1);
[ 1  1  1  1  0   0  ]
[                    ]
(%o2)                       [ 0  1  0  0  1  - 1 ]
[                    ]
[ 1  0  0  0  0   1  ]
(%i3) m3:rowswap(m2,3,1);
[ 1  0  0  0  0   1  ]
[                    ]
(%o3)                       [ 0  1  0  0  1  - 1 ]
[                    ]
[ 1  1  1  1  0   0  ]
(%i4) ```

Help for Rowswap