Row operations

We revisit the previous example using algebra to express the row operations on \(A\).

A = [2 0 4 3 ; -4 5 -7 -10 ; 1 15 2 -4.5 ; -2 0 2 -13];

We use the identity and its columns heavily.

using LinearAlgebra
I4 = I(4)
4×4 Diagonal{Bool,Array{Bool,1}}:
 1  ⋅  ⋅  ⋅
 ⋅  1  ⋅  ⋅
 ⋅  ⋅  1  ⋅
 ⋅  ⋅  ⋅  1

The first step is to put a zero in the (2,1) location using a multiple of row 1:

mult21 = A[2,1]/A[1,1]
L21 = I4 - mult21*I4[:,2]*I4[:,1]'
A = L21*A
4×4 Array{Float64,2}:
  2.0   0.0  4.0    3.0
  0.0   5.0  1.0   -4.0
  1.0  15.0  2.0   -4.5
 -2.0   0.0  2.0  -13.0

We repeat the process for the (3,1) and (4,1) entries.

mult31 = A[3,1]/A[1,1];
L31 = I4 - mult31*I4[:,3]*I4[:,1]';
A = L31*A;

mult41 = A[4,1]/A[1,1];
L41 = I4 - mult41*I4[:,4]*I4[:,1]';
A = L41*A
4×4 Array{Float64,2}:
 2.0   0.0  4.0    3.0
 0.0   5.0  1.0   -4.0
 0.0  15.0  0.0   -6.0
 0.0   0.0  6.0  -10.0

And so on, following the pattern as before.