Exercise C10

Display Variables

#Let's store information in variable
A <- matrix( 
   c(1, 4, -3, 6, 3, 0), # the data elements 
   nrow=2,              # number of rows 
   ncol=3,              # number of columns 
   byrow = TRUE)        # fill matrix by rows 

B <- matrix( 
   c(3, 2, 1, -2, -6, 5), # the data elements 
   nrow=2,              # number of rows 
   ncol=3,              # number of columns 
   byrow = TRUE)        # fill matrix by rows 
 
C <- matrix( 
   c(2, 4, 4, 0, -2, 2), # the data elements 
   nrow=3,              # number of rows 
   ncol=2,              # number of columns 
   byrow = TRUE)        # fill matrix by rows 

a = 4
b = 1/2

\[ A = \begin{bmatrix}1&4&-3 \\6&3&0 \\\end{bmatrix} , B = \begin{bmatrix}3&2&1 \\-2&-6&5 \\\end{bmatrix} , C = \begin{bmatrix}2&4 \\4&0 \\-2&2 \\\end{bmatrix}, \alpha = 4 ,and \beta = 0.5 \]

  1. A + B
Ans1 <- A + B

\[ \begin{bmatrix}1&4&-3 \\6&3&0 \\\end{bmatrix} + \begin{bmatrix}3&2&1 \\-2&-6&5 \\\end{bmatrix} = \begin{bmatrix}4&6&-2 \\4&-3&5 \\\end{bmatrix} \]

  1. A + C \[ A =\begin{bmatrix}1&4&-3 \\6&3&0 \\\end{bmatrix} , C = \begin{bmatrix}2&4 \\4&0 \\-2&2 \\\end{bmatrix} \] A and C matrixes are different dimentions so can’t add together

  2. \(B^{t} + C\) , ( \(B^{t}\) means Tranpose of B)

TB = t(B)
Ans3 <- TB + C

\[ B = \begin{bmatrix}3&2&1 \\-2&-6&5 \\\end{bmatrix}, B^{t} = \begin{bmatrix}3&-2 \\2&-6 \\1&5 \\\end{bmatrix} \] \[ \begin{bmatrix}3&-2 \\2&-6 \\1&5 \\\end{bmatrix} + \begin{bmatrix}2&4 \\4&0 \\-2&2 \\\end{bmatrix} = \begin{bmatrix}5&2 \\6&-6 \\-1&7 \\\end{bmatrix} \]

  1. \(A+B^{t}\) \[ A =\begin{bmatrix}1&4&-3 \\6&3&0 \\\end{bmatrix} , B^{t} = \begin{bmatrix}3&-2 \\2&-6 \\1&5 \\\end{bmatrix} \] \(A + B^{t}\) matrixes are different dimentions so can’t add together

  2. \(\beta C\)

Ans5 <- b*C

\[ \beta \begin{bmatrix}2&4 \\4&0 \\-2&2 \\\end{bmatrix} = \begin{bmatrix}1&2 \\2&0 \\-1&1 \\\end{bmatrix} \]

  1. \(4A-3B\)
Ans6 <- (4*A) - (3*B)

\[ 4*\begin{bmatrix}1&4&-3 \\6&3&0 \\\end{bmatrix} - 3*\begin{bmatrix}3&2&1 \\-2&-6&5 \\\end{bmatrix} = \begin{bmatrix}-5&10&-15 \\30&30&-15 \\\end{bmatrix} \]

  1. \(A^{t} + \alpha C\)
TA = t(A)
Ans7 <- TA - (a*C)

\[ A^{t} + \alpha C = \begin{bmatrix}-7&-10 \\-12&3 \\5&-8 \\\end{bmatrix} \]

  1. \(A+B-C^{t}\)
TC = t(C)
Ans8 = A + B - TC 

\[ \begin{bmatrix}1&4&-3 \\6&3&0 \\\end{bmatrix}+\begin{bmatrix}3&2&1 \\-2&-6&5 \\\end{bmatrix}- \begin{bmatrix}2&4&-2 \\4&0&2 \\\end{bmatrix} = \begin{bmatrix}2&2&0 \\0&-3&3 \\\end{bmatrix} \]

  1. \(4A + 2B - 5C^{t}\)
Ans9 = (4*A)+(2*B)-(5*TC)

\[ 4*\begin{bmatrix}1&4&-3 \\6&3&0 \\\end{bmatrix} + 2*\begin{bmatrix}3&2&1 \\-2&-6&5 \\\end{bmatrix} - 5*\begin{bmatrix}2&4&-2 \\4&0&2 \\\end{bmatrix} = \begin{bmatrix}0&0&0 \\0&0&0 \\\end{bmatrix} \]