You are on page 1of 7

A Brief Introduction to

LINEAR ALGEBRA

Economy-wide Impact Analysis Workshop


TIPS, Pretoria
7-11 Nov 2016
Convention:
Convention:
Introduction to Matrix Algebra in Excel Upper
Lower Case:
Case: Matrix
Vector (in(in Bold)
Bold)

Matrix Element
 Linear a set–of
(or Matrix) Algebra basic principal: solving Row Column
linearNaming
equations
Convention:
(1) 7x1 + 3x2= 45
• First: Rows
(2) 4x1 + 5x2 = 29 • Second: Columns
Rewrite (2) and substitute in (1): tedious for larger systems
 Express in matrix form
(3) A • x = b, where:

7 3 𝑥1 7𝑥1 + 3𝑥2 45
𝐀= , 𝐱 = 𝑥 then 𝐀 • 𝐱 = and 𝐛 =
4 5 2 4𝑥1 + 5𝑥2 29

Solution:
(4) x = A-1 • b, which involves amongst others:
• matrix multiplication
• matrix inverse
• getting number of rows and columns lined up
• getting the order of the multiplication right
Further Notational Issues
 Matrix Multiplication A • B
Dot
 # of columns in A = # rows in B
 A • B not possible if:
3 6 9
1 2 3
𝐀= 4 5 12 and 𝐁 = Star
6 7 8
9 7 1
 Matrix Multiplication ≠ Element by Element Multiplication
2 3 1 2 2 6
𝐀= and 𝐁 = ⇒𝐀∗𝐁=
2 4 3 4 6 16
1 2 2 4
𝐜=2 and 𝐁 = ⇒ 𝐜∗𝐁=
3 4 6 8
2 1 2 2 4
𝐝= and 𝐁 = ⇒𝐝∗𝐁=
1 3 4 3 4
Some Hints for Matrix Algebra in Excel

1. Excel: limited matrix algebra functions


– For A*B we can use: = A*B (normal xls notation)
– For A+B we can use: = A+B (normal xls notation)
– A•B : = mmult(A,B) Range names
– A-1 : = minverse(A)
– A-1•B : = mmult(minverse(A),B)
– A’ : = transpose(A)
2. Matrix Algebra in Excel makes use of “Arrays”
– Enter by: holding down: “Shift” & “Ctrl” simultaneous
– While: pressing the “Enter” key
Matrix Algebra Exercise in Excel
1. Name ranges (strongly recommended)
a) Use where possible: removes clutter
b) Names should make sense
1. Top left window
2. Or Formulas/Name Manager
c) Remember: Lower Case for vectors and Upper Case for the rest
2. Basic Matrix Manipulation (element by element)
a) Add / subtract / multiply / divide / power
3. Transpose (rows to columns)
4. Matrix Multiplication (can also use help!)
5. Matrix Inverse
6. Related: Nesting of functions
Introducing the Identity Matrix

• Essential for solving SUT/SAM models (shown later)


• Square matrix with
– unit values on main diagonal
– zeros values elsewhere
– Construction: new Excel function [=munit(#rows/column)]
• Use “ I ” as name
• Example
1 0 0 2 2 6 2 2 6
𝐈= 0 1 0 𝑎𝑛𝑑 𝐀 = 8 1 9 ⇒𝐈•𝐀= 8 1 9
0 0 1 7 6 5 7 6 5
Exercises in Excel

• File: “Matrix algebra exercise.xls”


• Range names to be created! (hint name @ top of suggested range)
• Complete empty coloured boxes
• Read suggestions and hints (it really helps!)
• Matrix multiplication in two ways
1. Hard way:
• Do it manual for a few cells
• With 1st cell given, now could also use $ to anchor rows & cols
2. Excel functionality
• Matrix inverse: only use xlsx formula
• Identity matrix
• Use new xlsx formula: =munit(3)  3 x 3 identity matrix
• Can also be used to create diagonal matrices using vectors as input

You might also like