# When would I consider using an outer product of quantum states, to describe aspects of a quantum algorithm?

I know the inner product has a relationship to the angle between two vectors and I know it can be used to quantify the distance between two vectors. Similarly, what's an use case for the outer product? You can exemplify with the simplest case. It doesn't have to be a useful algorithm.

I do know the outer product is a matrix and I know how to compute it, but I don't know how and where I'd use it.

## 2 Answers

An outer product is a description of an operator, which is very often to be applied to a state. It can therefore be used to describe how the state transforms under the action of the operator.$$\def\ket#1{\lvert#1\rangle}\def\bra#1{\!\langle#1\rvert}$$

For example, we may describe the Hadamard gate by $$H \;=\; \ket{+}\bra{0} \,+\, \ket{-}\bra{1},$$ which describes the fact that $$H$$ transforms $$\ket{0} \mapsto \ket{+}$$ and $$\ket{1} \mapsto \ket{-}$$, and transforms all linear combinations of $$\ket{0}$$ and $$\ket{1}$$ linearly. If you want to describe the effect of the Hadamard gate on the standard basis — describing its matrix, but symbolically, so that you can actually carry out symbolic analysis — then you might then want to write something like $$H \;=\; \frac{1}{\sqrt 2}\sum_{x,y \in \{0,1\}} (-1)^{xy} \,\ket{y}\bra{x}.$$ Admittedly this is not often very important specifically for a single Hadamard matrix, though a representation like this may well prove useful if you want to reason about performing a Hadamard on many qubits at once, $$H^{\otimes n} \;=\; \frac{1}{\sqrt{2^n}} \sum_{k,z \in \{0,1\}^n} (-1)^{k\cdot z}\,\ket{k_1 k_2 \cdots k_n}\bra{z_1 z_2 \cdots z_n} ,$$ or to describe the quantum Fourier transform with respect to the integers modulo $$M$$ for some integer $$M$$: \begin{align} F_{M} \,=\, \frac{1}{\sqrt M} \sum_{x,y \in \mathbb Z_M} \mathrm e^{2\pi i x y\!\:/\!\:M} \end{align} \ket{y}\bra{x}. It is sometimes useful to describe projectors using outer products as well: for example, the operator which projects states onto the $$\ket{+}$$ states would be written simply as $$\ket{+}\bra{+}$$.

The outer product is just a mathematical tool to write matrices, and therefore quantum operations and states. It is "useful" in the same sense that matrices, or more generally linear algebra, are "useful" in quantum mechanics. It is the mathematical formalism in which QM is formulated. Given the above, I don't think it is particularly meaningful to talk of its utility for quantum algorithm.

In other words, I feel like the question is akin to asking "what is a use of linear algebra in a quantum algorithm?", and the answer is: it is the language in which QM is formulated, so it can never be not useful.

Note that this is a bit different than asking about inner products. The inner product between two vectors is a well-defined operation between sets of numbers, which makes meaningful to talk of a quantum algorithm performing this operation. On the other hand, the outer product is (roughly speaking) only a way to denote matrix elements. There is nothing to compute here.