# Linear algebra & matrix multiplication

**URL:** <https://boards.straightdope.com/t/linear-algebra-matrix-multiplication/467861>\
**Category:** Factual Questions\
**Created:** [October 14, 2008, 1:11pm UTC](https://boards.straightdope.com/t/linear-algebra-matrix-multiplication/467861 "2008-10-14T13:11:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![BrandonR](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@BrandonR](https://boards.straightdope.com/u/BrandonR)\
**Post date:** [October 14, 2008, 1:11pm UTC](https://boards.straightdope.com/t/linear-algebra-matrix-multiplication/467861/1 "2008-10-14T13:11:21Z")

</div>

_Disclaimer: this is not for homework, rather a request for clarification of a rather basic concept_

In my linear algebra book, it states at the columns of **AB** ( **A** and **B** are matrices) are just combinations of the columns of A. How? I know there are multiple ways of visualizing matrix multiplication but I’m just not seeing this one.

I’ve always only been able to multiply matrices by going across the row of the left matrix and multiplying by the same column of the second. This isn’t helpful in visualizing the columns, though.

For example, I get the following perfectly:

```auto

  | 8 2 8 |
A=| 2 1 1 |
  | 4 2 7 |

  | x1 |
B=| x2 |
  | x3 |
        |8| |2| |8|
AB = x1*|2| + x2*|1| + x3*|1|
        |4| |2| |7|

```

I think it’s just when B is more than a column vector, I get confused. And quickly.

It also says that the columns of **AB** are simply matrix **A** times the columns of **B**. Why doesn’t that mean that the columns of **AB** are combinations of the columns of _B_?

The book also states there’s a column-row picture for matrix multiplication in that the columns of **A** are multiplied by the rows of **B** , but it states no more and gives no examples. Help? I’m an engineering student and this abstract material is killing me. :smack:

---

<div class="post-metadata">

**Author:** ![CalMeacham](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/calmeacham/32/35_2.png) [@CalMeacham](https://boards.straightdope.com/u/CalMeacham)\
**Post date:** [October 14, 2008, 1:18pm UTC](https://boards.straightdope.com/t/linear-algebra-matrix-multiplication/467861/2 "2008-10-14T13:18:09Z")

</div>

Trying to write this out with the limitations of our typeface isn;t worth it.

My first suggestion is to get va good book on linear algebra. There are plenty of them out there.

You can also go to internet sites, of which there are many. The first refuge, of course, is Wikipedia, which gives you this:

> **[Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)**
>
> In mathematics, particularly in linear algebra, matrix multiplication is a binary operation that produces a matrix from two matrices. For matrix multiplication, the number of columns in the first matrix must be equal to the number of rows in the second matrix. The resulting matrix, known as the matrix product, has the number of rows of the first and the number of columns of the second matrix. The product of matrices A and B is denoted as AB.
> Matrix multiplication was first described by the Frenc...

Which is pretty good.

---

<div class="post-metadata">

**Author:** ![Santo\_Rugger](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@Santo\_Rugger](https://boards.straightdope.com/u/Santo_Rugger)\
**Post date:** [October 14, 2008, 1:34pm UTC](https://boards.straightdope.com/t/linear-algebra-matrix-multiplication/467861/3 "2008-10-14T13:34:18Z")

</div>

**Cal** ’s link has a pretty neat picture showing it graphically, but when you have more than one column in **B** , you just take each column piecewise and do the matrix multiplication, and then add the answers element wise. I’m not sure what you’re asking when you say **AB** should be combination of columns of **B** , since you’ve multiplied the vector\* B\* by the matrix \*\*A \*\*already.

I can’t explain it conceptually, but if you just do what you wrote in your code three times (assuming **B** is 3x3), and then add all 3 matrices up element wise, you should come up with the proper answer.

ETA: Here’s another handy reference, I just found out about wikibooks recently:

[http://en.wikibooks.org/wiki/Linear\_Algebra/Matrix\_Multiplication](http://en.wikibooks.org/wiki/Linear_Algebra/Matrix_Multiplication)

It’s a bit broken right now, but there’s a good example of an mxn \* nxo matrix.

---

<div class="post-metadata">

**Author:** ![Hari\_Seldon](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/hari_seldon/32/5173_2.png) [@Hari\_Seldon](https://boards.straightdope.com/u/Hari_Seldon)\
**Post date:** [October 14, 2008, 2:01pm UTC](https://boards.straightdope.com/t/linear-algebra-matrix-multiplication/467861/4 "2008-10-14T14:01:29Z")

</div>

Think of it this way. If I let v\_1,v\_2,…,v\_m denote the columns of A (so that we think of A as a row whose entries are these column vectors) and the left column of B is b\_11, b\_21,…,b\_m1, then the left column of AB is the linear combination b\_11v\_1 + b\_21v\_2 + … + b\_m1v\_m. The second column of AB is similarly a linear combination of the columns of A using the second column of B as the coefficients and so on.

Of course, you could equally well say that the rows of AB are linear combinations of those of B, using the elements of the rows of A as coefficients. As a matter of pedagogy (I taught linear algebra more times than I care to think), I don’t find this approach to matrix multiplication as particularly helpful. At any rate, I hope the explanation is useful.

---

<div class="post-metadata">

**Author:** ![Tyrrell\_McAllister](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/tyrrell_mcallister/32/16772_2.png) [@Tyrrell\_McAllister](https://boards.straightdope.com/u/Tyrrell_McAllister)\
**Post date:** [October 14, 2008, 3:48pm UTC](https://boards.straightdope.com/t/linear-algebra-matrix-multiplication/467861/5 "2008-10-14T15:48:24Z")

</div>

The more explanations the better, right? I’ll just extend your example a little, which means less work for me ;).

Let’s let

```auto

    | 8 2 8 |
A = | 2 1 1 |
    | 4 2 7 |

    | x1 | | y1 |
X = | x2 | Y = | y2 |
    | x3 | | y3 |

```

where x1, y1, etc., are specific real numbers. Then, as you wrote, **AX** is the following linear combination of the columns of **A** , which I’ll call **C1**.

```auto

             |8| |2| |8|
C1 = AX = x1*|2| + x2*|1| + x3*|1|
             |4| |2| |7|

```

Similarly, **AY** is the following linear combination of the columns of **A** , which I’ll call **C2**.

```auto

             |8| |2| |8|
C2 = AY = y1*|2| + y2*|1| + y3*|1|
             |4| |2| |7|

```

Now suppose that I have a 3x2 matrix **Z** whose columns are **X** and **Y** :

```auto

               | x1 y1 |
Z = | X Y | = | x2 y2 |
               | x3 y3 |

```

Compute the matrix product **AZ** in the way that you’re used to, and you’ll get a matrix whose columns are precisely **C1** and **C2**.

```auto

AZ = | C1 C2 |

```

Since **C1** and **C2** were linear combinations of columns of **A** , you can say the same about the columns of the matrix product **AZ**.

---

<div class="post-metadata">

**Author:** ![KneadToKnow](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/kneadtoknow/32/3999_2.png) [@KneadToKnow](https://boards.straightdope.com/u/KneadToKnow)\
**Post date:** [October 14, 2008, 4:05pm UTC](https://boards.straightdope.com/t/linear-algebra-matrix-multiplication/467861/6 "2008-10-14T16:05:47Z")

</div>

There is no spoon.

---

<div class="post-metadata">

**Author:** ![BrandonR](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@BrandonR](https://boards.straightdope.com/u/BrandonR)\
**Post date:** [October 15, 2008, 3:59am UTC](https://boards.straightdope.com/t/linear-algebra-matrix-multiplication/467861/7 "2008-10-15T03:59:56Z")

</div>

Thanks for all the replies! I think I get it now.
