Visualizing Matrix multiplication in four different ways — Part 2

Vaibhav Patel
Analytics Vidhya
Published in
4 min readNov 28, 2020

In Part 1 I had explained the four ways to perform Matrix Multiplication intuitively. Recently, I have come across some other tricks which are useful to understand the theory of Machine Learning Algorithms without using a scratchpad! You can even reverse engineer the two matrices just by looking at the result of Matrix Multiplication. So, without further ado, let’s start learning them.

Before proceeding further, we will add one terminology called row-side and column-side. When the matrix is multiplied to the left of the other matrix it is called row-side multiplication and when it is multiplied on the right side it is called column-side multiplication. You can remember it by remembering the order of the notation of the dimension of the matrix.

Trick 1: Distribute values row-wise or column-wise with Diagonal Matrix

Diagonal values will get distributed to columns if multiplied to the column-side of the matrix.

Diagonal values will get distributed to rows if multiplied to the row-side of the matrix.

If you find any matrix with a left-hand side pattern then you can split it into matrix multiplication as shown on the right-hand side.

Trick 2:Effect of Matrix with only single non zero value

This is a little tricky. Whenever you multiply single-non-zero valued matrix first note the position of row and column of the non zero value. Let’s call them r and c.

Now if the matrix is multiplied to the column side then pick the column corresponding to the position r and then put it at the c position in the final matrix. (To remember: column-side,column at c position)

Now if the matrix is multiplied to the row-side then pick the row corresponding to position c and then put it at the r position in the final matrix. (To remember: row-side, row at r position)

Trick 3: Quadratic polynomial in Matrix form

The above result is a scalar and can be expressed as follows:

How to remember it? Simple, you know the matrix corresponding to column row multiplication.

Now perform element-wise multiplication with A and add all the elements.

a circle represents element-wise multiplication

Trick 4: Off diagonal matrix multiplication

This result can be obtained using trick 2, however, it is easy to visualize it differently.

No matter what side the off-diagonal matrix be, mirror the row-side matrix about the column and column-side matrix about the row and then perform Trick 2.

Hope these four new tricks help you follow the matrix multiplication of machine learning proofs without scribbling too much.

Share the love if you find the article useful, it motivates me to write more quality content for you.

For Part I check:

--

--

Vaibhav Patel
Analytics Vidhya

MTech. Data Science @ IITMadras Finance Enthusiast | Data Science Enthusiast