Home page for accesible maths LAB100

Style control - access keys in brackets

Font (2 3) - + Letter spacing (4 5) - + Word spacing (6 7) - + Line spacing (8 9) - +

2 Matrix Multiplication

Matrix multiplication is performed by the operator %*%; for example, execute the command A%*%B. However, this will only work if the two matrices have matching dimensions. The dim command calculates the dimensions of a matrix, where the first number indicates the number of rows and the second indicates the number of columns:

dim( A )

dim( B )

dim( C )

dim( D )

dim( E )

Here, we see that matrix C and matrix D have a matching dimension and so we can execute the following matrix multiplication:

F <- C%*%D

F

dim( F )

When the dimensions of the matrices do not match, for example B%*%C, RStudio reports the message Error in B%*%C: non-conformable arguments.

 

Quiz 1: Matrix multiplication

For 𝐀,𝐁,𝐂,𝐃 and 𝐄 as defined by A,B,C,D and E at the start of this worksheet, find

𝐂𝐀𝐁T𝐃+𝐄𝐂𝐃

The result is

  1. (A)

    [2456123754123112]

  2. (B)

    [2456541212373112]

  3. (C)

    [3525215754563536]

  4. (D)

    [3525545621573112]

  5. (E)

    [5321265433453411]