Sponsored links: Algebra eBooks
 

Related

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
A:matrix([2,1,0,0,0],[1,2,-1,0,0],[0,-1,2,-1,0],[0,0,-1,2,-1],[0,0,0,-1,2]);
                           [ 2   1    0    0    0  ]
                           [                       ]
                           [ 1   2   - 1   0    0  ]
                           [                       ]
(%o1)                      [ 0  - 1   2   - 1   0  ]
                           [                       ]
                           [ 0   0   - 1   2   - 1 ]
                           [                       ]
                           [ 0   0    0   - 1   2  ]
(%i2) A:rowswap(A,1,2);
                           [ 1   2   - 1   0    0  ]
                           [                       ]
                           [ 2   1    0    0    0  ]
                           [                       ]
(%o2)                      [ 0  - 1   2   - 1   0  ]
                           [                       ]
                           [ 0   0   - 1   2   - 1 ]
                           [                       ]
                           [ 0   0    0   - 1   2  ]
(%i3) A[2]:A[2]-2*A[1];
(%o3)                          [0, - 3, 2, 0, 0]
(%i4) A;
                           [ 1   2   - 1   0    0  ]
                           [                       ]
                           [ 0  - 3   2    0    0  ]
                           [                       ]
(%o4)                      [ 0  - 1   2   - 1   0  ]
                           [                       ]
                           [ 0   0   - 1   2   - 1 ]
                           [                       ]
                           [ 0   0    0   - 1   2  ]
(%i5) A[2]:A[2]*-1/3;
                                        2
(%o5)                          [0, 1, - -, 0, 0]
                                        3
(%i6) A;
                           [ 1   2   - 1   0    0  ]
                           [                       ]
                           [           2           ]
                           [ 0   1   - -   0    0  ]
                           [           3           ]
(%o6)                      [                       ]
                           [ 0  - 1   2   - 1   0  ]
                           [                       ]
                           [ 0   0   - 1   2   - 1 ]
                           [                       ]
                           [ 0   0    0   - 1   2  ]
(%i7) A[3]:A[3]+A[2];
                                      4
(%o7)                          [0, 0, -, - 1, 0]
                                      3
(%i8) A;
                            [ 1  2  - 1   0    0  ]
                            [                     ]
                            [         2           ]
                            [ 0  1  - -   0    0  ]
                            [         3           ]
                            [                     ]
(%o8)                       [        4            ]
                            [ 0  0   -   - 1   0  ]
                            [        3            ]
                            [                     ]
                            [ 0  0  - 1   2   - 1 ]
                            [                     ]
                            [ 0  0   0   - 1   2  ]
(%i9) A[3]:A[3]*3/4;
                                           3
(%o9)                          [0, 0, 1, - -, 0]
                                           4
(%i10) A;
                            [ 1  2  - 1   0    0  ]
                            [                     ]
                            [         2           ]
                            [ 0  1  - -   0    0  ]
                            [         3           ]
                            [                     ]
(%o10)                      [              3      ]
                            [ 0  0   1   - -   0  ]
                            [              4      ]
                            [                     ]
                            [ 0  0  - 1   2   - 1 ]
                            [                     ]
                            [ 0  0   0   - 1   2  ]
(%i11) A[4]:A[4]+A[3];
                                         5
(%o11)                         [0, 0, 0, -, - 1]
                                         4
(%i12) A;
                            [ 1  2  - 1   0    0  ]
                            [                     ]
                            [         2           ]
                            [ 0  1  - -   0    0  ]
                            [         3           ]
                            [                     ]
                            [              3      ]
(%o12)                      [ 0  0   1   - -   0  ]
                            [              4      ]
                            [                     ]
                            [             5       ]
                            [ 0  0   0    -   - 1 ]
                            [             4       ]
                            [                     ]
                            [ 0  0   0   - 1   2  ]
(%i13) 
Run Example
A:matrix([2,1,0,0,0],[-1,2,-1,0,0],[0,-1,2,-1,0],[0,0,-1,2,-1],[0,0,0,-1,2]);
                          [  2    1    0    0    0  ]
                          [                         ]
                          [ - 1   2   - 1   0    0  ]
                          [                         ]
(%o1)                     [  0   - 1   2   - 1   0  ]
                          [                         ]
                          [  0    0   - 1   2   - 1 ]
                          [                         ]
                          [  0    0    0   - 1   2  ]
(%i2) A:rowswap(A,1,2);
                          [ - 1   2   - 1   0    0  ]
                          [                         ]
                          [  2    1    0    0    0  ]
                          [                         ]
(%o2)                     [  0   - 1   2   - 1   0  ]
                          [                         ]
                          [  0    0   - 1   2   - 1 ]
                          [                         ]
                          [  0    0    0   - 1   2  ]
(%i3) A;
                          [ - 1   2   - 1   0    0  ]
                          [                         ]
                          [  2    1    0    0    0  ]
                          [                         ]
(%o3)                     [  0   - 1   2   - 1   0  ]
                          [                         ]
                          [  0    0   - 1   2   - 1 ]
                          [                         ]
                          [  0    0    0   - 1   2  ]
(%i4) A[1]:A[1]/-1;
(%o4)                          [1, - 2, 1, 0, 0]
(%i5) A[2]:A[2]-2*A[1];
(%o5)                          [0, 5, - 2, 0, 0]
(%i6) A[2]:A[2]/5;
                                        2
(%o6)                          [0, 1, - -, 0, 0]
                                        5
(%i7) A[3]:A[3]+A[2];
                                      8
(%o7)                          [0, 0, -, - 1, 0]
                                      5
(%i8) A;
                           [ 1  - 2   1    0    0  ]
                           [                       ]
                           [           2           ]
                           [ 0   1   - -   0    0  ]
                           [           5           ]
                           [                       ]
(%o8)                      [          8            ]
                           [ 0   0    -   - 1   0  ]
                           [          5            ]
                           [                       ]
                           [ 0   0   - 1   2   - 1 ]
                           [                       ]
                           [ 0   0    0   - 1   2  ]
(%i9) 

Related Help

Help for Rowswap