# How to build a quantum circuit to generate an equal superposition of 3 outcomes for 2 qubits?

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:

(1)

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

(2)

So (1) can be rewritten as

(3)

If we keep in mind that the plus state can be implemented by applying a Hadamard gate on the zero state

(4)

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

(5)

- 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

(6)

where

(7)

We’re looking for a unitary operator U which fulfills

(8)

Ok, let’s find the elements of U

(9)

It’s quite obvious that U must look like this

(10)

To find the elements u12 and u22, we use the fact that unitary operations have this property

(11)

which means

(12)

When you multiply out (12), you end up with this

(13)

(14)

This gives

(15)

(16)

(17)