# Measuring overlap of two quantum states

I have a qubit state $$|\psi\rangle = a|0\rangle + b|1\rangle$$, and another qubit state $$|\psi'\rangle = a'|0\rangle + b'| 1 \rangle$$. I want, through quantum gates, to measure the overlap $$|\langle \psi | \psi'\rangle|^2$$ which is given by a projective measurement $$\text{tr}\left[|\psi\rangle\langle \psi||\psi'\rangle\langle\psi'|\right]$$. I want to know how to implement this measurement using quantum gates. Also, how would one generalise the measurement to a multi qubit state?

• Quantum gates are necessarily reversible, and measurements are not - so this would not be possible. Mar 23, 2020 at 12:37
• @MahathiVempati what I mean is how to introduce ancillary qubits or how to control the two qubit states to produce a new state that can be measured, and from which the overlap $|aa'+bb'|^2$ can be deduced. Mar 23, 2020 at 14:08

The basic idea is the following: First, the overlap $$\omega=\mathrm{tr}[\rho\sigma]$$ of two quantum states (e.g. the pure states in your question) is equal to $$\omega=\mathrm{tr}[(\rho\otimes\sigma)\mathbb F]\ ,$$ with $$\mathbb F$$ the SWAP gate.
On the other hand, the expectation value of any unitary gate $$U$$ in a state $$\rho$$, $$\mathrm{tr}[\rho U]$$, can be estimated using phase estimation. The simplest version is to apply a controlled-U gate, where the control qubit is initialized in $$|+\rangle$$ and subsequently measured in the $$|\pm\rangle$$ basis. It is an easy exercise to see that the probabilities of the two measurement outcomes are directly related to $$\omega$$.