# How would you write this in Index notation?

**URL:** <https://discourse.julialang.org/t/how-would-you-write-this-in-index-notation/68032>\
**Category:** Offtopic\
**Created:** [September 11, 2021, 7:39pm UTC](https://discourse.julialang.org/t/how-would-you-write-this-in-index-notation/68032 "2021-09-11T19:39:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [September 11, 2021, 7:39pm UTC](https://discourse.julialang.org/t/how-would-you-write-this-in-index-notation/68032/1 "2021-09-11T19:39:03Z")

</div>

Hi!

So a bit of an off-topic question, but I think a lot of you here have an interest in math. If you had an expression you wanted to put in index notation given for one value of i as:

![image](https://global.discourse-cdn.com/julialang/original/3X/d/c/dcea56f06b493e605fd431046ece6b97e2806e68.png)

Where x is a vector with i = 1 → 3:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/4/6401aae25727ebb7978beb128bb14774eec5ccb4.png)

Where superscripts a and b refer to particles, for example see this picture:

![image](https://global.discourse-cdn.com/julialang/original/3X/7/0/70d559edce4d20e754b8600fe57d481494f3c9c3.png)

[https://www.researchgate.net/publication/270278277\_A\_Lagrangian-Lagrangian\_framework\_for\_the\_simulation\_of\_rigid\_and\_deformable\_bodies\_in\_fluid\_Multibody\_Dynamics\_Computational\_Methods\_and\_Applications/figures?lo=1&utm\_source=google&utm\_medium=organic](https://www.researchgate.net/publication/270278277_A_Lagrangian-Lagrangian_framework_for_the_simulation_of_rigid_and_deformable_bodies_in_fluid_Multibody_Dynamics_Computational_Methods_and_Applications/figures?lo=1&utm_source=google&utm_medium=organic) - Picture source no need to click.

How would you write this in index notation using Einstein summation convention? I’ve been trying something like this:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/7/979305b825336d94dac2184eeba99b68d79fc839.png)  
Where the nominator seems fine to me, but the denominator I just don’t see how to make it “sum” as I want.

It is primarily the subscripts I want help with, the superscripts are fine to me.

Kind regards

---

<div class="post-metadata">

**Author:** ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Post date:** [September 12, 2021, 3:28pm UTC](https://discourse.julialang.org/t/how-would-you-write-this-in-index-notation/68032/2 "2021-09-12T15:28:22Z")

</div>

As far as I know, the Einstein summation is primarily used for linear expressions.  
Hence, \lambda^i b\_i = \sum\_i \lambda^i b\_i.

But, summation is not automatically performed on addition of terms with indices, i.e. \lambda^i + \gamma^i \neq \sum\_i (\lambda^i + \gamma^i).  
_Instead, this expression makes sense if combined with the basis, namely (\lambda^i + \gamma^i) b\_i = \sum\_i (\lambda^i + \gamma^i) b\_i_

In Riemannian geometry, one could use a Riemannian metric (g) to compute the length of a tangent vector x^i b\_j as \sqrt{ g\_{ij} x^i x^j } = \sqrt{ \sum\_{ij} g\_{ij} x^i x^j }.

Now, to compute the distance between two points in Riemannian geometry is a bit envolved (geodesics), which is maybe the reason why finding a good expression is a bit unintuitive, but you could write

\sqrt{ \delta\_{ij} (x^i - y^i) (x^j - y^j) }

where \delta\_{ij} = 1 if i=j and otherwise \delta\_{ij} = 0 (which are the coordinates of the Riemannian tensor for Euclidean geometry with respect to the cannonical basis).

For the whole expression, you could write

\frac{x^i - y^i}{\sqrt{ \delta\_{\alpha \beta} (x^\alpha - y^\alpha) (x^\beta - y^\beta) }}.

_Notes on notation: Everyone uses different notation. I must admit that for me the Einstein summation makes only sense if one differentiates between covariant and contravariant coordinates. That’s why I use upper and lower indices a bit different than you._

(Also, you are most likely aware of it, but [https://math.stackexchange.com/](https://math.stackexchange.com/) is probably a better place where you could get more answers for this type of question.)
