Sunteți pe pagina 1din 37

Matrix

TOPIC 3
https://www.coursera.org/lecture/machine-
learning/matrices-and-vectors-38jIT
Objectives of the Topic
2

 To Compute Determinant of Matrix


 To Compute summation, product and inverse of a
matrix
 Applications in Simultaneous Equations
 Applications of Human Resource Planning
 Applications in Input-Output Analysis
Topics
3

 Addition of Matrix
 Product of Matrix
 Inverse of Matrix
 Application in Simultaneous Linear Equation, Brand
Switching, HRP, Input-Output Analysis
Definition
4

 An m × n matrix A is a rectangular array of real


numbers with m rows and n columns. We refer to
m and n as the dimensions of the matrix. The
numbers that appear in the matrix are called its
entries. We customarily use capital letters A, B,
C, . . . for the names of matrices.

2 3 1
 
  

5 4 2

 This is a 2 × 3 matrix because it has 2 rows and 3
columns.
Some types of Matrix
5

 A matrix with a single row is called a row matrix,


or row vector.
 A matrix with a single column is called a column
matrix or column vector.
 A matrix with the same number of rows as
columns is called a square matrix.
Determinant of a matrix
6

a11 a12
 a11  a22  a12  a21
a21 a22
a11 a12 a13
a21 a22 a23
a31 a32 a33
a22 a23 a21 a23 a21 a22
 a11   a12   a13 
a32 a33 a31 a33 a31 a32
Determinant
7

0.5 0.4 0.1


0.2 0.7 0.1
0.1 0.2 0.7
 0.5(0.7  0.7  0.1 0.2)  0.4(0.2  0.7  0.1 0.1)  .1(0.2  0.2  0.7  0.1)
 0.18
Properties of determinant
8
Problem 2
9
 Without expansion solve the following
5 1 2 x 1 2 2 3 8 4 6 7
(i) x 4 8  0, ii   4  6 7   2 4 3   4  5  5
7 6 9
 Prove 2 3 8 4 6 7 2 3 8

p  q q  r r  p p q r
(i ) q  r r  p p  q  2 q r p,
r  p p  q q  r r p q
1 1 1 x y z
ii  x y z  x2 y2 z2
yz zx xy 1 1 1
Addition of Two Matrix
10

 Matrix Addition and Subtraction


 Two matrices can be added (or subtracted) if and only if they have the
same dimensions. To add (or subtract) two matrices of the same
dimensions, we add (or subtract) the corresponding entries. More
formally, if A and B are m × n matrices, then A + B and A − B are the
m × n matrices whose entries are given by:
 (A + B)i j = Ai j + Bi j
 (A − B)i j = Ai j − Bi j
 Visualizing Matrix Addition

2  3  1 1  3  2
1 0    2 1   1 1 
     
Scalar Multiplication
11

 To multiply a number of to a matrix multiply every


element by scalar quantity
 Example: Let
2  1 0  1 3  1 x y w
A  , B   , C   
     
3 5  3 5  6 0   z t  1 3 

 Evaluate the following: 4A, xB, and A + 3C.

8 4 0  x 3x  x  2  3x  1  3 y 3w
4 A   , xB  
 
, A  3C  
 


12 20  12 5 x  6 x 0  3  3z 3t  8 6 
Properties of Matrix Addition
12

 If A, B, and C are any m × n matrices and if O is the zero


m × n matrix, then the following
 hold:
 A + (B + C) = (A + B) + C Associative law
 A+B=B+A Commutative law
 A+O=O+A=A Additive identity law
 A + (−A) = O = (−A) + A Additive inverse law
 c(A + B) = cA + cB Distributive law
 (c + d)A = cA + dA Distributive law
 IA = A
 OA = O
Transposition

13

 If A is an m × n matrix, then its transpose is the n


× m matrix obtained by writing its rows as
columns, so that the ith row of the original matrix
becomes the ith column of the transpose. We denote
the transpose of the matrix A by AT.

 2 1 5
2  3  
1 1  
   3 1 0
5 0 
Product of Two Matrix
14
 The product AB of a row  The Product of Two
matrix A and a column Matrices: General Case
matrix B is a 1 × 1  In general for matrices A
matrix. The length of the and B, we can take the
row in A must match the product AB only if the
length of the column in B for
the product to be defined. To  number of columns of A
find the product, multiply equals the number of rows
of B (so that we can multiply
each entry in A (going from the rows of A by thecolumns
left to right) by the of B as above).
corresponding entry in B  The product AB is then
(going from top to bottom) obtained by taking its i jth
and then add the results. entry to be:
 i jth entry of AB = Row i of
A × Column j of B
Multipication Example
15

 The A-Plus auto parts store had the following sales in its
Vancouver store:
Vancouver
Wiper 20
blades
Cleaning 10
Fluid Bottle
Floormat 8
 The store sells wiper blades for $7.00 each, cleaning fluid
for $3.00 per bottle, and floor mats for $12.00 each. Use
matrix multiplication to find the total revenue generated
by sales of these items.
 Ans 266
Application of Product of Matrix
16

 A manufacturer produces three products A, B and C which he sells in the


market. Annual sale estimates (in unit) are indicated as follows:

Products
Markets A B C
I 8000 10000 15000
II 10000 2000 20000

 If unit sale prices of A, B and C are Rs 2.25, Rs 1.50 and Rs 1.75


respectively, find the total revenue in each market with the help of
matrices.
 If the unit costs of the above three products are Rs 1.60, Rs 1.20 and Rs
0.90 respectively, find the gross profit with the help of matrices
Solution
17

 2.25 
 Total Revenue  8000 10000 15000    59250 
  1.50    
10000 2000 20000  1.75   60500 
 

 2.25  1.6 
 Total gross profit  8000 10000 15000    20950 
 1.50  1.20    
10000 2000 20000  1.75  0.9   24100 
 
Brand Switching Problem
18

 In a brand switching problem, the transition matrix


is given by 0.5 0.4 0.1
0.2 0.7 0.1
 
 0.1 0.2 0.7
 If the market share vector at nth stage is [0.4 0.3
0.3], what will be the market share vector in the next
stage?
 Also calculate the market share in equilibrium
condition.
Solution
19

 The market share vector in the 2nd stage

0.5 0.4 0.1


0.4 0.3 0.30.2 0.7 0.1  0.29 0.43 0.28
 0.1 0.2 0.7

 At equilibrium state

0.5 0.4 0.1


P1 P2 P2 0.2 0.7 0.1  P1 P2 P2 
 0.1 0.2 0.7

 0.5P1+0.2P2+0.1(1-P1-P2)=P1 (1)
0.4P1+0.7P2+0.2(1-P1-P2)=P2 (2)
0.1P1+0.1P2+0.7P3=P3 (3)
 P1 =0.25, P2=0.5, P3=0.25
Brand Switching Problem
20

 Suppose there are two products of brand A and B


respectively. Let each of these brands have exactly 50% of
the total market share in same period and let the market
be of fixed size. The transition matrix is given below:

 

A0.9 0.1
From
 
B 0.5 0.5
 What will be market share after 2 years
 Determine their market share in steady state.
 P1=0.8333 P2=0.167
An Application to Manpower Planning
21
 A finance company has offices location in every division, every
district and every taluq in a certain state in India. Assume there are
five divisions, thirty districts and 200 taluqs in the state. Each office
has one head clerk, one cashier, one clerk and one peon. A division
office has in addition one office superintendent, two clerks, one
typist and one peon. A district office has in addition, one clerk and
one peon. Record the set up in matrix form
 
 5 30 200 
 Division District Taluq 13
Division  1 0 1 1 1 1 2 11 
 
District  0 0 1 1 11 11 
Taluq  0 0 1 1 1 1 
 
 Superitend ent Typist Head clerk Cashier clerk Peon 36
 The total number of posts of each kind in all offices taken together.

 5 5 235 235 275 270 


   1025
 Superitend ent Typist Head clerk cashier clerk peon 
 The basic monthly salaries are as follows: office
superintendent Rs 500, head
22
clerk Rs 200, cashier
Rs 175, clerks and typist Rs 150 and peon Rs 100.
Find out the total basic monthly salary bill of each
kind of office.
 
 
Division  1 1 1 1 3 2   
 
District  0 0 1 1 2 2   Superitend ent 500 
 
Taluq  0 0 1 1 1 1   Typist 150 
   200 
 Superitend ent Typist Peon 36
Head clerk
 Head clerk Cashier clerk  
 cashier 175 
 clerk 150 
 100  61
 peon

Division 1675 
 
 District  875 
 625 
Taluq  31
23

 The total basic monthly salary of each offices taken


together
Division 1675 
   
  5 30 200  District  875   15965
 Division District Taluq 13  625 
Taluq  31
Multipication
24

 In 2003, the population of the U.S., broken down by regions, was 53.3 million in the
Northeast, 64.0 million in the Midwest, 101.6 million in the South, and 65.4 million
in the West.14 The matrix P below shows the population movement during the
period 2003–2004. (Thus, 98.79% of the population in the Northeast stayed there,
while 0.20% of the population in the Northeast moved to the Midwest, and so on.)
To To To To
NE MW S W
P= From NE 0.9879 0.0020 0.0081 0.0019
From MW 0.0014 0.9895 0.0063 0.0028
From S 0.0027 0.0025 0.9927 0.0022
FromW 0.0010 0.0030 0.0050 0.9909

 Set up the 2003 population figures as a row vector. Then use matrix multiplication
to compute the population in each region in 2004.
25

 The inverse of an n × n matrix A is that n × n


matrix A−1 which, when multiplied by A
 on either side, yields the n × n identity matrix I.
Thus,
 A A−1 = A−1 A = I
 If A has an inverse, it is said to be invertible.
Otherwise, it is said to be singular
Some concepts for understanding Inverse
26

 Minor of an element of a matrix


 If Mij be the (n-1)X(n-1) submatrix of the matrix A =[aij]
obtained by removing ith and jth row then determinant of Mij,
i.e, |Mij|
 Cofactor of an element of a matrix
 Cofactor cij of an element aij is (-1)i+j|Mij|
Problem 1
1 2 1 27
A   1 0 3  find A -1
 2 1  1
 0 3 1 3 1 0 
  
 1 1 2 1 2 1
 3 5  1
 2 1 1 1 1 2  
Cofactors of matrix A      3  3 3
 1 1 2 1 2 1  
 6  4 2 
 2 1 1 1 1 2 
 0 
 3 1 3  1 0 
1 2 1
Determinan t of A  1 0 3  1 3  2  5  1 1  6
2 1 1
Problem 1 contd
28

 3 5  1
Cofactor of matrix A   3  3 3 
 6  4 2 
 3 3 6
Adjoint A  Transpose of cofactor matrix   5  3 4
  1 3 2
 3 3 6   0.5 0.5 1 
adj A 1 
A -1    5 3 4   0.8333  0.5  0.67
A 6
  1 3 2  0.167 0.5 0.33 
Solving simultaneous equation
29

 A firm produces two products P1 and P2 passing through


two machines M1 and M2 before completion.M1 can
produce either 10 units of P1or 15 units of P2 per hour. M2
can produce15 units of either product per hour. Find
daily production of P1 and P2 if time available is 12 hours
on machine M1 and 10 hours on machine M2 per day,
using matrix inversion.
 Let daily production of P1 and P2 be x and y respectively
x/10+y/15= 12
x/15+y/15=10
x=60, y=90
Application in Simultaneous Linear Equation
30
 The prices (in Rs) of three X, Y and Z are x, y, z per unit respectively. A
purchases 4 units of Z and sells 3 units of X and 5 units of Y. B purchases
3 units of Y and sells 2 units of X and 1 unit of Z, C purchases 1 unit of X
and sells 4 units of Y and 6 units of Z. In the process, A, B and C earn Rs
6000, Rs 5000, and Rs 13000. Using matrices, find the prices of the
three commodities.
 3 5  4  x   6000 
    
 2  3 1   
y  5000 
 1 4 6  z  13000 

 3x+5y-4z=6000, 2x-3y+z=5000, -x+4y+6z=13000
1
 x  3 5  4   6000 
     
 y    2  3 1   5000 
 z   1 4 6  13000 
  
 0.1457 0.3046 0.0464  6000   3000 
    
  0.0861  0.0927 0.0728  5000    1000 
  0.0331 0.1126 0.1258  2000  13000 
    
Input-Output Analysis-Closed Economy
31

 Suppose an economic system has several different industries, each of which has
certain input requirements, as well as some sort of product or output. Let us
consider three producers farmers (food), carpenters (tools) and Tailors
(clothes). Assume for convenience that each group produces 1 unit per year of
whatever they produce. Suppose that during the year, the portion of each
commodity consumed by each group is given by

Goods Produced by
Farmers Carpenters Tailors
Goods
Consume Farmers 7/16 1/2 3/16
d by
Carpenters 5/16 1/6 5/16
Tailors 1/4 1/3 1/2
Input-Output Analysis
32

 Let p1 be the price of food, p2 be the price of tools,


and p3 the price of clothes. (Each is price per unit).
We assume everyone pays the same amount for each
commodity, so the farmers pay just as much for food
as the tailors, even though they grew it. We are
interested in determining the prices p1; p2; p3 so
that we have a state of equilibrium, that is, no one
makes money and no one loses money. Apparently,
we are in a communist state.
Input-Output Analysis (Closed)
33

 This system of equations can be written in matrix notation as


Ap = p 0r (I-A)p =O
7 / 16 1 / 2 3 / 16  p1 
A  5 / 16 1 / 6 5 / 16, p   p2 
   
 1 / 4 1 / 3 1 / 2   p3 
 If no goods leave the system, and no goods are introduced
from an outside source, then the total consumption must
equal its total production
 An n×n matrix is called an input-output matrix iff it satisfies
the following two properties:
 (1) aij > 0 (the matrix is nonnegative).
 (2) a1j + a2j + : : : + anj = 1 (each column sums to 1).
 Input-output based model is economically viable if
|I-A|-1 exists
Input-Output Analysis (Open)
34

 We will work with equations that look like


(goods produced by the system)
= (goods consumed by the system) + (goods consumed
externally)
Input and Output Analysis -Open
35

 An economy produces only coal and steel. The two commodities serve as an
intermediate inputs in each other’s production. 0.4 tonne of steel and 0.1
tonne of coal are needed to produce a tone of steel. Similarly, 0.7 tonne of
steel and 0.6 tonne of coal are required to produce a tone of coal. No
capital inputs are needed. Do you think that the system is viable? 10 and 3
labour days are required to produce a tonne of coal and steel respectively. If
the external economy needs 400 tonne of steel and 200 tonne of coal,
calculate the gross output of the two commodities and total labour
required.
 Since determinant is positive and diagonal elements are non-zero. So the
system is viable. The total output of steel and coal will be
Input-Output Analysis-Open
36

 0.4 Steel +0.1 Coal +400 = Steel


 0.7Steel+0.6 Coal+200= Coal
 0.6 Steel -0.1 Coal =400

 -0.7 Steel+0.4 Coal =200

1
 Steel   0.6  0.1  400 
      
 Coal    0.7 0.4   200 
Steel = 1058.324
Coal=2352.941
Input-Output Analysis
37

 Consider two sectors of the U.S. economy: crude petroleum


and natural gas (crude) and petroleum refining and related
industries (refining). According to government figures,* in
1998 the crude sector used $27,000 million worth of its own
products and $750 million worth of the products of the
refining sector to produce $87,000 million worth of goods
(crude oil and natural gas). The refining sector in the same
year used $59,000 million worth of the products of the crude
sector and $15,000 million worth of its own products to
produce $140,000 million worth of goods (refined oil and the
like). What was the technology matrix for these two sectors?
What was left over from each of these sectors for use by other
parts of the economy or for export?

S-ar putea să vă placă și