Arrays: Vectors and Matrices

**Vectors**

Vectors
are an efficient notational method for representing lists of numbers. They are equivalent to the arrays in the
programming language "C" that we learned about last week.

A
typical vector might represent the high temperature every day for a week. Such a vector would have seven elements and
could be written as a row vector (a single row),

_{}

or
as a column vector (a single column),

_{}

Note,
that I will use bold letters when referring to the entire vector (or
matrix). In both cases above, the **HighTemp** vector has seven elements,
representing Sunday through Saturday.
To access the individual elements in the array we use an index. For example, the temperature Sunday would be
accessed as HighTemp(1), and is equal to 25.
Likewise HighTemp(4)=38 is Wednesday's high temperature.

** **

**Matrices**

A
matrix (singular of matrices) is for our purposes a series of numbers listed in
two dimensions. As an example, consider
high temperatures collected over a 28 day period (4 weeks). We could write the matrix as a single list
28 elements long, or as a collection of numbers (a matrix) that has 4 rows and
7 columns.

_{}

Now
we need two indices to represent the numbers, one for the row, and one for the
column. For example the high
temperature on the 3^{rd} day of the 2^{nd} week is
HighTemp(2,3) and is equal to 45. Note
that the index for the column comes first.

We
could also write the matrix with rows and columns interchanged. This is referred to as taking the
"transpose" of the matrix.

_{}

Note
that a vector is the special case of a matrix, where there is only one row or
column. Also note that the two vectors
given are transposes of each other.

In
general a matrix consisting of m×n elements can be arranged
in m rows and n columns, yielding an *m*x*n* (read m by n) matrix, which we'll call
A.

_{}

The
symbol a_{ij} represents the number in the i^{th} row and the j^{th}
column.

**Matrix operations**

For the ensuing
discussion assume we have three matrices

** **

**Equality**

Two matrices are equal if they are
the same size, and corresponding elements are equal. For example, **A**=**B**, but **A**¹**C**.

**Addition**

Two matrices can be added if they
are the same size. Their sum is given
by a third matrix whose elements are the sum of the corresponding elements
being added.of the two arrays If **D**=**A**+**C**
then

_{}

Note that **A**+**B**=**B**+**A**.

**Multiplication by a scalar**

A matrix can be multiplied by a
scalar (a scalar is a single number) by multiplying each element of the array
by that number. For example:

_{}

**Multiplication of two
vectors**

A row vector can be multiplied by a
column vector, in that order, if and only if the have the same number of
elements. If

_{}

then

_{}

For example:

_{}

**Multiplication of two
matrices**

Two matrices, **A** and **C** can be
multiplied together in the order **AC**
if and only if the number of columns in **A
**equals the number of rows in **C**. If **D**=**AC**, then d_{ij} is the element
obtained by multiplying the row vector represented by the i^{th} row of
**A** by the column vector represented
by the j^{th} column of **C**. For arrays **A** and **C** with n columns
and rows, respectively, we get:

_{}

For
example, if **D**=**AC**, using the matrices given previously

_{}

Note that in general ** AC**¹**CA.**
In this case

_{}

_{}

**Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È****Ç****È**

**Important matrices**

**Identity Matrix**

There
is a special matrix called the identity matrix. This is a square matrix has one's along the main diagonal, and
0's elsewhere. Shown are 2x2 and 4x4
identity matrices.

_{}

The identity matrix has the special property that
for a square matrix **A**, **AI**=**IA**=**A**

** **

**Inverse Matrix**

If the matrix **A**
has an inverse **G**, we write **G**=**A**^{-1},
and **GA**=**AG**=**I**. Note that some matrices don't have inverses.

**Review - Vectors and Matrices**

For the following problems let:

_{}

1.
What
is a_{12}?

2.
What
is a_{21}?

3.
What
is **A**+**B**?

4.
What
is **UV**?

5.
What
is **AB**?

6.
What
is **AI**?

7.
What
is **IA**?

8.
What
is **VU**?

9.
What
is **BA**?

**Answers - Vectors and Matrices**

For the following problems let:

_{}

1.
What
is a_{12}?

-1

2.
What
is a_{21}?

1

3.
What
is **A**+**B**?

_{}

_{}

4.
What
is **UV**?

11

5.
What
is **AB**?

_{}

_{}

6.
What
is **AI**?

_{}

_{}

7.
What
is **IA**? (Note, in this case **IA**=**AI**, multiplication isn't generally
commutative).

_{}

_{}

8.
What
is **VU**? (Note, in this case **UV**¹**VU**,
because multiplication isn't generally commutative).

_{}

_{}

9.
What
is **BA**?

_{}