# Confused about associativity of outer product notation

Consider this expression where $$A$$ and $$B$$ are matrices, $$|i \rangle$$ is a ket (column vector) and $$\langle j |$$ is a bra (row vector) : $$A | i \rangle \langle j | B \tag1\label1$$

Due to the general associative properties of the bra-ket notation, this can be interpreted as the inner product of 2 vectors: $$\left( A | i \rangle \right) \left( \langle j | B \right) \tag2\label2$$

But by regrouping the terms and considering that outer products can be given a matrix representation, \eqref{1} can also be interpreted as the product of 3 matrices:

$$A (| i \rangle \langle j |) B \tag3\label3$$

My confusion comes from the mismatch of the dimensions of expressions \eqref{2} and \eqref{3}. \eqref{2} yields a complex scalar, while \eqref{3} yields a matrix. If the associative property holds, I'd expect the dimensions not to depend on the grouping of the terms. Could somebody please shed some light where I am getting confused?

It seems you're conflating inner products and outer products. An inner product would be expressed as $$\langle i \vert j \rangle \;\;\; \text{or} \;\;\; \langle i \vert A^\dagger B \vert j\rangle.$$ A column vector times a row vector, $$C^{j \times 1} R^{1 \times i}$$, results in a $$j \times i$$ matrix. A row vector times a column vector with compatible dimension, $$R^{1 \times j} C^{j \times 1}$$, gives a scalar.