This post is inspired by the beautiful solution of the problem by Niel de Beaudrap and it shows how to implement it in Quirk.
What we’re trying to achieve is the following:
Niel de Beaudrap shows in this post how to decompose the target state, which I will recapitulate in my own words.
We can decompose the target state by using the plus state which looks like this
So (1) can be rewritten as
If we keep in mind that the plus state can be implemented by applying a Hadamard gate on the zero state
we can conclude, that the first qubit can be seen as control qubit for applying a Hadamard gate to the second qubit, if the first qubit is in the zero state and leave the second qubit untouched if the first qubit is in the one state.
So the circuit will do the following on both qubits initially prepared in zero state:
- bring the first qubit in the following state
- apply a Hadamard gate to the second qubit if the first qubit is in zero state
In Quirk this looks like this:
I used a custom gate to prepare the first qubit in the superposition (5). The question arises how to find the matrix elements for the custom gate in Quirk.
The transformation in (5) can be written like this
We’re looking for a unitary operator U which fulfills
Ok, let’s find the elements of U
It’s quite obvious that U must look like this
To find the elements u12 and u22, we use the fact that unitary operations have this property
When you multiply out (12), you end up with this