Chapter 5 - Determinants, Inverses, and Cramer’s Rule

Section 5.3 - Determinants Found by Triangularizing Matrices

Commands before Example 5.3.1

(U={{a,b,c},{0,d,e},{0,0,f}})//MatrixForm

Sum[(((-1))^(i+1))U[[i,1]] Det[Drop[U,{i},{1}]],{i,1,3}]

(L={{a,0,0},{b,c,0},{d,e,f}})//MatrixForm

Sum[(((-1))^(1+j))L[[1,j]] Det[Drop[L,{1},{j}]],{j,1,3}]

(T={{-7,2,1,-5,3,8},{0,4,-1,6,2,1},{0,0,9,-1,7,2},{0,0,0,-4,10,1},{0,0,0,0,6,-7},{0,0,0,0,0,11}})//MatrixForm

Product[T[[i,i]],{i,1,6}]

Det[T]

Example 5.3.1

(A={{a,b,c},{d,e,f},{g,h,i}})//MatrixForm

Det[A]

(ASwapRow1Row3={A[[3]],A[[2]],A[[1]]})//MatrixForm

Det[ASwapRow1Row3]

(ASwapRow2Row3={A[[1]],A[[3]],A[[2]]})//MatrixForm

Det[ASwapRow2Row3]

Example 5.3.2

(AMulRow2byn={A[[1]],n A[[2]],A[[3]]})//MatrixForm

Det[AMulRow2byn]

Factor[%]

Example 5.3.3

(AAddnTimesRow1ToRow2={A[[1]],A[[2]]+n A[[1]],A[[3]]})//MatrixForm

Det[AAddnTimesRow1ToRow2]

%-Det[A]

Example 5.3.4

PivotDown[m_,{i_,j_},oneflag_:0]:=Block[{k},
If[m[[i,j]]==0,Return[m]];
Return[Table[Which[k<i,m[[k]],k>i,m[[k]]-m[[k,j]]/m[[i,j]] m[[i]],k==i&&oneflag==0,m[[k]],k==1&&oneflag==1,m[[k]]/m[[i,j]]],{k,1,Length[m]}]]]

DetByGaussianElimination[mat_]:=Block[{row,column,matrix,m,n,k,t,swaps},
row=1;column=1;matrix=mat;swaps=0;
{m,n}=Dimensions[mat];
While[row<m&&column<n,
Which[matrix[[row,column]] ≠0,matrix=PivotDown[matrix,{row,column}];
row++;column++;,
matrix[[row,column]]==0,
swaps++;
If[Union[Table[matrix[[k,column]],{k,row+1,m}]]=={0},
swaps – –;column++;,t=row+Position[Map[#1≠ 0&,Table[matrix[[k,column]],{k,row+1,m}]],True][[1,1]];
matrix=Table[Which[k==row,matrix[[t]],k==t,matrix[[row]],True,matrix[[k]]],{k,1,m}]]]];
If[swaps>0,Print["There were",swaps,"row swap(s)"]];
Print[MatrixForm[matrix]];
Return[matrix]]

(A={{-9,3,0,2,-4,5,1},{6,8,-7,-1,2,10,3},{2,5,-1,-15,6,2,-4},{11,7,5,4,-8,-1,6},{-7,1,1,2,5,-3,8},{1,-12,9,0,4,-2,13},{0,-9,7,2,6,3,-4}})//MatrixForm

U=DetByGaussianElimination[A];

Det[U]

Det[A]

Example 5.3.4 continued...

(A1=PivotDown[A,{1,1}])//MatrixForm

(A2=PivotDown[A1,{2,2}])//MatrixForm

(A3=PivotDown[A2,{3,3}])//MatrixForm

(A4=PivotDown[A3,{4,4}])//MatrixForm

(A5=PivotDown[A4,{5,5}])//MatrixForm

(A6=PivotDown[A5,{6,6}])//MatrixForm

Det[A6]

Product[A6[[k,k]],{k,1,7}]

Det[A]