Vous êtes sur la page 1sur 4

Basic Introduction to Matrix Algebra

Rob Davies & Dirk van Seventer

We briefly review the matrix or linear algebra theory that is required in the workshop to solve linear
SAM based multiplier models. This is followed by a discussion how the theory can be applied in
Excel and an example of how this can be applied to a typical multiplier model. The associated Excel
workbook (Matrix algebra exercise.xlsx) contains some exercises, while the PowerPoint slide show
(Presentation on Intro to Matrix Algebra in XLS.pptx) has more detail.

Theory

A matrix is a rectangular array of elements

For example:

1 5 8 3 
7 3 4 2 
 

is a matrix. We can use symbols to represent matrices. Normally these are written in bold to
distinguish them from other algebraic symbols. Thus we could write

1 5 8 3 
Z 
7 3 4 2 

We refer to the dimension or size of a matrix by the number of its rows and columns. Thus Z is a 2 x
4 matrix.

We will often write the elements of a matrix in algebraic notation. To save on symbols, we can show
the elements using subscripts, where the first refers to the row of the element and the second the
column. Thus we could write Z as

z z12 z13 z14 


Z   11
 z21 z22 z23 z24 

A square matrix has the same number of rows as columns. Consider:

 a11 a12 a13 


A 3x3 matrix A   a21 a22 a23 
 a31 a32 a33 

Also consider:

 b1 
A 3x1 column vector b  b2 
b2 
A 1x3 row vector c'  c1 c2 c3 

Our general convention is that vectors are written in lower case while row vectors are written with a
prime and column vectors without a prime. So, the default is a column vector.

Transpose a matrix such as A and written as A’ by interchanging all rows and columns, i.e.,
 a11 a21 a31 
A'   a12 a22 a32 
 a13 a23 a33 

Matrix addition can only be applied to matrices of the same size. This also applies to matrix
subtraction and to element-by-element multiplication and division. Thus:

 a11 a12  b11 b12   a11  b11 a12  b12 


a   
 21 a22  b21 b22   a21  b21 a22  b22 

 a11 a12  b11 b12   a11  b11 a12  b12 


a   
 21 a22  b21 b22  a21  b21 a22  b22 

 a11 a12  b11 b12   a11 * b11 a12 * b12 


a *  
 21 a22  b21 b22  a21 * b21 a22 * b22 

 a11 a12   b11 b12   a11 / b11 a12 / b12 


a /  
 21 a22  b21 b22  a21 / b21 a22 / b22 

Multiply a matrix with a scalar by multiplying each element with the same number (scalar). For
example

 a11 a12  a * d a12 * d 


a  * d   11
 21 a22  a21 * d a22 * d 

The same applies to scalar addition, subtraction and division.

Multiply a matrix with a vector in the following way

 a11 a12   d1   a11 * d1 a12 * d1 


a *    a22 * d 2 
 21 a22   d2  a21 * d2

Again, one can do the same for addition, subtraction and division.

Matrix multiplication is not the same as multiplying matrices element-by-element as is shown in the
next example. Consider:
e e  f f12 
E   11 12  and F   11
e21 e22   f 21 f 22 

Matrix multiplication is shown with a “dot” instead of a “star”. Thus:

e f  e f e f e f 
E  F   11 11 12 21 11 12 12 22 
e21 f11  e22 f 21 e21 f12  e22 f 22 
The rule is that the number of columns of the first matrix must be equal to the number of rows of the
second matrix. If this is not the case, matrix multiplication of two matrices is not possible. This can
be shown in the following example:

g 
Consider the column vector g   1  , then: E  g is a column vector, since
 g2 
e g e g 
E  g   11 1 12 2 
e21 g2  e22 g2 
(2 rows by 2 colums) (2 rows by1column) = (2 rows by 1 column)

The inner dimensions of the two matrices to be multiplied have to be equal and then they cancel out
to get to the dimension of the results of the matrix multiplication. The resulting matrix product has
the number of rows of the first matrix and the number of columns of the second matrix (or vector).

This also means the E ∙ F = is not the same as F ∙ E and g  E above would not be possible. The
order of the matrix multiplication therefore matters.

The identity matrix is a square matrix with all elements being zero except those on the diagonal
which have the unit value. In the case of 2 rows and columns:

1 0 
I 
0 1 

If the inverse of a matrix A is A 1 then A  A 1  I (the order of the matrix multiplication does not
matter in this case). In the case of a matrix with 2 rows and columns the inverse can be calculated at:

1  a22 a12 
A1 
a11a22  a12 a21  a21 a11 

1
Where is referred as the determinant of A or det  A  . We do not discuss the
a11a22  a12 a21
derivation of larger inverses and leave it up to Excel to do the calculation. Further details can be
found in http://en.wikipedia.org/wiki/Matrix_inverse.
Excel

Element-by-element matrix manipulation can be achieved in Excel by applying the usual operators
(+, - , *, /). However, since the manipulation refer to ranges you need to perform an array
manipulation by holding down Shift and Ctrl when pressing Enter.

It is strongly recommended to use range names by entering the desired name (A or B or CC1 etc) in
the space just above the top left hand corner of the worksheet. Also find a drop down menu to select
any range names that have been defined in the workbook. Range names can be changed by going to
formulas/name manager.

In Excel there are specific functions for matrix multiplication =mmult(first matrix, second matrix)
and matrix inverse =minverse(matrix). Again, these functions have to be entered as arrays by holding
down Shift and Ctrl when pressing Enter.

Functions can be nested. For example: =mmult(first matrix, minverse(second matrix))

Note that there is a special function for identity matrices2: =munit(3) generates a 3 x 3 identity matrix

Example

A typical example of solving a SAM based multiplier model involving a matrix B of 2 rows and 2
columns, vectors x and Δf each of 2 rows and 1 column and the Identity matrix I of 2 rows and 2
columns is shown below:

x   I  B   Δf
1

1
 x1   1 0  b11 b12    f1 
 x    0 1   b b     f 
 2    21 22    2 
1
 x1  1  b11 b12   f1 
 x    b   
 2   21 1  b22   f 2 

x can be solved with the following Excel formula in a range of 2 rows and 1 column:

=mmult(minverse(I-B),df) if the identity matrix is know, otherwise


=mmult(minverse(munit(2)-B),df)

In which I is a range of 2 rows and 2 column with values as in the Identity Matrix I defined above, B
is a range of 2 rows and 2 column with values as in the Matrix B and df is a range of 2 rows and 1
column as defined in column vector Δf . For larger systems the number of rows and columns of the
relevant ranges have to be expanded in Excel but the formula stays the same.

1
C and R are reserved names in Excel so we typically use CC and RR instead.
2
Applies to Excel 2013 and 2016 for Windows and Excel 2012 for Mac.

Vous aimerez peut-être aussi