# Vectors and matrices

This lecture provides an informal introduction to matrices and vectors.

## Matrix

A matrix is a two-dimensional array that has a fixed number of rows and columns and contains a number at the intersection of each row and column.

A matrix is usually delimited by square brackets.

Example Here is an example of a matrix having two rows and two columns:

## Dimension of a matrix

If a matrix has rows and columns, we say that it has dimension , or that it is a matrix.

Example The matrixhas rows and columns. So, we say that is a matrix.

## Entries of a matrix

The numbers contained in a matrix are called entries of the matrix (or elements, or components).

If is a matrix, the entry at the intersection of row and column is usually denoted by (or ). We say that it is the -th entry of .

Example Let be a matrix defined as follows:The element of at the intersection of the third row and the first column, that is, its -th entry is

## Vectors

If a matrix has only one row or only one column it is called a vector.

A matrix having only one row is called a row vector.

Example The matrixis a row vector because it has only one row.

A matrix having only one column is called a column vector.

Example The matrixis a column vector because it has only one column.

## Scalars

A matrix having only one row and one column is called a scalar.

Example The matrixis a scalar. In other words, a scalar is a single number.

## Equal matrices

Equality between matrices is defined in the obvious way.

Two matrices and having the same dimension are said to be equal if and only if all their corresponding elements are equal to each other:

## Zero matrices

A matrix is a zero matrix if all its elements are equal to zero, and we write

Example If is a matrix and , then

## Square matrices

A matrix is called a square matrix if the number of its rows is the same as the number of its columns, that is, .

Example The matrixis a square matrix.

Example The matrixis a square matrix.

## Diagonal and off-diagonal elements

Let be a square matrix.

The diagonal (or main diagonal of ) is the set of all entries such that .

The elements belonging to the diagonal are called diagonal elements, and all the other entries are called off-diagonal.

Example Let be the matrix defined byAll off-diagonal entries of are equal to , while the three diagonal elements are equal to , , and , respectively.

## Identity matrix

A square matrix is called an identity matrix if all its diagonal elements are equal to and all its off-diagonal elements are equal to . It is usually indicated by the letter .

Example The matrixis the identity matrix.

## Transpose of a matrix

If is a matrix, its transpose, denoted by , is the matrix such that the -th element of is equal to the -th element of for any and satisfying and .

In other words, the columns of are equal to the rows of (equivalently, the rows of are equal to the columns of ).

Example Let be the matrix defined by Its transpose is the following matrix:

Example Let be the matrix defined by Its transpose is the following matrix:

## Symmetric matrices

A square matrix is said to be symmetric if it is equal to its transpose.

Example Let be the matrix defined by Its transpose is the following matrix:which is equal to . Therefore, is symmetric.

## Solved exercises

Below you can find some exercises with explained solutions.

### Exercise 1

Let be a matrix defined by

Find its transpose.

Solution

The transpose is a matrix such that its columns are equal to the rows of :

### Exercise 2

Let be a column vector defined by

Show that its transpose is a row vector.

Solution

The transpose is a matrix such that its rows are equal to the columns of . But has only one column, which implies that has only one row. Therefore, it is a row vector:

### Exercise 3

Let be a matrix defined by

Is it symmetric?

Solution

is symmetric if it is equal to its transpose. The transpose of iswhich is not equal to . Therefore, is not symmetric.