# How to convert an einsum expression to an equation?

I'm using Python's einsum for an operation over two arrays, and I was wondering how to correctly write this operation out in a paper.

Let's say I have two '3d' arrays $$A_{i,j,k}$$ and $$B_{i,k,l}$$, and I want a sum-product over index $$k$$, an outer product over indices $$j$$ and $$l$$, and I want to do that for every $$i$$, i.e. index $$i$$ is "matched" between $$A$$ and $$B$$. I would write that as einsum('ijk,ikl->ijl',A,B).

1. Is there an index-based mathematical notation that would let me write all these operations at once? I have looked up actual Einstein summation, but it seems to be defined more narrowly, e.g. for a sum-product but not outer product, and not in a way you could represent "for every $$i$$...". Specifically for the index $$i$$, it seems that once an index is repeated, it must be summed over, which I don't want.

2. Is there a set of rules for writing out derivatives with respect to arrays using the same index notation? E.g. of outer and inner products, repeated operations, etc?

Inner (sum-product) and outer product in index notation works exactly as in einsum (it worth noting that the notation and the name einsum come from Einstein notation common in tensor algebra). For example, for tensors $$A_{ij}$$ and $$B_{ij}$$:

$$A_{ij}B_{jk} = C_{ik}$$

Inner product on index $$j$$ and outer product for everything else.

However, element-wise operation (for matrices, it's called Hadamard product) is not a tensor operation (the result isn't generally a tensor), so there is no widely used notation for that. However, you are not prohibited to invent it yourself:

$$A_{ijk}\circ_i B_{ikl} = C_{ijl}$$

(I am once again note that multi-dimensional matrices $$A,B,C$$ are not tensors from the maths perspective)

Another approach is to separate indices that follow Einstein rule (e.g. lating $$i,j,k$$) from indices that are just indices (e.g. $$\alpha,\beta,\gamma$$): $$A_{\alpha jk} B_{\alpha kl} = C_{\alpha jl}$$

In that case $$A_{\alpha ij}$$ can be tensor for each particular value of $$\alpha$$