Chapter 2 operations as einsum
Three operations you already know, written with the one rule:
np.einsum('ii->', A) # trace == np.trace(A)
np.einsum('ij->ji', A) # transpose == A.T
np.einsum('ik,kj->ij', A, B) # matrix product == A @ B
Trace repeats a letter, which selects the diagonal, and then sums it. Transpose keeps both letters but swaps their order after the arrow — nothing is summed. Matrix product shares k between two inputs and drops it.