6.1 8A.

Gauss.Elimination = function(A){
  # Input A: augmented matrix. Make sure that he diagonal 
  #          elements of the coefficient matrix are non-zero! 
  A0 = A        
  n = dim(A0)[1]                # number of rows
  for(i in 1:(n-1)){            # iterator fo pivot element A0[i,i]
                                # i = 1, 2, ..., n-1
      #~~~~~~~~~~~~~~~~~~~~~   Make the function robust  ~~~~~~~~~~~~~~~~~~~~~~~~~#
      if(A0[i,i] == 0){
          non.0 = which(A0[,i] != 0)
              #cat("\n\n i =",i, ", non.0 =", non.0,". (i+1):n =", (i+1):n, ".")
              id = intersect(non.0, (i+1):n)[1] # which() equiv to find() in MATLAB
              if(!is.na(id)){
              tempi = A0[i,]                    # put the i-th row in a place-holder
              A0[i,] = A0[id,]                  # row swapping
              A0[id,] = tempi    
            }
      }
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
       if(A0[i,i] != 0){    # A0[i,i] is in the denominator of recursive equation
          for(j in (i+1):n){  # to make the augmented matrix in the row echelon form
             #cat("\n\n j =",j,".")
             A0[j,] = A0[j,] - (A0[j,i]/A0[i,i])*A0[i,]
           }
        }
      }
   A0
 }
##
A1 = matrix(c(1/2,1/4,-1/8,0,1/3,-1/6,1/9,1,1/7,1/7,1/10,2), ncol =4, byrow = TRUE)
Gauss.Elimination(A = A1)
##      [,1]       [,2]       [,3]     [,4]
## [1,]  0.5  0.2500000 -0.1250000 0.000000
## [2,]  0.0 -0.3333333  0.1944444 1.000000
## [3,]  0.0  0.0000000  0.1773810 2.214286

Now solve for x1, x2, x3 manually and x3 = 12.48 x2 = 4.28 x1 = .9799

8B.

##
A1 = matrix(c(2.71,1,1032,12,4.12,-1,500,11.49,3.33,2,-200,41), ncol =4, byrow = TRUE)
Gauss.Elimination(A = A1)
##      [,1]      [,2]      [,3]      [,4]
## [1,] 2.71  1.000000  1032.000 12.000000
## [2,] 0.00 -2.520295 -1068.945 -6.753542
## [3,] 0.00  0.000000 -1795.204 24.188009

Now solve manually for x1, x2, x3 and x3 = -.013 x2 = 8.395 x1 = 6.462

8C.

##
A1 = matrix(c(pi,(2)^(1/2),-1,1,0,exp(1),-1,1,2,1,1,1,-(3)^(1/2),1,2,-1,-1,1,-(5)^(1/2),3), ncol =5, byrow = TRUE)
Gauss.Elimination(A = A1)
##          [,1]      [,2]       [,3]       [,4]     [,5]
## [1,] 3.141593  1.414214 -1.0000000  1.0000000 0.000000
## [2,] 0.000000 -2.223657  1.8652560  1.1347440 1.000000
## [3,] 0.000000  0.000000 -0.9525206  0.9622774 2.247269
## [4,] 0.000000  0.000000  0.0000000 -1.9756173 3.272882

x4 = -1.657 x3 = -4.033 x2 = -4.678 x1 = 1.349

8D.

##
A1 = matrix(c(1,1,-1,1,-1,2,2,2,1,-1,1,4,3,1,-3,-2,3,8,4,1,-1,4,-5,16,16,-1,1,-1,-1,32), ncol =6, byrow = TRUE)
Gauss.Elimination(A = A1)
##      [,1] [,2] [,3] [,4]        [,5]     [,6]
## [1,]    1    1   -1  1.0  -1.0000000   2.0000
## [2,]    0   -2    0 -5.0   6.0000000   2.0000
## [3,]    0    0    3 -3.0   3.0000000   0.0000
## [4,]    0    0    0 10.5 -13.0000000   5.0000
## [5,]    0    0    0  0.0  -0.3809524 -37.2381

x5 = 97.75 x4 = 121.5 x3 = 23.75 x2 = -11.5 x1 = 13.5

####
Gauss.Jordan = function(A){
# A is the augmented matrix
A1 = Gauss.Elimination(A) # perform Gauss elimination
n = length(A1[,1])
id.0 = rep(1,n) # indicator of zero A[i,i]
for (i in 1:n){
if(A1[i,i] == 0) id.0[i] = 0
}
if(sum(id.0) == n){ # A[i,i] != 0
k = n
A2 = A1[k:1, c(k:1,(n+1))] # re-arrange rows and columns
A3 = Gauss.Elimination(A2) # perform Gauss elimination
A4 = A3[k:1, c(k:1,(n+1))] # backward re-arrangement
} else{ # if exists A[i,i] =0
k = which(id.0==0)[1]-1 # select rows and columns for re-arrangement
A2 = A1[c(k:1,(k+1):n), c(k:1,(k+1):(n+1))]
A3 = Gauss.Elimination(A2)
A4 = A3[c(k:1,(k+1):n), c(k:1,(k+1):(n+1))]
}
A4
}
A1 = matrix(c(pi, (2)^(1/2), -1, 1, 0,exp(1),-1,1,2,1,1,1,-(3)^(1/2),1,2,-1,-1,1,-(5)^(1/2),3), ncol = 5, byrow = TRUE)
Gauss.Jordan(A = A1)
##          [,1]      [,2]       [,3]      [,4]      [,5]
## [1,] 3.141593  0.000000  0.0000000  0.000000  4.239418
## [2,] 0.000000 -2.223657  0.0000000  0.000000 10.402239
## [3,] 0.000000  0.000000 -0.9525206  0.000000  3.841414
## [4,] 0.000000  0.000000  0.0000000 -1.975617  3.272882

x4 = -1.66 x3 = -4.03 x2 = -4.68 x1 = 1.35

6.3 1C.

# matrix multiplication in R - example
a = matrix(c(2,3,0,0,-1,2,0,2,-3), ncol=3, nrow=3)
# matrix multiplication in R - example
 b = matrix(c(2,5,1), ncol=1, nrow=3)
a%*%b
##      [,1]
## [1,]    4
## [2,]    3
## [3,]    7

3C.

# matrix multiplication in R - example
a = matrix(c(2,4,5,-3,3,2,1,0,-4), ncol=3, nrow=3)
# matrix multiplication in R - example
 b = matrix(c(0,1,2,1,0,3,-2,-1,-2), ncol=3, nrow=3)
a%*%b
##      [,1] [,2] [,3]
## [1,]   -1    5   -3
## [2,]    3    4  -11
## [3,]   -6   -7   -4

5D.

M.inv = function(A){
# Input A: Must be a square matrix
n = dim(A)[1] # number of rows
A0 = cbind(A, diag(rep(1,n)))
##
for(i in 1:(n-1)){ # iterator fo pivot element A0[i,i], i < n.
#~~~~~~~~~~~~~~~~~~~~~ Make the function robust ~~~~~~~~~~~~~~~~~~~~~~~~~#
if(A0[i,i] == 0){
non.0 = which(A0[,i] != 0)
#cat("\n\n i =",i, ", non.0 =", non.0,". (i+1):n =", (i+1):n, ".")
id = intersect(non.0, (i+1):n)[1] # which() equiv to find() in MATLAB
if(!is.na(id)){
tempi = A0[i,] # put the i-th row in a place-holder
A0[i,] = A0[id,] # row swapping
A0[id,] = tempi
}
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
if(A0[i,i] != 0){ # A0[i,i] is in the denominator of recursive equation
for(j in (i+1):n){ # to make the augmented matrix in the row echelon form
#cat("\n\n j =",j,".")
A0[j,] = A0[j,] - (A0[j,i]/A0[i,i])*A0[i,]
}
}
}
A1=A0
n = length(A1[,1])
id.0 = rep(1,n) # indicator of zero A[i,i]
for (i in 1:n){
if(A1[i,i] == 0) id.0[i] = 0
}
if(sum(id.0) == n){ # A[i,i] != 0
for (i in 1:n){
A1[i,] = A1[i,] /A1[i,i] # Divide each row by A1[i,i]
} # so that new A1[i,i] = 1.
k = n
A2 = A1[k:1, c(k:1,(n+1):(2*n))] # re-arrange rows and columns
#_______________________________________________________________##
for(i in 1:(n-1)){
if(A2[i,i] != 0){ # A0[i,i] is in the denominator of recursive equation
for(j in (i+1):n){ # to make the augmented matrix in the row echelon form
A2[j,] = A2[j,] - (A2[j,i]/A2[i,i])*A2[i,]
}
}
}
#--------------------------------------------------------------##
A4 = A2[k:1, c(k:1,(n+1):(2*n))] # backward re-arrangement
round(A4[, (n+1):(2*n)],7)
} else if(dim(A)[1] != dim(A)[2]){
cat("\n\nA square matrix is needed!")
}else {# if exists A[i,i] =0
cat("The matrix is singular")
}
}
A=matrix(c(4,0,0,0,6,7,0,0,9,11,1,0,5,4,1,1), ncol = 4, byrow = TRUE)
M.inv(A)
##            [,1]       [,2] [,3] [,4]
## [1,]  0.2500000  0.0000000    0    0
## [2,] -0.2142857  0.1428571    0    0
## [3,]  0.1071429 -1.5714286    1    0
## [4,] -0.5000000  1.0000000   -1    1

7A.

Gauss.Elimination = function(A){
  # Input A: augmented matrix. Make sure that he diagonal 
  #          elements of the coefficient matrix are non-zero! 
  A0 = A        
  n = dim(A0)[1]                # number of rows
  for(i in 1:(n-1)){            # iterator fo pivot element A0[i,i]
                                # i = 1, 2, ..., n-1
      #~~~~~~~~~~~~~~~~~~~~~   Make the function robust  ~~~~~~~~~~~~~~~~~~~~~~~~~#
      if(A0[i,i] == 0){
          non.0 = which(A0[,i] != 0)
              #cat("\n\n i =",i, ", non.0 =", non.0,". (i+1):n =", (i+1):n, ".")
              id = intersect(non.0, (i+1):n)[1] # which() equiv to find() in MATLAB
              if(!is.na(id)){
              tempi = A0[i,]                    # put the i-th row in a place-holder
              A0[i,] = A0[id,]                  # row swapping
              A0[id,] = tempi    
            }
      }
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
       if(A0[i,i] != 0){    # A0[i,i] is in the denominator of recursive equation
          for(j in (i+1):n){  # to make the augmented matrix in the row echelon form
             #cat("\n\n j =",j,".")
             A0[j,] = A0[j,] - (A0[j,i]/A0[i,i])*A0[i,]
           }
        }
      }
   A0
 }
A1 = matrix(c(1,-1,2,-1,6,1,0,-1,1,4,2,1,3,-4,-2,0,-1,1,-1,5), ncol =5, byrow = TRUE)
Gauss.Elimination(A = A1)
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1   -1    2   -1    6
## [2,]    0    1   -3    2   -2
## [3,]    0    0    8   -8   -8
## [4,]    0    0    0   -1    1

x4 = -1 x3 = -2 x2 = -6 x1 = 3

A1 = matrix(c(1,-1,2,-1,1,1,0,-1,1,1,2,1,3,-4,2,0,-1,1,-1,-1), ncol =5, byrow = TRUE)
Gauss.Elimination(A = A1)
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1   -1    2   -1    1
## [2,]    0    1   -3    2    0
## [3,]    0    0    8   -8    0
## [4,]    0    0    0   -1   -1

x4 = 1 x3 = 1 x2 = 1 x1 = 1

7B.

A=matrix(c(1,-1,2,-1,1,0,-1,1,2,1,3,-4,0,-1,1,-1), ncol = 4, byrow = TRUE)
M.inv(A)
##       [,1]   [,2]   [,3] [,4]
## [1,] 0.125  0.625  0.125    0
## [2,] 0.125 -0.375  0.125   -1
## [3,] 0.875 -0.625 -0.125   -1
## [4,] 0.750 -0.250 -0.250   -1
# matrix multiplication in R - example
a = matrix(c(1,1,2,-1), ncol=4, nrow=4)
# matrix multiplication in R - example
 b = matrix(c((1/8),(1/8),(7/8),(3/4),(5/8),(-3/8),(-5/8),(-1/4),(1/8),(1/8),(-1/8),(-1/4),0,-1,-1,-1), ncol=4, nrow=4)
b%*%a
##      [,1] [,2] [,3] [,4]
## [1,]    1    1    1    1
## [2,]    1    1    1    1
## [3,]    1    1    1    1
## [4,]    1    1    1    1

We get x1 = 1 x2 = 1 x3 = 1 x4 = 1

# matrix multiplication in R - example
a = matrix(c(6,4,-2,5), ncol=4, nrow=4)
# matrix multiplication in R - example
 b = matrix(c((1/8),(1/8),(7/8),(3/4),(5/8),(-3/8),(-5/8),(-1/4),(1/8),(1/8),(-1/8),(-1/4),0,-1,-1,-1), ncol=4, nrow=4)
b%*%a
##      [,1] [,2] [,3] [,4]
## [1,]    3    3    3    3
## [2,]   -6   -6   -6   -6
## [3,]   -2   -2   -2   -2
## [4,]   -1   -1   -1   -1

Here we get x1 = 3 x2 = -6 x3 = -2 x4 = -1

7C. The second method requires more steps.

DET = function(A){
  # Input A: Must be a square matrix
  A0 = A        
  n = dim(A0)[1]                # number of rows
  for(i in 1:(n-1)){            # iterator fo pivot element A0[i,i]
                                # i = 1, 2, ..., n-1
      #~~~~~~~~~~~~~~~~~~~~~   Make the function robust  ~~~~~~~~~~~~~~~~~~~~~~~~~#
      if(A0[i,i] == 0){
          non.0 = which(A0[,i] != 0)
              #cat("\n\n i =",i, ", non.0 =", non.0,". (i+1):n =", (i+1):n, ".")
              id = intersect(non.0, (i+1):n)[1] # which() equiv to find() in MATLAB
              if(!is.na(id)){
              tempi = A0[i,]                    # put the i-th row in a place-holder
              A0[i,] = A0[id,]                  # row swapping
              A0[id,] = tempi    
            }
      }
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
       if(A0[i,i] != 0){    # A0[i,i] is in the denominator of recursive equation
          for(j in (i+1):n){  # to make the augmented matrix in the row echelon form
             #cat("\n\n j =",j,".")
             A0[j,] = A0[j,] - (A0[j,i]/A0[i,i])*A0[i,]
           }
        }
      }
     DET = prod(diag(A0))    # prod() - vectorized multiplication, diag() extracts a[i,i]
     if(dim(A)[1] != dim(A)[2]) {
        cat("\n\nNeed a square matrix!")
      } else{
       list(Triangular.Metrix = round(A0,4), Determinant = round(DET,4))
      }
 }
A = matrix(c(1,1,-1,1,1,2,-4,-2,2,1,1,5,-1,0,-2,-4), ncol = 4, byrow = TRUE)
DET(A)
## $Triangular.Metrix
##      [,1] [,2] [,3] [,4]
## [1,]    1    1   -1    1
## [2,]    0    1   -3   -3
## [3,]    0    0    0    0
## [4,]    0    0    0    0
## 
## $Determinant
## [1] 0

6.5 1A

Gauss.Elimination = function(A){
  # Input A: an n-by-m matrix 
  n = dim(A)[1]         # number of rows
  A0 = cbind(A, diag(rep(1,n)))   # Extended augmented matrix
  #P = diag(rep(1,n))     # identity matrix for permutation
  for(i in 1:(n-1)){     # iterator fo pivot element A0[i,i]
                         # i = 1, 2, ..., n-1
      #~~~~~~~~~~~~~~~~~~~~~   Make the function robust  ~~~~~~~~~~~~~~~~~~~~~~~~~#
      if(A0[i,i] == 0){
          non.0 = which(A0[,i] != 0)     # which() equiv to find() in MATLAB
              #cat("\n\n i =",i, ", non.0 =", non.0,". (i+1):n =", (i+1):n, ".")
              id = intersect(non.0, (i+1):n)[1] # vector of common row ID in the
                                                # lower triangular part of the matrix.
              if(!is.na(id)){     # if the common vector is not empty, do row-swapping!
              tempi = A0[i,]                    # put the i-th row in a place-holder
              A0[i,] = A0[id,]                  # row swapping
              A0[id,] = tempi    
              ###                               # updating permutation matrix
              #tempP = P[i,]
              #P[i,] = P[id,]                    
              #P[id,] = tempP 
             }
       }
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
       if(A0[i,i] != 0){    # A0[i,i] is in the denominator of recursive equation
          for(j in (i+1):n){  # to make the augmented matrix in the row echelon form
             #cat("\n\n j =",j,".")
             A0[j,] = A0[j,] - (A0[j,i]/A0[i,i])*A0[i,]
           }
        }
      }
   A0 
 }
##
A1 = matrix(c(1,0,0,2,2,1,0,-1,-1,0,1,1), ncol =4, byrow = TRUE)
Gauss.Elimination(A = A1)
##      [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,]    1    0    0    2    1    0    0
## [2,]    0    1    0   -5   -2    1    0
## [3,]    0    0    1    3    1    0    1

y1 = 2 y2 = -5 y3 = 3

Now we do

##
A1 = matrix(c(2,3,-1,2,0,-2,1,-5,0,0,3,3), ncol =4, byrow = TRUE)
Gauss.Elimination(A = A1)
##      [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,]    2    3   -1    2    1    0    0
## [2,]    0   -2    1   -5    0    1    0
## [3,]    0    0    3    3    0    0    1

the solution of the system becomes x1=-3,x2=3,x3=1

7B.

##
A1 = matrix(c(1.012,-2.132,3.104,1.984,-2.132,4.096,-7.013,-5.049,3.104,-7.013,.014,-3.895), ncol =4, byrow = TRUE)
Gauss.Elimination(A = A1)
##       [,1]       [,2]       [,3]       [,4]      [,5]      [,6] [,7]
## [1,] 1.012 -2.1320000  3.1040000  1.9840000  1.000000  0.000000    0
## [2,] 0.000 -0.3955257 -0.4737431 -0.8692688  2.106719  1.000000    0
## [3,] 0.000  0.0000000 -8.9391408 -8.9391408 -5.590528 -1.197756    1

x3 = 1 x2 = 1 x1 = 1

7D.

##
A1 = matrix(c(2.1756,4.0231,-2.1732,5.1967,17.102,-4.0231,6,0,1.1973,-6.1593,-1,-5.2107,1.1111,0,3.0004,6.0235,7,0,-4.1561,0), ncol =5, byrow = TRUE)
Gauss.Elimination(A = A1)
##        [,1]         [,2]       [,3]      [,4]     [,5]      [,6]      [,7]
## [1,] 2.1756 4.023100e+00 -2.1732000  5.196700 17.10200 1.0000000 0.0000000
## [2,] 0.0000 1.343948e+01 -4.0186619 10.806991 25.46556 1.8491910 1.0000000
## [3,] 0.0000 4.440892e-16 -0.8929524  5.091694 17.23072 0.9221666 0.2501219
## [4,] 0.0000 2.376891e-15  0.0000000 12.036128 52.71598 2.7364815 1.6466670
##          [,8] [,9]
## [1,] 0.000000    0
## [2,] 0.000000    0
## [3,] 1.000000    0
## [4,] 5.352283    1

x4= 4.3798 x3= 5.6774 x2= 0.0707 x1= 2.9398

9A.

LU = function(A){
  # Input A: an n-by-m matrix 
  n = dim(A)[1]         # number of rows
  A0 = cbind(A, diag(rep(1,n)))   # Extended augmented matrix
  P = diag(rep(1,n))     # identity matrix for permutation
  for(i in 1:(n-1)){     # iterator fo pivot element A0[i,i]
                         # i = 1, 2, ..., n-1
         #~~~~~~~~~~~~~~~~~~~~~   Make the function robust  ~~~~~~~~~~~~~~~~~~~~~~~~~#
         if(A0[i,i] == 0){
            non.0 = which(A0[,i] != 0)     # which() equiv to find() in MATLAB
              #cat("\n\n i =",i, ", non.0 =", non.0,". (i+1):n =", (i+1):n, ".")
              id = intersect(non.0, (i+1):n)[1] # vector of common row ID in the
                                                # lower triangular part of the matrix.
              if(!is.na(id)){     # if the common vector is not empty, do row-swapping!
              tempi = A0[i,]                    # put the i-th row in a place-holder
              A0[i,] = A0[id,]                  # row swapping
              A0[id,] = tempi    
              ###                               # updating permutation matrix
              tempP = P[i,]
              P[i,] = P[id,]                    
              P[id,] = tempP 
            }
           }
        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
        if(A0[i,i] != 0){    # A0[i,i] is in the denominator of recursive equation
        for(j in (i+1):n){  # to make the augmented matrix in the row echelon form
             #cat("\n\n j =",j,".")
             A0[j,] = A0[j,] - (A0[j,i]/A0[i,i])*A0[i,]
           }
        }
     }
   PA = P%*%A
   U = A0[,1:n]
   L = solve(A0[, (n+1):(2*n)])
   A = A
   list(A = A, P = P, PA = PA, L = L, U = U)
 }
A=matrix(c(0,2,3,1,1,-1,0,-1,1), ncol  = 3, byrow = TRUE)
P = matrix(c(0,1,0,1,0,0,0,0,1), ncol = 3, byrow = TRUE)
LU(A)
## $A
##      [,1] [,2] [,3]
## [1,]    0    2    3
## [2,]    1    1   -1
## [3,]    0   -1    1
## 
## $P
##      [,1] [,2] [,3]
## [1,]    0    1    0
## [2,]    1    0    0
## [3,]    0    0    1
## 
## $PA
##      [,1] [,2] [,3]
## [1,]    1    1   -1
## [2,]    0    2    3
## [3,]    0   -1    1
## 
## $L
##      [,1] [,2] [,3]
## [1,]    0  1.0    0
## [2,]    1  0.0    0
## [3,]    0 -0.5    1
## 
## $U
##      [,1] [,2] [,3]
## [1,]    1    1 -1.0
## [2,]    0    2  3.0
## [3,]    0    0  2.5

P^(t)LU = [0,1,0,1,0,0,0,0,1][1,0,0,0,1,0,0,-0.5,1][1,1,-1,0,2,3,0,0,2.5] or \(P*\)L*$U from above

9D.

A=matrix(c(1,-2,3,0,1,-2,3,1,1,-2,2,-2,2,1,3,-1), ncol  = 4, byrow = TRUE)
P = matrix(c(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1), ncol = 4, byrow = TRUE)
LU(A)
## $A
##      [,1] [,2] [,3] [,4]
## [1,]    1   -2    3    0
## [2,]    1   -2    3    1
## [3,]    1   -2    2   -2
## [4,]    2    1    3   -1
## 
## $P
##      [,1] [,2] [,3] [,4]
## [1,]    1    0    0    0
## [2,]    0    0    0    1
## [3,]    0    0    1    0
## [4,]    0    1    0    0
## 
## $PA
##      [,1] [,2] [,3] [,4]
## [1,]    1   -2    3    0
## [2,]    2    1    3   -1
## [3,]    1   -2    2   -2
## [4,]    1   -2    3    1
## 
## $L
##      [,1] [,2] [,3] [,4]
## [1,]    1    0    0    0
## [2,]    1    0    0    1
## [3,]    1    0    1    0
## [4,]    2    1    0    0
## 
## $U
##      [,1] [,2] [,3] [,4]
## [1,]    1   -2    3    0
## [2,]    0    5   -3   -1
## [3,]    0    0   -1   -2
## [4,]    0    0    0    1

P^(t)LU = [1,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0][1,0,0,0,2,1,0,0,1,0,1,0,1,0,0,1][1,-2,3,0,0,5,-3,-1,0,0,-1,-2,0,0,0,1]or \(P*\)L*$U from above

8.1 12.

x <- c(.04,.041,.055,.056,.062,.071,.071,.078,.082,.09,.092,.1,.105,.12,.123,.13,.14)
y <- c(26.5,28.1,25.2,26,24,25,26.4,27.2,25.6,25,26.8,24.8,27,25,27.3,26.9,26.2)

plot(x, y)
abline(lm(y ~ x))

summary(lm(y ~ x))$coefficients
##              Estimate Std. Error    t value     Pr(>|t|)
## (Intercept) 25.921755  0.8434062 30.7346032 5.816098e-15
## x            1.600393  9.3007288  0.1720718 8.656812e-01

line of best fit is y = 1.6x + 25.92