# xAct, xTensor: How to avoid clash of indices?

Please refer to the picture below. In the first line, I define the angular momentum vector $$\vec{L} = \vec{R} \times \vec{P}$$ using the Levi-Civita tensor $$\epsilon^{i}_{jk}$$. The definition relies on repeated indices $$j$$ and $$k$$.

In the third line, I try to define the scalar $$\vec{L}.\vec{L}$$ which throws an error possibly because the resulting expression has 4 '$$j$$' and 4 '$$k$$' indices (which is nonsensical).

Next, I try to circumvent this problem by using 'ReplaceDummies' which seems to have solved the problem.

Is there another shorter and more elegant way to go because I may not want to stick 'ReplaceDummies' all the time?

There are two alternatives if you don't want to add 'ReplaceDummies' all the time.

1. Add 'ReplaceDummies' in the definition of $$L^i$$

L[i_] := ReplaceDummies[epsilon[Delta][i, -j, -k] R[j] P[k]] ;

L[i] L[-i] // ContractMetric // ToCanonical

will produce the desired result.

1. Use 'MakeRule' which is smarter and replaces the dummy indices on its own

LtorcrosspRule = MakeRule[{L[i], epsilon[Delta][i, -j, -k] R[j] P[k]}, MetricOn -> All];

L[i] L[-i] /. LtorcrosspRule // ContractMetric // ToCanonical

will also work.