Live data from Hacker News

Einstein Notation applied in programming

hz2.org

1–10 of 28 posts

Re: Einstein Notation applied in programming

#5
I've never seen a cross product being defined in that way using Einstein notation.

You might want to express the cross product using the Levi-Civita symbol epsilon_{ijk} [1].

epsilon_{ijk} = 1 for i,j,k = 1,2,3 and all even permutations thereof. epsilon_{ijk} = -1 for all odd permutations of i,j,k = 1,2,3. Else it is 0.

Then, the cross product reduces to: C_i = epsilon_{ijk} A_j B_k

Using identities for epsilon_{ijk} you can – for example – easily calculate what A cross (B cross C) is.

[1]: https://en.wikipedia.org/wiki/Levi-Civita_symbol

Re: Einstein Notation applied in programming

#6

I've never seen a cross product being defined in that way using Einstein notation. You might want to express the cross product using the Levi-Civita symbol epsilon_{ijk} [1]. epsilon_{ijk} = 1 for i,j,k = 1,2,3 and all even permutations thereof. epsilon_{ijk} = -1 for all odd permutations of i,j,k = 1,2,3. Else it is 0. Then, the cross product reduces to: C_i = epsilon_{ijk} A_j B_k Using identities for epsilon_{ijk}…

> I've never seen a cross product being defined in that way using Einstein notation.

In fact, I can't understand this use of the notation—namely,

    C_i = A_{i + 1 `mod` 3}B_{i + 2 `mod` 3}
—and am not sure that it's correct. There is no free variable on the right-hand side, so I'm not sure over what to sum. Even if this were fixed, we'd need something like, as you say, the Levi–Civita symbol, since a given entry of the cross product is not a sum but a difference.

Re: Einstein Notation applied in programming

#7
post #6

I've never seen a cross product being defined in that way using Einstein notation. You might want to express the cross product using the Levi-Civita symbol epsilon_{ijk} [1]. epsilon_{ijk} = 1 for i,j,k = 1,2,3 and all even permutations thereof. epsilon_{ijk} = -1 for all odd permutations of i,j,k = 1,2,3. Else it is 0. Then, the cross product reduces to: C_i = epsilon_{ijk} A_j B_k Using identities for epsilon_{ijk}…

> I've never seen a cross product being defined in that way using Einstein notation. In fact, I can't understand this use of the notation—namely, C_i = A_{i + 1 `mod` 3}B_{i + 2 `mod` 3} —and am not sure that it's correct. There is no free variable on the right-hand side, so I'm not sure over what to sum. Even if this were fixed, we'd need something like, as you say, the Levi–Civita symbol, since a given entry of the…

Oh, you're right. I just glanced over the equation and I thought I should recommend the standard notation.

But as you stated, the cross product is clearly wrong as given by the author. There's obviously no other way than defining it with a totally antisymmetric quantity like the Levi-Civita symbol.

Re: Einstein Notation applied in programming

#9

Been a while since GR, but I'm pretty sure some of those indices are supposed to be on top. A_{ij} = B_i^k * C_{jk} possibly, but don't quote me on that.

Subscripts are how it's used in the more down to earth engineering applications like anisotropic thermal conductivity and elasticity. I can see why some authors might want to put the right-hand-side-only variables somewhere else for clarity though.

Re: Einstein Notation applied in programming

#10
What the author call "black magic" I call abstraction. Why would you need to know at all times what summation and multiplications of what rows and columns are going on in your matrices? That's why use matrices, to not have to think about those all the time.
Post reply on HN