0% found this document useful (0 votes)
17 views

Lecture4 MatrixAlgebraV2

Uploaded by

hxg285b5w2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Lecture4 MatrixAlgebraV2

Uploaded by

hxg285b5w2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

Matrix algebra

FN 211
The matrix from past to present
• Calculating yields of grain: From
Babylon to Han Dynasty

• There are three types of corn, of


which three bundles of the first,
two of the second, and one of the
third make 39 measures. Two of
the first, three of the second and
one of the third make 34
measures. And one of the first,
• Problem 1, Chapter 8 on two of the second and three of the
Rectangular Arrays in The Nine third make 26 measures. How
many measures of corn are
• Chapters on Mathematical Art, contained of one bundle of each
circa 10th-2nd century BC. type? 3x+
14 +2 = 39
2X + 34
34 +2 =
X +2
4 +3 =2 · 2
Modern applications of matrices
• Google site rankings
https://www.youtube.com/watch?v=P8Kt6Abq_rM
• Sentiment analysis from word clouds and document term matrices
• Check: https://www.wordclouds.com/

3
hai ลอ
ลไ ปลา
Sample text (put this in
104y แล้
https://www.wordclouds.com/)

นี
ใน www.

Thailand's trade-dependent economy grew at its slowest


quarterly rate in a year in the third quarter, official data
showed on Monday, leading the government to cut this
year's growth estimate once again.
Southeast Asia's second-largest economy expanded 0.1%
on a seasonally adjusted basis, the weakest rate since a
contraction in the third quarter of 2018, the National
Economic and Social Development Council said.
That met the forecast 0.1% growth in a Reuters poll, and
compared with the June quarter's revised 0.4% pace. The
economy is expected to continue its slow pace with drop in
export performance.
4
Modern applications in finance
• Big data analytics
• Optimal portfolio selections
• Financial modeling: Prediction
• Financial computing: MATLAB, R, SAS
• Text analysis for investor sentiment, etc…

5
Our class today
• Vector and matrices representations
• Vectors and matrices operations
• Matrices applications
– Solving linear equations
– Portfolio return and risks
– Financial modeling

6
REPRESENTATIONS OF
VECTORS AND MATRICES
7
Vector in R-space
• A vector is an ordered finite list of numbers
usually represented as a vertical array
surrounded by brackets as in,
  0 .5 

v   3 .0  
 4.2  31
• The vertical array above has 3 row entries
and one column. It is called a vector in 3

8
Geometric description of vectors

9
Geometric description of vectors

10
Reducing lengthy explanations
to vectors
• Denote  as a sample space of all possible
states of nature with elements (1, 2, ..m).
• A vector that lists all the possible cash flow
payoffs for project X under different scenarios
will be (X(1), X(2),…, X(m)).
• Let   (Bad, Base, Best)

11
Vector representation of cash
flow outcomes
• Project X yields three possible cash flow
outcomes:
Outcome Cash flows (THB mn)
Bad -50
Base 75
Best 120

• Vector representation: (-50, 75, 120) or


•  50
 75 
 
 120  31 12
Vector of words for text/sentiment
analysis

Document 1
No. of positive words 27
No. of negative words 3
No. of neutral words 0

13
Feature or attribute vector of a
credit card client
Feature/Attribute Quantities/Description
Gender F
Education Bachelor’s
Age 21
Monthly Salary 30,000
Monthly average spending 10,135

14
Vector of time series stock
returns
Time TFMAMA
Day 1 0.012
Day 2 -0.052
….
Day 30 0.026

15
Special vectors to help with algebra and
computational analytics
• A zero vector is a vector with all elements equal to zero. We can denote a
zero vector with n elements as 0n. Often times, the dimensions of the zero
vector is left out leaving us to figure out from the context the dimension.
• A unit vector is a vector with all elements equal to zero, except one element
which is equal to one. A unit vector with the ith element of one is denoted ei.
For example,
1  0 
e1  0 e2  1
0 0
• Transpose vector: Vector with rows and columns switched.
• For example let’s transpose vector v from slide 10

vT  v   0.5 3.0 4.213


16
Matrix
A matrix is a rectangular array of numbers written between brackets.
Below, matrix A is an m x n matrix with m rows and n columns. Each
element in the matrix is denoted as aij, where i tells what row the
number and j tells which column.

a11 , , a1n 
a 21 , , a 2 n 
A 
 
 
am1 , , amn  mn
17
Matrix representation
• A dietitian in a hospital is to arrange a special diet using three basic foods.
The diet is to include exactly 340 units of calcium, 180 units of iron, and 220
units of vitamin A. The number of units per ounce of each special ingredient
for each of the foods is indicated in the table. How many ounces of each
food must be used to meet the diet requirements

18
Recall the ancient problem of grain yields

• Can you reframe the problem on slide 2 in


a system of equations?

19
Special types of matrices
• Square matrix: A matrix with equal number of columns and rows.

 a11 a12 
A22  
a a
 21 22 
• Identity matrix: A square matrix with all elements in diag equal to
one and zero elsewhere. 1 0 0
I 3  0 1 0
0 0 1

• Inverse matrix: An inverse of matrix A or A-1 is an n x n square


matrix when multiplied with original matrix A gives an identity matrix.
AA1  A1 A  I n
• Zero matrix: A matrix with all elements equal to zero. The zero
matrix of size m × n is sometimes written as 0m×n, but usually a zero
matrix is denoted just 0,
20
VECTOR-MATRIX
OPERATIONS
21
Working with vectors
• Addition and subtraction: Possible only with same
dimensions.
1 0.7 1.7 
2  1.5   3.5
     
3  0   3 

• Scalar vector multiplication

2 / 3  2 / 6
 1 / 21 / 2     1 / 4 
2 / 5   1 / 5 

22
Working with vectors
• Inner product (dot product)

a' b  a b  a1b1  a2b2  ...anbn


T

T
 1 1 1
3 1   1 3 5 1   11  31  05  2
     
 5  0 0

23
Fun things you can do with unit vectors
0  1 
• Let’s define 0   2
   
e3  1 w   3
   
0   4
0 5

• Compute dot product of e3T  w  3

• You can select a single element from another non-empty


vector with unit vector dot products.

24
Matrix addition/subtraction

25
Multiplication by number
• The product of a number k and a matrix M, denoted by kM, is a matrix
formed by multiplying each element of M by k.

26
Example

27
28
Properties of matrix addition and scalar
multiplication

29
Transpose of a matrix
 a11 a12  a1n 
a a22  a2 n 
If A   21   M mn
     
a am 2  amn 
 m1

 a11 a21  am1 


a a22  am 2 
Then AT   12   M nm
     
a a2 n  amn 
 1n

30
Ex 8: (Find the transpose of the following
matrix)  1 2 3 0 1
 2   
(a) A    (b) A  4 5 6 (c) A  2 4
8   
7 8 9  1  1
Sol: (a)
 2
A   AT  2 8
8 
(b)  1 2 3 1 4 7 
A  4 5 6  AT  2 5 8 
   
7 8 9 3 6 9 
(c) 0 1
0 2 1 
A   2 4 A 
T

  1 4  1
 1  1 31
Properties of transposes
(1) ( AT )T  A
(2) ( A  B)T  AT  BT
(3) (cA)T  c( AT )
(4) ( AB)T  BT AT

32
Matrix multiplication
• Definition 1

33
Matrix multiplication
• Definition 2

34
Matrix product

35
Commutative law does not work in
matrix multiplication
 1 3 2  1
A  and B 
 2  1  0 2 
Sol:
 1 3 2  1 2 5
AB       
 2  1 0 2   4  4 

2  1  1 3 0 7
BA       
 0 2  2  1  4  2 

Note: AB  BA

36
The identity matrix
and inverse matrices

37
Inverse of a 2x2 matrix

38
Example Find Inverse of A
Step 1 – Calc Determinant known as det|A|
 4 8 Determinant (ad-cb) = 4x3-8x1 = 4
A   
 1 3
3 8
step2  
Step 2 – Swap Elements on leading diagonal  1 4 
 3 8
step3  
Step 3 – negate the other elements  1 4

1  3 8
step4  
Step 4 – multiply by 1/determinant 4  1 4
check
 4 8  0.75  2
1 0.75  2 AA
1
   0.25 1 
A  
1 3   

  0.25 1  
3  2
0.75  0.75
 8  8
 
1 0
0 1
 23  

39
Find the inverses and check them

 2 6 11  5  6   1.25  1.5 


A    A      
 1 5 4   1 2    0.25 0.5 

  5 20  1  2  20   0.2  2 
1
B    B      
 1 2  10  1  5   0.1  0.5 

2 2  1   1  2   0.5 1 
C    1
C      
 0  1 2 0 2   0  1

40
Inverse of n x n matrix
• Step 1: Write augmented matrix

• Step 2: Row reduction

41
-

↓ li
/

/
%

:
I

2 1 2
-

I
:


1 1 -

% inter /
- R1 + &3 · " &

2 2

% 2
( /

&3 + &2 1 = 1

Me (
2 =04 213 + % &

% -

⑧ 2 อ · :

1
& = 1 -1 3 3 3

↑"
8 1 ซ

#
-2

-
: :I g
-

-R 2 + Re # 2
⑧ 1 อ -C

I = % -2

% 0 &
-
Inverse of n x n matrix

/
42
Algebra properties of invertible matrices

43
MATRIX APPLICATIONS

44
Ways to solve linear systems
• Row reductions with augmented matrices
(Gauss Jordan elimination similar to the
ancient techniques used by Babylonians
and Chinese)
• Use a matrix inverse to multiply through
the system.
• Problems: Solutions not always exist

45
Solving system of equations with
reduced matrices (Not tested)
• How do we solve….

• Step 1: Put matrix in augmented format

สลั บแกง CROWN

• Step 2: Row operations 5 คู ณ, หา

② number

unige solutio
m
pinfinit
~ขา ให
~มี
เลย !
~
&7

%
x= +1 + M. X2 : /

• Step 3: Produce simplified forms x2 = / ล


=1 - 2

จิ ง้ snumb
·

· ·0 ° no solution
·คือม
• Forms 1, 2, and 3 above represent systems that have, respectively, a ↓ม
ตัวแปรเลย
unique solution, an infinite number of solutions, and no solution.
R
X, + M -X 2 :
ต้อแบ รท
ทา

46
Augmented matrix with no
solution (not tested)
• x+ 2y = 4
• 2x +4y = 8
1 2 4 
 
 2 4 8 
A reduced form from (-2)R1 +R2 R2 results in

1 2 4
 
 0 0 0 

47
Example: Solving equations with reduced
matrix (not tested)
• Solve

2 -6

48
Solving with linear systems with invertible Matrices (On
test: Know how to set up and solve for 2 variables)

49
No arbitrage price
• Simultaneous buying and selling of commodities, fx,
securities, or derivatives in order to take advantage of
different prices of the same assets.
• Law of one price: In frictionless markets (no transaction
costs), the same asset should trade at the same price.
• An Indian pomegranate costs THB 50, then 3
pomegranates should cost THB 150.
• What if they cost THB 151 or THB 149 in another
market?

50
Fruit bundles: Evaluate arbitrage free price
for orange and melon
• Bundle A:

• Bundle B:

A X= B
# =- A #
2 po  pm  150  2 1   p0   150 
1
 p0   2 1   150 
               
7 po  3 pm  470  7 3   pm   470   pm   7 3   470 

Solve for (po,pm) = (20, 110)


51
Conditions for unique solutions
• Matrix is invertible (Non-singular matrix)
• Matrix full rank:
• A full rank matrix is one which has
linearly independent rows or/and linearly
independent columns. If you were to find
the RREF (Row Reduced Echelon Form)
of a full rank matrix, then it would contain
all 1s in its main diagonal

52
Rank of a matrix
• The Rank of a Matrix. The number of non-zero
rows in a reduced form matrix.
• Example 1

1 2 1 2
• Example 2
3 4 1 4
④ ②

1 2 2 1
• Example 3
4 8 1 0.5
& &
53
Linear independence vs linear
dependence
• A set of vectors is linearly independent if none of them can be
written as a linear combination of the others

Ex. The set of vectors S = {[1,-1,2], [-3,3,-6]} in  is linearly


3

dependent since each of the vectors is a linear combination of the


other.
For example, [1,-1,2] = -1/3[-3,3,-6] or [-3,3,-6] = 3[1,-1,2]

A system of linear equations has to be linearly independent, otherwise


there is no unique solution

For example, can you solve x + y = 1 and 2x + 2y = 2?

1 1 1 "ไม ม ค ม 54
มี

Linear systems dependence
• Consider the linear systems
System Equations

=
1 x -2y = 2
i =5
x+y=5
A"D
idependen inde -> Unique sof A=

2 x+ 2y = -4 Moso

-1
2x +4y = 8
idependen
t

3 X + 2y = 4 &x2 = Re
!1.
2x + 4y =8
dependen
#

dep

Independent = ด
dependent = MIN'YG
55
Graph solutions
System 1 System 2
10 4
3
x + y =5 8
2
2x + 4y = 8
6 1
0
4 -4 -3 -2 -1 -1 0 1 2 3 4 5 6

2 x + 2y = -4 -2
-3
0
-4 -3 -2 -1 0 1 2 3 4 5 6 -4
-2 -5
x -2y = 2
-4 Series1 Series2

System 3
4
3.5
3
2.5
2x + 4y = 8
2
x + 2y = 4
1.5
1
0.5
0
-4 -3 -2 -1 0 1 2 3 4 5 6
-0.5
-1 56

You might also like