Advertisement

Everything you've been told about the cross product not existing in dimension n other than n = 3 or n = 7 is not quite true

Started by February 02, 2025 06:15 PM
1 comment, last by taby 1 week, 1 day ago

So, partially due to my own ignorance, I was under the impression that there is no cross product in $n$-dimensional space except for where $n = 3$ and $n = 7$. I mean, I've read that a lot, from many different sources.

However, the cross product in $n$-dimensional space is just the Hodge star operator where $k = n - 1$. That is, the $3$-D cross product takes in two (e.g. $n - 1$) $3$-D vectors and outputs one $3$-D vector. Where $n = 7$, the cross product takes in six $7-D$ vectors, and outputs one $7$ vector.

But you can turn this into a C++ function where n is a template parameter, so that it works in for any dimension.

I did just that, and applied it to linear algebra by visualizing the determinant of a square matrix as a single cross product operation and then a single dot product operation.

It works exactly as desired.

So don't let anyone tell you that there is no equivalent cross product in arbitrary dimension. The determinant of the matrix, which relies on this cross product, is calculated perfectly fine.

The code is at: https://github.com/sjhalayka/cross_product_nD

Sorry, I'm likely late for the party: this Hodge star operator where $k = n - 1$ is likely common knowledge.

Here's the resulting equation for $n = 3$, which is a little bit different than the traditional $3$-D cross product:

result[0] += v(0, 1) v(1, 2)
result[0] -= v(0, 2) v(1, 1)
result[1] += v(0, 0) v(1, 2)
result[1] -= v(0, 2) v(1, 0)
result[2] += v(0, 0) v(1, 1)
result[2] -= v(0, 1) v(1, 0)

For $n = 7$, the terms look quite unlike those from the traditional $7$-D cross product:

result[0] += v(0, 1) v(1, 2) v(2, 3) v(3, 4) v(4, 5) v(5, 6)
result[0] -= v(0, 1) v(1, 2) v(2, 3) v(3, 4) v(4, 6) v(5, 5)
result[0] -= v(0, 1) v(1, 2) v(2, 3) v(3, 5) v(4, 4) v(5, 6)
result[0] += v(0, 1) v(1, 2) v(2, 3) v(3, 5) v(4, 6) v(5, 4)
result[0] += v(0, 1) v(1, 2) v(2, 3) v(3, 6) v(4, 4) v(5, 5)
result[0] -= v(0, 1) v(1, 2) v(2, 3) v(3, 6) v(4, 5) v(5, 4)
result[0] -= v(0, 1) v(1, 2) v(2, 4) v(3, 3) v(4, 5) v(5, 6)
result[0] += v(0, 1) v(1, 2) v(2, 4) v(3, 3) v(4, 6) v(5, 5)
result[0] += v(0, 1) v(1, 2) v(2, 4) v(3, 5) v(4, 3) v(5, 6)
result[0] -= v(0, 1) v(1, 2) v(2, 4) v(3, 5) v(4, 6) v(5, 3)
result[0] -= v(0, 1) v(1, 2) v(2, 4) v(3, 6) v(4, 3) v(5, 5)
result[0] += v(0, 1) v(1, 2) v(2, 4) v(3, 6) v(4, 5) v(5, 3)
result[0] += v(0, 1) v(1, 2) v(2, 5) v(3, 3) v(4, 4) v(5, 6)
result[0] -= v(0, 1) v(1, 2) v(2, 5) v(3, 3) v(4, 6) v(5, 4)
result[0] -= v(0, 1) v(1, 2) v(2, 5) v(3, 4) v(4, 3) v(5, 6)
result[0] += v(0, 1) v(1, 2) v(2, 5) v(3, 4) v(4, 6) v(5, 3)
result[0] += v(0, 1) v(1, 2) v(2, 5) v(3, 6) v(4, 3) v(5, 4)
result[0] -= v(0, 1) v(1, 2) v(2, 5) v(3, 6) v(4, 4) v(5, 3)
result[0] -= v(0, 1) v(1, 2) v(2, 6) v(3, 3) v(4, 4) v(5, 5)
result[0] += v(0, 1) v(1, 2) v(2, 6) v(3, 3) v(4, 5) v(5, 4)
result[0] += v(0, 1) v(1, 2) v(2, 6) v(3, 4) v(4, 3) v(5, 5)
result[0] -= v(0, 1) v(1, 2) v(2, 6) v(3, 4) v(4, 5) v(5, 3)
result[0] -= v(0, 1) v(1, 2) v(2, 6) v(3, 5) v(4, 3) v(5, 4)
result[0] += v(0, 1) v(1, 2) v(2, 6) v(3, 5) v(4, 4) v(5, 3)
result[0] -= v(0, 1) v(1, 3) v(2, 2) v(3, 4) v(4, 5) v(5, 6)
result[0] += v(0, 1) v(1, 3) v(2, 2) v(3, 4) v(4, 6) v(5, 5)
result[0] += v(0, 1) v(1, 3) v(2, 2) v(3, 5) v(4, 4) v(5, 6)
result[0] -= v(0, 1) v(1, 3) v(2, 2) v(3, 5) v(4, 6) v(5, 4)
result[0] -= v(0, 1) v(1, 3) v(2, 2) v(3, 6) v(4, 4) v(5, 5)
result[0] += v(0, 1) v(1, 3) v(2, 2) v(3, 6) v(4, 5) v(5, 4)
result[0] += v(0, 1) v(1, 3) v(2, 4) v(3, 2) v(4, 5) v(5, 6)
result[0] -= v(0, 1) v(1, 3) v(2, 4) v(3, 2) v(4, 6) v(5, 5)
result[0] -= v(0, 1) v(1, 3) v(2, 4) v(3, 5) v(4, 2) v(5, 6)
result[0] += v(0, 1) v(1, 3) v(2, 4) v(3, 5) v(4, 6) v(5, 2)
result[0] += v(0, 1) v(1, 3) v(2, 4) v(3, 6) v(4, 2) v(5, 5)
result[0] -= v(0, 1) v(1, 3) v(2, 4) v(3, 6) v(4, 5) v(5, 2)
result[0] -= v(0, 1) v(1, 3) v(2, 5) v(3, 2) v(4, 4) v(5, 6)
result[0] += v(0, 1) v(1, 3) v(2, 5) v(3, 2) v(4, 6) v(5, 4)
result[0] += v(0, 1) v(1, 3) v(2, 5) v(3, 4) v(4, 2) v(5, 6)
result[0] -= v(0, 1) v(1, 3) v(2, 5) v(3, 4) v(4, 6) v(5, 2)
result[0] -= v(0, 1) v(1, 3) v(2, 5) v(3, 6) v(4, 2) v(5, 4)

...
Advertisement