# 6.2 - Operations with Matrices

## Equality

Two matrices are equal if and only if

• The order of the matrices are the same
• The corresponding elements of the matrices are the same

• Order of the matrices must be the same

## Subtraction

• The order of the matrices must be the same
• Subtract corresponding elements
• Matrix subtraction is not commutative (neither is subtraction of real numbers)
• Matrix subtraction is not associative (neither is subtraction of real numbers)

## Scalar Multiplication

A scalar is a number, not a matrix.

• The matrix can be any order
• Multiply all elements in the matrix by the scalar
• Scalar multiplication is commutative
• Scalar multiplication is associative

## Zero Matrix

• Matrix of any order
• Consists of all zeros
• Denoted by capital O
• Any matrix plus the zero matrix is the original matrix

## Matrix Multiplication

Am×n × Bn×p = Cm×p

• The number of columns in the first matrix must be equal to the number of rows in the second matrix. That is, the inner dimensions must be the same.
• The order of the product is the number of rows in the first matrix by the number of columns in the second matrix. That is, the dimensions of the product are the outer dimensions.
• Since the number of columns in the first matrix is equal to the number of rows in the second matrix, you can pair up entries.
• Each element in row i from the first matrix is paired up with an element in column j from the second matrix.
• The element in row i, column j, of the product is formed by multiplying these paired elements and summing them.
• Each element in the product is the sum of the products of the elements from row i of the first matrix and column j of the second matrix.
• There will be n products which are summed for each element in the product.

See a complete example of matrix multiplication.

### Matrix multiplication is not commutative

• Multiplication of real numbers is.
• The inner dimensions may not agree if the order of the matrices is changed.

### Do not simply multiply corresponding elements together

• Since the order (dimensions) of the matrices don't have to be the same, there may not be corresponding elements to multiply together.
• Multiply the rows of the first by the columns of the second and add.

### There is no matrix division

• There is no defined process for dividing a matrix by another matrix.
• A matrix may be divided by a scalar.

## Identity Matrix

• Square matrix
• Ones on the main diagonal
• Zeros everywhere else
• Denoted by I. If a subscript is included, it is the order of the identity matrix.
• I is the multiplicative identity for matrices
• Any matrix times the identity matrix is the original matrix.
• Multiplication by the identity matrix is commutative, although the order of the identity may change

Identity matrix of size 2

 I2 = 1 0 0 1

Identity matrix of size 3

 I3 = 1 0 0 0 1 0 0 0 1

## Properties of Matrices

Property Example
Commutativity of Addition A + B = B + A
Associativity of Addition A + ( B + C ) = ( A + B ) + C
Associativity of Scalar Multiplication (cd) A = c (dA)
Scalar Identity 1A = A(1) = A
Distributive c (A + B) = cA + cB
Distributive (c + d) A = cA + dA
Additive Identity A + O = O + A = A
Associativity of Multiplication A (BC) = (AB) C
Left Distributive A (B + C) = AB + AC
Right Distributive ( A + B ) C = AC + BC
Scalar Associativity / Commutativity c (AB) = (cA) B = A (cB) = (AB) c
Multiplicative Identity IA = AI = A

## Properties of Real Numbers that aren't Properties of Matrices

### Commutativity of Multiplication

• You can not change the order of a multiplication problem and expect to get the same product. AB≠BA
• You must be careful when factoring common factors to make sure they are on the same side. AX+BX = (A+B)X and XA + XB = X(A+B) but AX + XB doesn't factor.

### Zero Product Property

• Just because a product of two matrices is the zero matrix does not mean that one of them was the zero matrix.

### Multiplicative Property of Equality

• If A=B, then AC = BC. This property is still true, but the converse is not necessarily true. Just because AC = BC does not mean that A = B.
• Because matrix multiplication is not commutative, you must be careful to either pre-multiply or post-multiply on both sides of the equation. That is, if A=B, then AC = BC or CA = CB, but AC≠CB.

### There is no matrix division

• You must multiply by the inverse of the matrix

## Evaluating a Function using a Matrix

Consider the function f(x) = x2 - 4x + 3 and the matrix A

 A = 1 2 3 4

The initial attempt to evaluate the f(A) would be to replace every x with an A to get f(A) = A2 - 4A + 3. There is one slight problem, however. The constant 3 is not a matrix, and you can't add matrices and scalars together. So, we multiply the constant by the Identity matrix.

f(A) = A2 - 4A + 3I.

Evaluate each term in the function and then add them together.

 A2 = 1 2 * 1 2 = 7 10 3 4 3 4 15 22
 -4 A = -4 1 2 = -4 -8 3 4 -12 -16
 3I = 3 1 0 = 3 0 0 1 0 3
 f(A) = 7 10 + -4 -8 + 3 0 = 6 2 15 22 -12 -16 0 3 3 9

## Factoring Expressions

Some examples of factoring are shown. Simplify and solve like normal, but remember that matrix multiplication is not commutative and there is no matrix division.

2X + 3X = 5X

AX + BX = (A+B)X

XA + XB = X(A+B)

AX + 5X = (A+5I)X

AX+XB does not factor

## Solving Equations

A system of linear equations can be written as AX=B where A is the coefficient matrix, X is a column vector containing the variables, and B is the right hand side. We'll learn how to solve this equation in the next section.

If there are more than one system of linear equations with the same coefficient matrix, then you can expand the B matrix to have more than one column. Put each right hand side into its own column.

## Matrix Multiplication

Matrix multiplication involves summing a product. It is appropriate where you need to multiply things together and then add. As an example, multiplying the number of units by the per unit cost will give the total cost.

The units on the product are found by performing unit analysis on the matrices. The labels for the product are the labels of the rows of the first matrix and the labels of the columns of the second matrix.