# Tips and tricks for constructing circuits to generate arbitrary quantum states

I see a question quite a lot in past exam papers that goes like propose a quantum circuit that generates the state $$|\psi \rangle$$ given the initial state $$|\phi\rangle$$

Here's an example:

Given the initial state $$|000 \rangle$$ propose a quantum circuit that generates the state

$$|\psi \rangle=\tfrac{1}{\sqrt{2}} (|+++ \rangle - |--- \rangle)$$

Where $$|\pm \rangle=(|0 \rangle \pm |1\rangle)/\sqrt{2}$$

Now there's a square root of 2 involved so one would imagine a Hadamard gate is involved, but other than that I don't really see how you could just know the circuit apart from trial and error.

Are there any tips and tricks for making circuits that generate states given some initial state?

## 3 Answers

For the single qubit case, we can consider the circuit/operation/mapping as a rotation on the Bloch sphere, so just use the form $$R_y(\theta_1)R_z(\theta_2)R_y(\theta_3)$$ or any other similar stuff and try to get a set of $$\{\theta\}$$ to satisfy the requirements.

However, multiple qubits could be much more difficult. Take two-qubit computation, for example, you could find the decomposition is very complex if only real gates are allowed (look at this paper).

So if you don't need the exact operation giving the exact output, I would recommend quantum circuit learning.

As an exam question, you're unlikely to be asked to produce some entirely arbitrary state (I guess). What you want to do is try and spot similarities to things you already know how to produce. On particularly useful strategy to think about here is a change of basis - it's a very cheap way to disguise something you know about as something else.

In this instance, have you seen the GHZ state before? Does it look kind of similar in structure? What is the difference and how do you build that into a circuit?

Once you've got a circuit that works, take a moment to see if there are any obvious simplifications you can make.

To answer my own question after all this time …… The circuit $$(H_1 \otimes H_2\otimes H_3)(I \otimes Z_2\otimes I)(I \otimes CNOT_{32})(CNOT_{21}\otimes I)(I \otimes H_2\otimes I)|000>$$ accomplishes the task , the reason being that we know we want a square root two out at the front hence the first Hadamard, it also allows us to begin building $$|111>$$ we finish of building that with the $$CNOT$$ gates then we want to change the sign so we apply a phase gate and finally three hadamards to get $$|+++>,|--->$$ from $$|000>,|111>$$.

• Just to point out, this is just the X-basis representation of a phased GHZ state. So if you know how to prepare $|000\rangle \pm |111\rangle$ (a very common state preparation circuit!) then you can just Hadamard into the X-basis – forky40 Aug 8 '19 at 17:44