Matrix demystified

13
Matrix Demystified…

description

Attempts to describe the meaning behind the mathematical concept of Matrix

Transcript of Matrix demystified

Page 1: Matrix demystified

Matrix Demystified…

Page 2: Matrix demystified

What is Matrix?• What is Matrix?– Novel, Movie??– A Physical/Visual Construct?

• (like grid…, or students in prayer hall)

– Some geometric construct? (like rectangle, square??)– CS Data Structure (like Two Dimensional Array??)– Rows….Columns….Other definitions? ...– Yes, these are all fine, but why do we need this?

• Addition, Subtraction – Oh, ok…. now, I see• Multiplication – Hey ---- What the heck is this !!!• Determinant, Inverse ---- ?$%#• Rank, Eigen-Value, Eigen-Vector----------Bhaago!!

Page 3: Matrix demystified

Why this kolaveri di?• Root Cause

– No Surprise, Our education system– Which divorces the description of mathematical ideas from their historical

context– Not convinced?

• Google for Matrix Multiplication• http://en.wikipedia.org/wiki/Matrix_multiplication#General_definition• Do you still want to study matrices?

• Wrong Sequence– First Matrix, then addition/subtraction then multiplication – THIS IS

WRONG– First Matrix Multiplication, then add/subtract, then Matrix – THIS IS RIGHT

• This presentation is an attempt towards correcting this injustice done to simple and great idea of MATRIX

Page 4: Matrix demystified

What is Matrix Multiplication?

• Software Engineer– (for for for c[I,j] += a[I,k] * b[k,r] )– One more successful program he wrote without

understanding a, b, c (or m, n, r) of it• DSP Engineer - – Convolution, Weighted Sum, FIR, Pipelining…– Impressive terms , but why matrix?

• Mathematician – See Wikipedia… • Super Market Clerk -??? –What is he doing here?– In all probabilities, he was the one who invented matrix

multiplication and hence matrix!!!

Page 5: Matrix demystified

Super Market – Birth Place of Matrix Multiplication

• Let me explain…– Suppose you buy 1 kg Sugar, ½ Liter Milk and 5

cakes of detergent soap. – Let 1 Kg sugar = Rs. 61; 1 Liter Milk Rs. 40 and 1

cake of soap costs Rs. 25

Page 6: Matrix demystified

Contd…

• How will you calculate the cost?=> 1 * 61+ 0.5 *1 + 5 * 1= (….blank cheque )

=> We can generalize it by applying famous [(price per unit) * (no units formula)]Þ 1 [sugar price] + 40 [milk price] + 25 [ cake price ]Þ That’s it!! Above expression is Matrix MultiplicationÞ This [Multiply and Accumulate] “*+” is central concept

at matrix multiplication and hence at matrix

Page 7: Matrix demystified

Contd…• This operation reduces it’s two sequences to a single

number, or two vector operands to a scalar quantity• Let us see how….– Split the above formula into two parts– Price Per Unit (PPU) List = [61 40 25]– Number Of Units = [1 ½ 5]

• If you want to calculate the bill, you will multiply corresponding vectors, and add all the terms of resulting vectors( here, we can consider the term vector to mean lists)

Page 8: Matrix demystified

Contd..Total price= + ( [61 40 25] .* [1 ½ 5] ) = + ( [61*1 40*1/2 25*5] )= + ([61 20 125])= 206Note two operations here1. Multiplication between corresponding elements of two

vectors of same size ( no of units * units price operation). One thing it converts different infos like kg, liter and 5 pieces to same unit price. This allows addition to be possible

2. Addition of all elements belonging to same vector

Page 9: Matrix demystified

Contd…

• These two operations together is called Matrix Multiplications

Þ + ([61 40 25] .* [1 ½ 5])Þ [61 40 25] * [1 ½ 5] ; //note that .* becomes

just * nowÞ This itself represented as Þ [1 ½ 5] * 61

40

25

Page 10: Matrix demystified

This visual concept gives birth to idea of

• A vector in horizontal orientation and another in vertical.

• But it is just visualization. They could have been elliptical and diagonal also.

• But, again why this circus? Why we could not keep both horizontal.

• Answer is…

Page 11: Matrix demystified

I too do not know

• However, some guesses• To differentiate .* from * (not convincing enough)• To keep in-line with addition, and subtraction

- Operands of +, - , .* are of same type- Result will also be of same type- But matrix multiplication yields scalar when two vectors are multiplied. Probably, notation helps to emphasize this fact that this is not straight multiplication

Page 12: Matrix demystified

Contd…

• Let us explore further. Let us consider 5 people shopped in the shop on a particular day. Using the notation discussed earlier

Note that row elements are of different types (sugar milk and soap) where as column elements are of same type. Keeping the same philosophy , since prices are of same type they better represented as columns. Note that adding a given column appears natural. For example, if you observe sum row below, it shows total amount of sugar sold in a day. Same is with Milik and Soap. However, adding all row elements of a row does not make any sense. What is Sugar + Milk + Soap? Sweet Washing System?.....Yucc!!! If we want to preserve this convention, price also should be column rather than row.

1 ½ 52 1 34 5 79 8 33 2 4

61

40

25

19 16.5 25

Page 13: Matrix demystified

Contd…

• Now, conventional matrix emerges, with rows columns etc.,

• I will leave it to you to extend to other matrix related ideas. (Ab tumhare havaale matrix saathiyon )

• All the best!!