# Matrix calculation for dot product?

**URL:** <https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365>\
**Category:** Factual Questions\
**Created:** [September 19, 2005, 3:07pm UTC](https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365 "2005-09-19T15:07:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![chaoticbear](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@chaoticbear](https://boards.straightdope.com/u/chaoticbear)\
**Post date:** [September 19, 2005, 3:07pm UTC](https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365/1 "2005-09-19T15:07:57Z")

</div>

Is there a way to use a matrix for dot products of vectors, like you can take the determinant of  
[i j k]  
[Ax Ay Az]  
[Bx By Bz]  
to get the cross product for AxB?

---

<div class="post-metadata">

**Author:** ![Thudlow\_Boink](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/thudlow_boink/32/320_2.png) [@Thudlow\_Boink](https://boards.straightdope.com/u/Thudlow_Boink)\
**Post date:** [September 19, 2005, 3:10pm UTC](https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365/2 "2005-09-19T15:10:22Z")

</div>

Well, if you make one vector a row vector, and the second a column vector, and multiply them together according to the ordinary rules for matrix multiplication, then what you’ve just calculated is the dot product of the two vectors.

Seems kinda circular, though, since matrix multiplication essentially involves computing dot products anyway.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [September 19, 2005, 4:15pm UTC](https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365/3 "2005-09-19T16:15:14Z")

</div>

> [@Thudlow Boink](#):
>
> Well, if you make one vector a row vector, and the second a column vector, and multiply them together according to the ordinary rules for matrix multiplication, then what you’ve just calculated is the dot product of the two vectors.

Even simpler, make them both row/column vectors and just compute **w\*\*\*\*v** [sup]T[/sup]/ **w** [sup]T[/sup] **v**.

---

<div class="post-metadata">

**Author:** ![Mathochist](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Mathochist](https://boards.straightdope.com/u/Mathochist)\
**Post date:** [September 19, 2005, 4:41pm UTC](https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365/4 "2005-09-19T16:41:54Z")

</div>

> [@ultrafilter](#):
>
> Even simpler, make them both row/column vectors and just compute **w\*\*\*\*v** [sup]T[/sup]/ **w** [sup]T[/sup] **v**.

You might want to clear up that the / in that expression means “or, respectively” rather than division.

---

<div class="post-metadata">

**Author:** ![chaoticbear](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@chaoticbear](https://boards.straightdope.com/u/chaoticbear)\
**Post date:** [September 19, 2005, 6:16pm UTC](https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365/5 "2005-09-19T18:16:38Z")

</div>

Umm… what are row and column vectors?

Quite plainly, what do I need to do in order to do this? (side note: I had a physics test that I didn’t know about today, and dot products were on there… however, we weren’t responsible for knowing how to do it with matrices, since we never learned it.)

Could someone explain this for the matrix-hater?

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [September 19, 2005, 6:28pm UTC](https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365/6 "2005-09-19T18:28:41Z")

</div>

A row vector is a 1 x n matrix, while a column vector is an n x 1 matrix.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [September 19, 2005, 8:10pm UTC](https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365/7 "2005-09-19T20:10:23Z")

</div>

For example, if I have vectors A = (1,6,5) and B = (4,9,3), and I wanted A dot B, I’d set it up this way:

```auto

           [4]
[1 6 5] [9]
           [3]

```

The first vector I set up as a row matrix, and the second as a column matrix, and then I just multiply them as normal matrix multiplication. Not that this saves any effort, in this case, but it’s a good foundation to start building on for more complicated matrix algebra (one might, for instance, have some other square matrix in between the two vectors).

---

<div class="post-metadata">

**Author:** ![TJdude825](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@TJdude825](https://boards.straightdope.com/u/TJdude825)\
**Post date:** [September 19, 2005, 11:13pm UTC](https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365/8 "2005-09-19T23:13:41Z")

</div>

The only advantage I can see to using matrices instead of just calculating the way you probably learned (Ax_Bx + Ay_By + Az\*Cz) is that you can multiply matrices on a TI-83 or similar, which might be easier than the formula above if the numbers in the vectors are long and decimal-y and your teacher wants a high level of accuracy.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [September 19, 2005, 11:41pm UTC](https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365/9 "2005-09-19T23:41:56Z")

</div>

The real advantage is that both operations are described by a single algorithm. It’s always kinda cool when something like that happens.

---

<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:** [September 20, 2005, 5:35am UTC](https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365/10 "2005-09-20T05:35:53Z")

</div>

There is another advantage, which, granted, wouldn’t do you much good unless you went much further in math: Frequently, when you compute a dot product **x** ⋅ **y** , you’re really applying a linear functional **x** to a vector **y**. That is, **x** lives in the dual space _V_[sup]\*[/sup] of the space _V_ containing **y**. By using matrices, your notation accords with the fact that **x** and **y** live in different vector spaces, just as row and column vectors do.

---

<div class="post-metadata">

**Author:** ![Mathochist](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Mathochist](https://boards.straightdope.com/u/Mathochist)\
**Post date:** [September 20, 2005, 5:41am UTC](https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365/11 "2005-09-20T05:41:01Z")

</div>

> [@Tyrrell McAllister](#):
>
> There is another advantage, which, granted, wouldn’t do you much good unless you went much further in math: Frequently, when you compute a dot product **x**? **y** , you’re really applying a linear functional **x** to a vector **y**. That is, **x** lives in the dual space _V_[sup]\*[/sup] of the space _V_ containing **y**. By using matrices, your notation accords with the fact that **x** and **y** live in different vector spaces, just as row and column vectors do.

To be more accurate, the function **y** -\> **x**? **y** is a linear functional. **x** lives in the same vector space as **y** , but the dot product specifies an _isomorphism_ between the vector space and its dual.

---

<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:** [September 20, 2005, 6:01am UTC](https://boards.straightdope.com/t/matrix-calculation-for-dot-product/322365/12 "2005-09-20T06:01:30Z")

</div>

My post was accurate was it stood, though it was not precise, thanks to my escape-hatch word “frequently” and to my not being explicit about how I was using the notation. But, to make things more precise, I was assuming that a basis for _V_ had been given (as is “frequently” the case in applications), and I was using **x**? **y** as nothing but notation for **x** ( **y** ), so that **x** is literally an element of the dual space of the space containing **y**.

Often, of course, the dot product is being used as an inner product on _V_, but I’m not talking about those cases.
