# How to create superposition of states with fixed parity with a quantum circuit?

I'm searching for a circuit to generate, starting from the $$|00\, ...\,0\rangle$$ state, an arbitrary superposition of all states with either even or odd parity. The gate choice is irrelevant for now, but sticking with single qubit gates and controlled rotations would be preferrable.

For example, for 3 qubits, I want to be able to generate the states $$|\mathrm{odd}\rangle = a|001\rangle + b|010\rangle + c |100\rangle + d|111\rangle$$ and $$|\mathrm{even}\rangle = a|000\rangle + b|011\rangle + c |101\rangle + d|110\rangle$$ where $$a,b,c,d$$ are freely chosen complex values satisfying the condition of normalization.

• Are $a,b,c,d$ complex parameters that you will specify, or can they be freely chosen? For example, there's a very nice circuit if you have $a=b=c=d$. Dec 3, 2021 at 7:28
• @DaftWullie The parameters should be able to be completely freely chosen. I found a solution to my problem (see post below), but it doesn't allow for every single possible state. Dec 3, 2021 at 10:05
• This was part of my confusion as I could see that. Perhaps you should add that qualifying remark to your solution. Dec 3, 2021 at 10:07

I actually found the solution to my problem - with one caveat: the amplitudes $$a,b,c,d$$ can not be completely arbitrary. An $$n$$-qubit superposition state with even parity will have $$2^{n-1}-1$$ free parameters, while the approach presented below only allows for $$2(n-1)$$ parameters. This still solves my problem though, so I will share the approach anyways:

Given $$n$$ qubits initialized as $$|0\rangle$$, one can act with $$R_y(\alpha_i)$$ and $$R_z(\beta_i)$$ on all qubits $$i$$, excluding one of them (for me this will be the last one). This will put every qubit in an arbitrary superposition state $$a|0\rangle + b|1\rangle$$.

Then one just needs to apply $$n-1$$ CNOT gates with control qubits being the first $$n-1$$ qubits and the qubit acted upon being the last qubit (rotation angles are random):

This yields a superposition of all states with even parity. For odd parity, one can start with the last qubit in the $$|1\rangle$$ state.

If you want all amplitudes to be the same, replace the rotation gates with Hadamard gates.

To do this in general is equivalent to creating an arbitrary $$n-1$$-qubit state, and then using the pattern of controlled-nots to determine the bit value of the final qubit, as you did in your solution.

Creating an arbitrary $$n$$ qubit state is a standard, well-studied, but complex task which I'm not going to elaborate on here. You might look, for example, at this question and answer.