** DATA_605_Discussion_4_C20_p443_Thonn **
#install.packages("pracma")
** Problem C20 pg443 **
Referring to example MOLT, compute S(w) two different ways.
First use the definition of S, then compute the matrix product \(C_w\) (Definition MVP)
S: \[S(x) = C^3 \rightarrow C^4, S(\left[\begin{array}{rrr} x1 \\ x2 \\ x3 \end{array} \right]) = \left[\begin{array}{rrr} 3x1 - 2x2 + 5x3 \\ x1 + x2 + x3 \\ 9x1 -2x2 + 5x3 \\ 4x2 \end{array} \right]\]
Let \[w = \left[\begin{array}{rrr} -3 \\ 1 \\ 4 \end{array} \right]\]
\[S_w\]
Let \[C = \left[\begin{array}{rrr} 3 & -2 & 5\\ 1 & 1 & 1 \\ 9 & -2 & 5 \\ 0 & 4 & 0\end{array} \right]\]
Method-1: Calculate S_w_1 directly from substuting w in S(x)
Let \[S_w1 = \left[\begin{array}{rrr} 3*-3 -2*1 +5*4\\ -3 + 1 +4 \\ 9*-3 -2*1 + 5*4 \\ 4*1\end{array} \right] = \left[\begin{array}{rrr} \\ 9 \\ 2 \\ -9 \\4 \end{array} \right] \]
Method-2: compute the matrix product \(C_w\) (Definition MVP)
C <- matrix(data = c(3,-2,5, 1,1,1, 9,-2,5, 0,4,0), nrow = 4, ncol = 3, byrow = TRUE)
C
## [,1] [,2] [,3]
## [1,] 3 -2 5
## [2,] 1 1 1
## [3,] 9 -2 5
## [4,] 0 4 0
w <- matrix(data = c(-3,1,4),nrow=3,ncol=1, byrow=TRUE)
w
## [,1]
## [1,] -3
## [2,] 1
## [3,] 4
S_w_2 <- C%*%w
S_w_2
## [,1]
## [1,] 9
## [2,] 2
## [3,] -9
## [4,] 4
#Conclusion:
#S-Method-1 equals S-Method-1
END