(*^ ::[paletteColors = 128; currentKernel; fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e8, 14, "Times"; ; fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e6, 18, "Times"; ; fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, R65535, B65535, 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, 14, "Times"; ; fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 10, "Times"; ; fontset = input, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L1, 12, "Courier"; ; fontset = output, output, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier"; ; fontset = message, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = print, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = info, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, L1, 12, "Courier"; ; fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, B65535, L1, 10, "Times"; ; fontset = header, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, L1, 12, "Times"; ; fontset = Left Header, nohscroll, italic, 12, "Times"; ; fontset = footer, inactive, nohscroll, noKeepOnOnePage, preserveAspect, center, M7, italic, L1, 12, "Times"; ; fontset = Left Footer, nohscroll, italic, 12, "Times"; ; fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 10, "Times"; ; 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; next21StandardFontEncoding; ] :[font = title; inactive; dontPreserveAspect; ] Linear Algebra Commands for Linear Algebra By Dennis M. Schneider With Assistance From Robby Villegas Copyright 1990-92 by Dennis M. Schneider Work on this package partially supported by grants from Pew Charitable Trusts National Science Foundation NSF-ILI Grant # USE-9050757 NSF Grant # USE-9153249 Knox College Lilly Foundation ;[s] 21:0,0;2,1;16,2;18,3;45,4;47,5;70,6;72,7;107,8;109,9;149,10;150,11;206,12;227,13;228,14;255,15;256,16;307,17;308,18;320,19;321,20;338,-1; 21:1,12,9,Times,1,14,0,0,0;1,31,24,Times,1,36,65535,0,65535;1,12,9,Times,1,14,0,0,0;1,21,16,Times,1,24,0,0,0;1,12,9,Times,1,14,0,0,0;1,16,12,Times,1,18,0,0,0;1,12,9,Times,1,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,2,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,10,8,Times,1,12,0,0,0;1,12,9,Times,1,14,0,0,0;1,10,8,Times,1,12,0,0,0;1,12,9,Times,1,14,0,0,0;1,10,8,Times,1,12,0,0,0;1,9,7,Times,1,10,0,0,0;1,10,8,Times,1,12,0,0,0;1,12,9,Times,1,14,0,0,0;1,10,8,Times,1,12,0,0,0;1,12,9,Times,1,14,0,0,0; :[font = section; inactive; Cclosed; preserveAspect; startGroup; ] Initialization :[font = text; inactive; preserveAspect; ] This notebook contains examples for the commands contained in the package LinearAlgebra.m. That package is in the folder KnoxPackages which must be loaded in the Packages folder in the Mathematica folder. ;[s] 4:0,0;170,1;185,2;196,3;211,-1; 4:1,13,10,Times,0,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,13,10,Times,2,14,0,0,0;1,13,10,Times,0,14,0,0,0; :[font = input; initialization; preserveAspect; endGroup; ] *) Needs["KnoxPackages`LinearAlgebra`"] (* :[font = section; inactive; Cclosed; pageBreak; dontPreserveAspect; startGroup; ] Examples :[font = subsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] AppendColumn :[font = input; preserveAspect; endGroup; ] AppendColumn[{{1,2,3},{2,3,4},{4,5,6}},{{a,b,c},{d,e,f}}] :[font = subsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] AppendRow :[font = input; preserveAspect; endGroup; ] AppendRow[{{1,2,3},{2,3,4},{4,5,6}},{{a,b,c},{d,e,f}}] :[font = subsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] PivotColumns :[font = input; dontPreserveAspect; endGroup; ] PivotColumns[{{1,3,-2,1},{2,6,-2,8},{-1,-3,8,17}}] :[font = subsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] ColumnSpace :[font = input; dontPreserveAspect; endGroup; ] ColumnSpace[{{1,3,-2,1},{2,6,-2,8},{-1,-3,8,17}}] :[font = subsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] Rank :[font = input; dontPreserveAspect; endGroup; ] Rank[{{1,3,-2,1},{2,6,-2,8},{-1,-3,8,17}}] :[font = subsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] RowSpace :[font = input; dontPreserveAspect; ] RowSpace[{{1,3,-2,1},{2,6,-2,8},{-1,-3,8,17}}] :[font = input; dontPreserveAspect; endGroup; ] RowSpace[{{I,1,1,0},{1+I,0,0,1}}] :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] HilbertMatrix :[font = input; preserveAspect; ] ?HilbertMatrix :[font = input; preserveAspect; ] HilbertMatrix[5,6] :[font = input; preserveAspect; endGroup; ] HilbertMatrix[5] :[font = subsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] GramSchmidt :[font = input; preserveAspect; ] ?GramSchmidt :[font = input; preserveAspect; ] ?NDot :[font = input; dontPreserveAspect; ] GramSchmidt[{{-1,0,1},{-1,1,0}}] :[font = input; dontPreserveAspect; ] GramSchmidt[{{-1,0,1},{-1,1,0}},Normalized->True] :[font = input; preserveAspect; ] GramSchmidt[{{-1,0,1},{-1,1,0}},InnerProduct->NDot,Normalized->True] :[font = input; preserveAspect; ] GramSchmidt[{{-1,0,1},{-1,Pi,0}},InnerProduct->NDot] :[font = input; preserveAspect; ] GramSchmidt[{{a,b},{c,d}}] :[font = input; preserveAspect; ] hilbertmat10 = HilbertMatrix[10]; :[font = input; preserveAspect; ] GramSchmidt[hilbertmat10,InnerProduct->NDot] :[font = input; preserveAspect; ] Length[%] :[font = input; preserveAspect; ] GramSchmidt[hilbertmat10,InnerProduct->NDot,Tolerance->10^-6] :[font = input; preserveAspect; ] Length[%] :[font = input; preserveAspect; ] GramSchmidt[{1,x,x^2},InnerProduct->FunctionDot[{x,0,1}],Normalized->True] :[font = input; preserveAspect; ] GramSchmidt[{1,x,x^2},InnerProduct->NFunctionDot[{x,0,1}],Normalized->True] :[font = input; preserveAspect; ] GramSchmidt[{Sin[x] Cos[x],Sin[2x],x},InnerProduct->FunctionDot[{x,0,1}]] :[font = input; preserveAspect; ] GramSchmidt[{Sin[x] Cos[x],Sin[2x],x},InnerProduct->NFunctionDot[{x,0,1}]] :[font = input; preserveAspect; endGroup; ] GramSchmidt[{{0,0,0}}] :[font = subsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] Project :[font = input; dontPreserveAspect; endGroup; ] Project[{-1,-1,1,1},{{1,0,1,1},{0,1,1,2},{2,-2,0,-2}}] :[font = subsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] Projection Matrix :[font = input; dontPreserveAspect; endGroup; ] ProjectionMatrix[{{1,0,1,1},{0,1,1,2},{2,-2,0,-2}}] :[font = subsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] LeastSquaresSoln :[font = input; dontPreserveAspect; ] LeastSquaresSoln[{{1,0,2},{0,1,-2},{1,1,0},{1,2,-2}}, {-1,-1,1,1}] :[font = input; preserveAspect; ] LeastSquaresSoln[{{1,-1},{2,1},{3,2}}, {-3,0,6}] :[font = text; inactive; preserveAspect; ] The optimal least-squares solution can be found using Mathematica's PseudoInverse command. It will agree with LeastSquaresSoln when the matrix has maximal rank. ;[s] 7:0,0;54,1;65,2;68,3;81,4;111,5;127,6;162,-1; 7:1,13,10,Times,0,14,0,0,0;1,13,10,Times,2,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,10,8,Courier,1,12,0,0,0;1,13,10,Times,0,14,0,0,0;1,10,8,Courier,1,12,0,0,0;1,13,10,Times,0,14,0,0,0; :[font = input; preserveAspect; ] PseudoInverse[{{1,0,2},{0,1,-2},{1,1,0},{1,2,-2}}].{-1,-1,1,1} :[font = input; preserveAspect; endGroup; ] PseudoInverse[{{1,-1},{2,1},{3,2}}].{-3,0,6} :[font = subsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] DiagQuad :[font = input; dontPreserveAspect; ] DiagQuad[x^2 + x y + y^2,{x,y},{u,v}] :[font = input; dontPreserveAspect; ] DiagQuad[x y + y z + x z,{x,y,z},{u,v,w}] :[font = input; dontPreserveAspect; ] DiagQuad[x y + y z + x z,{x,y,z},{u,v,w}] :[font = text; inactive; dontPreserveAspect; ] Diagonalizing the quadratic using numerical coefficients leads to a different ordering of the eigenvalues and a different bases of eigenvectors. :[font = input; dontPreserveAspect; ] NDiagQuad[x y + y z + x z,{x,y,z},{u,v,w}] :[font = input; dontPreserveAspect; ] DiagQuad[x^2 + x y + y z + x z,{x,y,z},{u,v,w}] :[font = input; dontPreserveAspect; endGroup; ] NDiagQuad[x^2 + x y + y z + x z,{x,y,z},{u,v,w}] :[font = subsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] CompleteSquare :[font = input; preserveAspect; ] CompleteSquare[x^2 + x + 2y^2 + 7y - 14,{x}] :[font = input; preserveAspect; ] CompleteSquare[x^2 + x + 2y^2 + 7y - 14,{y}] :[font = input; dontPreserveAspect; ] CompleteSquare[x^2 + x + 2y^2 + 7y - 14,{x,y}] :[font = input; preserveAspect; ] CompleteSquare[(a + c)^3 x^2 + b x + 2Pi y^2 + 7y - 14 + z^3 + (x + z)^4,{x,y}] :[font = input; preserveAspect; ] CompleteSquare[(a + b)^2 x^2 + c x + (d + x)^2 + (y + c + d)^2 + y,{x,y}] :[font = input; preserveAspect; endGroup; ] CompleteSquare[Exp[x^2] + c x,{x}] :[font = subsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] Random Vectors and Matrices of Various Types :[font = subsubsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] RandomVector :[font = input; dontPreserveAspect; ] RandomVector[4] :[font = input; dontPreserveAspect; endGroup; ] RandomVector[4,Integer,{-2,4}] :[font = subsubsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] RandomMatrix :[font = input; dontPreserveAspect; ] RandomMatrix[3] :[font = input; dontPreserveAspect; ] RandomMatrix[3,Integer,{-4,10}] :[font = input; dontPreserveAspect; endGroup; ] RandomMatrix[3,Integer,{-4,1},MatRank->2] :[font = subsubsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] RandomSymmetricMatrix :[font = input; dontPreserveAspect; ] RandomSymmetricMatrix[3] :[font = input; dontPreserveAspect; endGroup; ] RandomSymmetricMatrix[3, Integer, {-3,6}] :[font = subsubsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] RandomTriangularMatrix :[font = input; dontPreserveAspect; ] RandomTriangularMatrix[5] :[font = input; dontPreserveAspect; endGroup; ] RandomTriangularMatrix[5,Integer,{-2,12}] :[font = subsubsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] RandomOrthogonalMatrix :[font = input; dontPreserveAspect; ] RandomOrthogonalMatrix[3] :[font = input; dontPreserveAspect; endGroup; ] RandomOrthogonalMatrix[3,Integer,{-2,5}] :[font = subsubsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] RandomPermutationMatrix :[font = input; dontPreserveAspect; endGroup; ] RandomPermutationMatrix[5] :[font = subsubsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] RandomNonsingularMatrix :[font = input; dontPreserveAspect; ] RandomNonsingularMatrix[3] :[font = input; dontPreserveAspect; endGroup; ] RandomNonsingularMatrix[3, Integer, {-3,3}] :[font = subsubsection; inactive; Cclosed; dontPreserveAspect; startGroup; ] RandomSingularMatrix :[font = input; preserveAspect; endGroup; endGroup; endGroup; ] RandomSingularMatrix[3,Integer,{0,2}] ^*)