(*^ ::[ Information = "This is a Mathematica Notebook file. It contains ASCII text, and can be transferred by email, ftp, or other text-file transfer utility. It should be read or edited using a copy of Mathematica or MathReader. If you received this as email, use your mail application or copy/paste to save everything from the line containing (*^ down to the line containing ^*) into a plain text file. On some systems you may have to give the file a name ending with ".ma" to allow Mathematica to recognize it as a Notebook. The line below identifies what version of Mathematica created this file, but it can be opened using any other version as well."; FrontEndVersion = "NeXT Mathematica Notebook Front End Version 2.2"; NeXTStandardFontEncoding; fontset = title, inactive, noPageBreakBelow, noPageBreakInGroup, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e8, 24, "Times"; ; fontset = subtitle, inactive, noPageBreakBelow, noPageBreakInGroup, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e6, 18, "Times"; ; fontset = subsubtitle, inactive, noPageBreakBelow, noPageBreakInGroup, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, L1, e6, 14, "Times"; ; fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, L1, a20, 18, "Times"; ; fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, L1, a15, 14, "Times"; ; fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, L1, a12, 12, "Times"; ; fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 10, "Times"; ; fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L1, 12, "Courier"; ; fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier"; ; fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, L1, 12, "Courier"; ; fontset = name, inactive, noPageBreakInGroup, nohscroll, preserveAspect, M7, italic, B65535, L1, 10, "Times"; ; fontset = header, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, L1, 12, "Times"; ; fontset = leftheader, 12; fontset = footer, inactive, nohscroll, noKeepOnOnePage, preserveAspect, center, M7, italic, L1, 12, "Times"; ; fontset = leftfooter, 12; fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12, "Courier"; ; fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; paletteColors = 128; currentKernel; ] :[font = title; inactive; Cclosed; preserveAspect; startGroup] Row Operations and Elementary Matrices :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Row Operations and Elementary Matrices :[font = text; inactive; preserveAspect] Suppose we are given a matrix A, such as: :[font = input; preserveAspect] a = {{1,2,7},{-1,0,3},{2,1,1}} :[font = text; inactive; preserveAspect; endGroup] We would like to know if A possesses certain properties, one immediate example being whether we can solve A . x = b for any vector b. If we let the vector b = (1,0,0), then the requirement A . x = b breaks down into three (linear) equations: x1 + 2 x2 + 7 x3 = 1 - x1 + 3 x3 = 0 2 x1 + x2 + x3 = 0 From algebra class we know we can manipulate these equations in certain ways and still keep the same set of solutions. For example, we can add the first equation to the second and subtract twice the first equation from the third. Then we get : x1 + 2 x2 + 7 x3 = 1 2 x2 + 10 x3 = 1 -3 x2 - 13 x3 = -2 And now we could convert this system back into matrix form. But dealing with variables and equations seems unnecessarily messy. What we need are methods of manipulating the matrix itself while keeping its properties intact. To do this, we need to think of the rows of the matrix as individual entities, which we can add (component by component), for example. Now, in the case of linear systems, the following ªequation operationsº do not affect the solution set : (1) Adding a multiple of one equation to another (2) Exchanging two equations (3) Multiplying an equation on both sides by a nonzero constant We can certainly do more, but it turns out that this set of operations is quite useful and sufficient for our purposes. To show how these operations apply to matrices, it turns out that the following is true: FACT: (1) Let Ei,j (a) (with i ¹ j) be the matrix defined by ì 1, if k = l (Ei,j(a)) k,l = í a, if k = i and l = j î 0, otherwise. Then for any compatible matrix A, B = Ei,j(a) . A is a matrix the same as A except the ith row of B is the ith row of A plus a times the jth row of A. (2) Let Ei,j (i ¹ j) be the matrix defined by ì 1, if k = l and k Ï {i,j} (Ei,j)k,l = í 1, if {k,l} = {i,j} (set-wise equality) î 0, otherwise. Then the matrix Ei,j . A is equal to A, except the ith and jth rows of A have been exchanged. (3) Let Ei(a) (a ¹ 0) be defined by ì 1, if k = l and k ¹ i (Ei(a))k,l = í a, if k = l = i î 0, if k ¹ l. Then the matrix Ei(a) . A is the same as A, except the ith row has been multiplied by a. The matrices E* defined in the above fact are called elementary matrices and their role in Matrix Theory is important. If the matrix Aaug = [A ½ b] represents the equation A . x = b, then multiplying Aaug on the left by elementary matrices does not affect the solution of this system, but at the same time it can make the form of Aaug simpler. ;[s] 135:0,0;264,1;265,2;271,3;272,4;278,5;279,6;298,7;299,8;316,9;317,10;336,11;337,12;343,13;344,14;351,15;352,16;625,17;626,18;632,19;634,20;642,21;643,22;675,23;676,24;684,25;685,26;717,27;718,28;727,29;728,30;1605,31;1608,32;1610,33;1611,34;1621,35;1622,36;1691,37;1692,38;1724,39;1727,40;1728,41;1729,42;1732,43;1735,44;1739,45;1740,46;1741,47;1742,48;1805,49;1806,50;1880,51;1883,52;1884,53;1885,54;1957,55;1958,56;1977,57;1978,58;1995,59;1996,60;2007,61;2008,62;2032,63;2035,64;2040,65;2041,66;2110,67;2111,68;2132,69;2133,70;2158,71;2161,72;2162,73;2165,74;2170,75;2173,76;2214,77;2218,78;2254,79;2255,80;2308,81;2311,82;2342,83;2343,84;2350,85;2351,86;2423,87;2424,88;2425,89;2426,90;2430,91;2431,92;2432,93;2433,94;2489,95;2490,96;2509,97;2510,98;2531,99;2532,100;2533,101;2534,102;2536,103;2539,104;2544,105;2545,106;2546,107;2547,108;2600,109;2601,110;2610,111;2611,112;2663,113;2664,114;2665,115;2666,116;2701,117;2702,118;2757,119;2758,120;2793,121;2794,122;2795,123;2796,124;2834,125;2853,126;2916,127;2919,128;2925,129;2926,130;2985,131;2988,132;3115,133;3118,134;3133,-1; 135:1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = subsection; inactive; Cclosed; preserveAspect; startGroup] Elementary Matrices in Mathematica ;[s] 2:0,0;23,1;34,-1; 2:1,12,9,Times,1,14,0,0,0;1,13,10,Times,3,14,0,0,0; :[font = text; inactive; preserveAspect] When performing row operations, often the matrices involved can be complicated and computational error unavoidable. To this end, a program has been written in Mathematica to simulate these matrices. Click in the next cell and press the key marked Enter to load in this program. ;[s] 3:0,0;160,1;171,2;289,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect] << ElementaryMatrices.ma :[font = text; inactive; preserveAspect] Because Mathematica does not have subscripts, certain notational liberties have been made: Ei,j(a) . A º EM [i,j,a, A] Ei,j . A º EM [{i,j},A] Ei(a) . A º EM [i,a,A] Note particularly the braces ({}) in Ei,j to distinguish it from Ei(a), purely for the machine's sake. Now let's do some row operations on the following matrix. ( Click in the cells and press enter to activate them.) ;[s] 28:0,0;8,1;19,2;123,3;126,4;127,5;128,6;135,7;136,8;146,9;147,10;190,11;198,12;199,13;249,14;250,15;251,16;252,17;258,18;259,19;267,20;268,21;310,22;313,23;338,24;339,25;340,26;341,27;514,-1; 28:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,0,0,Symbol,0,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,0,0,Symbol,64,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,0,0,Symbol,64,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,0,0,Symbol,64,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,0,0,Symbol,64,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,0,0,Symbol,64,12,0,0,0;1,11,8,Times,64,12,0,0,0; :[font = input; preserveAspect] a = {{1,1,1},{1,0,1},{1,0,0}} :[font = input; preserveAspect] MatrixForm[a] :[font = input; preserveAspect] EM [1,3,5,a]; :[font = text; inactive; preserveAspect] Note two things at this point : first, the semicolon at the end of the command, which keeps the result from being printed in ªmachine formº -- the program prints the result of the operation if it is legal -- and second, that EM [1,3,5,A] really means E1,3(5) . A. A simple computation shows this is what was expected. Now let's do some more row operations from this matrix; the symbol % means to use the last output as input, even though we could have saved the previous result as another matrixwith a command like b = EM [1,3,5,a]. ;[s] 5:0,0;257,1;260,2;523,3;539,4;541,-1; 5:1,11,8,Times,0,12,0,0,0;1,11,8,Times,64,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,1,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect] EM [{1,3},%]; :[font = text; inactive; preserveAspect] We see we have swapped the first and third rows of our new matrix. What happens if we try to swap a row, such as the fifth, which isn't there? Let's try it ... :[font = input; preserveAspect] EM [{1,5},%]; :[font = text; inactive; preserveAspect] Aha! The programmer saw ahead to people possibly mis-using this routine (this phenomenon is called -- perhaps inappropriately -- the ª idiot testº) and lets us know that something is wrong. The routine saw that our matrix has three rows and so we couldn't possibly have a fifth row. So we don't need to tell how big our matrix is; Mathematica takes care of it for us. Another feature of the program is that if we do get a message like this, we can still use the % to mean ª the last matrix printedº, so that we don't have to re-work everything if we just happen to make a typo. Now let's multiply the first row by 5: ;[s] 3:0,0;341,1;352,2;877,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect] EM [1,5,%]; :[font = text; inactive; preserveAspect] This brings up an important point : the last two commands were almost alike, so we must be careful at times like this. And if we try to multiply a row by zero, we get : :[font = input; preserveAspect] EM [2,0,%]; :[font = text; inactive; preserveAspect; endGroup; endGroup] ... and the program tells us simply that we're trying to do something wrong. ^*)