Quantum Circuit

Abhishek Dubey
5 min readApr 27, 2020

--

Let’s get started & make some cool quantum circuits which we would be using for our first Quantum Algorithm later.

Before we start getting into actual useful circuits, lets first understand few basic things about Circuit representations. The most important thing for any Quantum circuit is the Pure Quantum state ( superposition) and the way to prepare such a state (qubit system), is by applying the Hadamard gate, represented by H. So let’s first draw the circuit for preparing the quantum 2 qubit state,|ψ⟩, and understand what each step means.

|ψ⟩ = 1/2 |00⟩ — 1/2 |01⟩ + 1/2 |10⟩ — 1/2 |11⟩

Putting Quantum Register into Superposition

The above simple circuit generates |ψ⟩ from simple qubits q0 =|0⟩
& q1 =|0⟩, which are not in superposition.
Now to understand what actually happened above, let’s expand above circuit to the table below

Note: Any quantum state of qubits at any point, can be described by the state of the individual qubits or the combines state of all the qubits, which is represented by the tensor product of individual qubits.

Now if the above table is not sufficient for you, lets expand the above explanation even further.

Now we are ready to make our first useful circuit, so let’s begin:

We would make 4 quantum circuits here, which all perform almost the same task but they differ in the actual output. The task these circuits would perform is “negating/ flipping” the amplitude of the selected computational basis vector.

Note: If you think these are silly circuits, please bear with me, as these would become one of the key circuits when we implement our first Quantum algorithm.

Selector Circuit 1:
For any 2 qubit state,|ψ⟩, negate/ flip the amplitude of the basis vector|11⟩

Circuit(|ψ⟩) |ω⟩, where,
|ψ⟩ = α|00⟩ + β|01⟩ + γ|10⟩ + δ|11⟩ &
|ω⟩ = α|00⟩ + β|01⟩ + γ|10⟩ δ|11⟩

So before we make a circuit, let first figure out the operation need for the same, before you read below, can you figure out which gate we would need for this?

Hint: You read about this gate in the previous post

So we would use controlled Z, CZ, Gate for this:
CZ |ψ⟩ = α CZ|00⟩ + β CZ|01⟩ + γ CZ|10⟩ + δ CZ|11⟩
= α|00⟩ + β|01⟩ + γ|10⟩ — δ|11⟩ ≡ |ω⟩

Done! Let’s draw your our first circuit:

Circuit: CZ Gate

The above circuit solved the problem which we had, but we can further extend the above circuit for even the preparation of one sample input state of our generic |ψ⟩. This is already something we saw at the top of this blog, so let’s complete this circuit end to end, outside our main problem as well.

For the circuit below,

|ϕ⟩ = q0 ⊗ q1
where q0, q1 ∈ {|0⟩, |1⟩} and depending on values of q0, q1 from |0⟩ or |1⟩, |ψ⟩ would be in below states.
|ψ⟩ = ∓1/2 |00⟩ ∓ 1/2 |01⟩ ∓ 1/2 |10⟩ ∓ 1/2 |11⟩,
is particular instance of generic |ψ⟩ from the problem statement, where all coefficient are 1/2 and their sign (+ or — ) would depend on the initial state of the individual qubits.

Note: |x⟩, |y⟩ in above figure are simple qubit (which are not in superposition) and can be either |0⟩ or |1⟩.

Lets understand the above circuit better for all possible initialization of q0 & q1. Check how CZ gate above makes it possible for achieving our goal irrespective of the initialization.

This was simple, now lets make 2nd circuit

Selector Circuit 2:
For any 2 qubit state,|ψ⟩, negate the amplitude of the basis vector|00⟩

Circuit(|ψ⟩) |ω⟩, where,
|ψ⟩ = α|00⟩ + β|01⟩ + γ|10⟩ + δ|11⟩ &
|ω⟩ = α|00⟩ + β|01⟩ + γ|10⟩ + δ|11⟩

Again Let’s first write the equation for the circuit above

NOT(CZ(NOT(|ψ⟩)))
= NOT(CZ(NOT(α|00⟩ + β|01⟩ + γ|10⟩ + δ|11⟩)))
= NOT(CZ(α|11⟩ + β|10⟩ + γ|01⟩ + δ|00⟩))
= NOT(- α|11⟩ + β|10⟩ + γ|01⟩ + δ|00⟩)
= - α|11⟩ + β|10⟩ + γ|01⟩ + δ|00⟩ ≡ |ω⟩

Again for completing the circuit, we can add the circuit to even generate one particular instance of |ψ⟩

Similarly you can try to make circuit for negating remaining vectors. If you are not able to to that, do not worry, we would make them when we study our first quantum algorithm, again with above circuits.

Reflection Circuit 1:
For any 2 qubit state,|ψ⟩, negate the amplitude of all the basis vector except|00⟩

Circuit(|ψ⟩) |ω⟩, where,
|ψ⟩ = α|00⟩ + β|01⟩ + γ|10⟩ + δ|11⟩ &
|ω⟩ = α|00⟩ β|01⟩ γ|10⟩ δ|11⟩

Note: If Zq0 is applying Z gate on only q0 qubit & similar Zq1 is applying Z gate on only q1 qubit. If you are not sure what Z Gate is please refer the post just before this post.

CZ(Zq1(Zq0(|ψ⟩)))
= CZ(Zq1(Zq0(α|00⟩ + β|01⟩ + γ|10⟩ + δ|11⟩)))
= CZ(Zq1(α|00⟩ — β|01⟩ + γ|10⟩ — δ|11⟩))
= CZ(α|00⟩ — β|01⟩ — γ|10⟩ +δ|11⟩)
= α|11⟩ — β|10⟩ — γ|01⟩ — δ|00⟩ ≡ |ω⟩

Like above, lets add the gate to even generate the input state, |ψ⟩

That’s it this is sufficient for us to learn our First Quantum Algorithm called Gover’s Search Algorithm.

This post is 4th part of the “Quantum Computing 101” Series, check the next post of this series, Basic Quantum Search Algorithm.

--

--