%%%% Sta of "RREF-Rationals.Lisp.txt" ;; Uses a semicolon ";" to start a comment. ;; Use "::::" to indicate a new problem or section. ;; Use "%" for the Lisp prompt. :::: Reducing a Q-matrix with integer-entries :::: % (use-ring Rational-ring) ;; The matrix Q1: % Q1 [ 3 6 4 7 -6 7 8 ] [ 8 4 7 1 3 4 5 ] [ 11 10 11 8 8 -4 1 ] Reducing column-0 produces c0 c1 c2 c3 c4 c5 c6 Row operations |-----------------------------------------------------| r0 | 1 2 4/3 7/3 -2 7/3 8/3 | 1/3 0 0 r1 | 0 -12 -11/3 -53/3 19 -44/3 -49/3 | -8/3 1 0 r2 | 0 -12 -11/3 -53/3 30 -89/3 -85/3 | -11/3 0 1 |-----------------------------------------------------| Reducing column-1 produces c0 c1 c2 c3 c4 c5 c6 Row operations |-----------------------------------------------------| r0 | 1 0 13/18 -11/18 7/6 -1/9 -1/18 | -1/9 1/6 0 r1 | 0 1 11/36 53/36 -19/12 11/9 49/36 | 2/9 -1/12 0 r2 | 0 0 0 0 11 -15 -12 | -1 -1 1 |-----------------------------------------------------| Reducing column-2 produces NO change. Reducing column-3 produces NO change. Reducing column-4 produces c0 c1 c2 c3 c4 c5 c6 Row operations |-----------------------------------------------------| r0 | 1 0 13/18 -11/18 0 293/198 241/198 | -1/198 3/11 -7/66 r1 | 0 1 11/36 53/36 0 -371/396 -145/396 | 31/396 -5/22 19/132 r2 | 0 0 0 0 1 -15/11 -12/11 | -1/11 -1/11 1/11 |-----------------------------------------------------| ALL rows have pivots, so EXITing. JK: Found 3 pivots before the seventh column. c0 c1 c2 c3 c4 c5 c6 Row operations |-----------------------------------------------------| r0 | 1 0 13/18 -11/18 0 293/198 241/198 | -1/198 3/11 -7/66 r1 | 0 1 11/36 53/36 0 -371/396 -145/396 | 31/396 -5/22 19/132 r2 | 0 0 0 0 1 -15/11 -12/11 | -1/11 -1/11 1/11 |-----------------------------------------------------| ;;Verifying. We extract RREF(Q1) ... % (setq RREF-Q1 (MTB-Alt *Tab*)) [ 1 0 13/18 -11/18 0 293/198 241/198 ] [ 0 1 11/36 53/36 0 -371/396 -145/396 ] [ 0 0 0 0 1 -15/11 -12/11 ] ;; ... and the RowOp(Q1) matrix. % (setq RowOpMatrix (MTB-ROM *Tab*)) [ -1/198 3/11 -7/66 ] [ 31/396 -5/22 19/132 ] [ -1/11 -1/11 1/11 ] ;; Acting from the left (i.e, multiplying) with RowOps on Q1, is ;; supposed to give RREF(Q1). To verify, I'll subtract the latter ;; from the former, hoping to get the zero-matrix. % (mat-sub (mat-mul RowOpMatrix Q1) RREF-Q1) [ 0 0 0 0 0 0 0 ] [ 0 0 0 0 0 0 0 ] [ 0 0 0 0 0 0 0 ] ;; Yup. :::: Inverting a 4x4 Q-matrix, failure :::: % Q2 [ 19/10 892/165 -2861/66 -4036/825 ] [ -4807/3120 -11917/7605 1535243/121680 14087/5850 ] [ 1311/1040 -176/2535 19837/40560 -1691/1950 ] [ 47101/17680 -60972/14365 7772189/229840 10773/11050 ] ;; Adjoining the identity-matrix: % (setq Q2I (mat-Horiz-concat Q2 (mat-eye 4))) [ 19/10 892/165 -2861/66 -4036/825 1 0 0 0 ] [ -4807/3120 -11917/7605 1535243/121680 14087/5850 0 1 0 0 ] [ 1311/1040 -176/2535 19837/40560 -1691/1950 0 0 1 0 ] [ 47101/17680 -60972/14365 7772189/229840 10773/11050 0 0 0 1 ] % (rref-mtab-beforecol Q2I :stepwise t) Reducing column-0 produces c0 c1 c2 c3 c4 c5 c6 c7 Row operations |--------------------------------------------------------------------------------| r0 | 1 1784/627 -14305/627 -8072/3135 10/19 0 0 0 | 10/19 0 0 0 r1 | 0 14281/5070 -57124/2535 -304/195 253/312 1 0 0 | 253/312 1 0 0 r2 | 0 -203903/55770 815612/27885 5102/2145 -69/104 0 1 0 | -69/104 0 1 0 r3 | 0 -11210773/948090 44843092/474045 285682/36465 -2479/1768 0 0 1 | -2479/1768 0 0 1 |--------------------------------------------------------------------------------| Reducing column-1 produces c0 c1 c2 c3 c4 c5 c6 c7 Row operations |------------------------------------------------------------------------------| r0 | 1 0 -1/19 -1356744/1356695 -238340/814017 -3014960/2984729 0 0 | -238340/814017 -3014960/2984729 0 0 r1 | 0 1 -8 -7904/14281 16445/57124 5070/14281 0 0 | 16445/57124 5070/14281 0 0 r2 | 0 0 0 5070/14281 66677/171372 203903/157091 1 0 | 66677/171372 203903/157091 1 0 r3 | 0 0 0 313170/242777 5832307/2913324 11210773/2670547 0 1 | 5832307/2913324 11210773/2670547 0 1 |------------------------------------------------------------------------------| Reducing column-2 produces NO change. [[JK: WHOA!, our matrix Q2 does /not/ have full rank; hence, is NOT invertible. WE COULD STOP HERE, if our only goal is computing a matrix-inverse.]] Reducing column-3 produces c0 c1 c2 c3 c4 c5 c6 c7 Row operations |-----------------------------------------------------------------| r0 | 1 0 -1/19 0 14879/18525 2336612/883025 226124/80275 0 | 14879/18525 2336612/883025 226124/80275 0 r1 | 0 1 -8 0 161/180 5102/2145 304/195 0 | 161/180 5102/2145 304/195 0 r2 | 0 0 0 1 5129/4680 203903/55770 14281/5070 0 | 5129/4680 203903/55770 14281/5070 0 r3 | 0 0 0 0 10/17 -1260/2431 -803/221 1 | 10/17 -1260/2431 -803/221 1 |-----------------------------------------------------------------| Reducing column-4 produces c0 c1 c2 c3 c4 c5 c6 c7 Row operations |-------------------------------------------------------------------| r0 | 1 0 -1/19 0 0 218/65 1440889/185250 -252943/185250 | 0 218/65 1440889/185250 -252943/185250 r1 | 0 1 -8 0 0 19/6 12751/1800 -2737/1800 | 0 19/6 12751/1800 -2737/1800 r2 | 0 0 0 1 0 721/156 448639/46800 -87193/46800 | 0 721/156 448639/46800 -87193/46800 r3 | 0 0 0 0 1 -126/143 -803/130 17/10 | 1 -126/143 -803/130 17/10 |-------------------------------------------------------------------| ALL rows have pivots, so EXITing. JK: Found 4 pivots before the eighth column. :::: Inverting a 4x4 Q-matrix that DOES have an inverse :::: % (setq Q3 (mat-make-random 4 4 2)) [ -1/3 -1/3 -4 -4 ] [ 1/3 0 1/3 1 ] [ 1/3 -1 -4 2/3 ] [ -1/2 -3/2 -2 -2/3 ] % (setq Q3I (mat-Horiz-concat Q3 (mat-eye 4))) [ -1/3 -1/3 -4 -4 1 0 0 0 ] [ 1/3 0 1/3 1 0 1 0 0 ] [ 1/3 -1 -4 2/3 0 0 1 0 ] [ -1/2 -3/2 -2 -2/3 0 0 0 1 ] % (rref-mtab-beforecol Q3I ) c0 c1 c2 c3 c4 c5 c6 c7 |------------------------------------------------------------| r0 | 1 0 0 0 369/310 864/155 -138/155 51/155 | r1 | 0 1 0 0 -111/310 -396/155 102/155 -159/155 | r2 | 0 0 1 0 18/155 141/155 -129/310 39/155 | r3 | 0 0 0 1 -27/62 -36/31 27/62 -6/31 | |------------------------------------------------------------| % (setq InvQ3 (MTB-ROM *Tab* )) [ 369/310 864/155 -138/155 51/155 ] [ -111/310 -396/155 102/155 -159/155 ] [ 18/155 141/155 -129/310 39/155 ] [ -27/62 -36/31 27/62 -6/31 ] % Q3 [ -1/3 -1/3 -4 -4 ] [ 1/3 0 1/3 1 ] [ 1/3 -1 -4 2/3 ] [ -1/2 -3/2 -2 -2/3 ] % (mat-mul InvQ3 Q3) [ 1 0 0 0 ] [ 0 1 0 0 ] [ 0 0 1 0 ] [ 0 0 0 1 ] %%%% End of "RREF-Rationals.Lisp.txt"