Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

For questions regarding usage, performance, implementation, application or theory related to quantum gates

5
votes
3answers
106 views

What does it mean for a quantum computer to have $X$ qubits?

I want to preface with a disclaimer that I am a physicist with minimal knowledge of computer hardware. I have a solid understanding of quantum information from a theoretical standpoint but zero ...
6
votes
2answers
92 views

Just want to confirm: Do two CNOT gates cancel each other?

I see somewhere that this happens: But I wonder if this is just identity.
5
votes
3answers
361 views

Advantange of Hadamard gate over rotation about the X axis for creating superpositions

When I look at most circuits (admittedly small sample as I'm a beginner), the Hadamard gate is used a lot to prepare a superposition from say the $\mid0\rangle$ state. But upon a little reflection, we ...
5
votes
2answers
103 views

How do you implement the Toffoli gate using only single-qubit and CNOT gates?

I've been reading through "Quantum Computing: A Gentle Introduction", and I've been struggling with this particular problem. How would you create the circuit diagram, and what kind of reasoning would ...
6
votes
2answers
105 views

Is there a tool that can give you the unitary representing a quantum circuit from just a string?

Say I have a string representing the operations of a quantum circuit. I want to have the unitary operator representing it. Is there a tool for doing so in Python or else?
3
votes
2answers
92 views

How do we code the matrix for a controlled operation knowing the control qubit, the target qubit and the $2\times 2$ unitary?

Having n qubits, I want to have the unitary described a controlled operation. Say for example you get as input a unitary, an index for a controlled qubit and another for a target. How would you code ...
5
votes
2answers
375 views

Incorrectly Calculating Probability Amplitudes for 3-qbit Circuit

I’m trying to calculate the probability amplitudes for this circuit: My Octave code is: ...
6
votes
2answers
312 views

Possibility of a “reset” quantum gate

I wish to have a "reset" gate. This gate would have an effect to bring a qubit to the $\mid0\rangle$ state. Clearly, such a gate is not unitary (and so I'm unable to find any reliable implementation ...
4
votes
2answers
141 views

Shorthand notation for the sign flip gate

I need to use the following matrix gate in a quantum circuit: $$\text{Sign Flip}=\left[\begin{matrix}0 & -1 \\ -1 & 0\end{matrix}\right]$$ $\text{Sign Flip}$ can be decomposed as (in terms ...
4
votes
0answers
64 views

Number of gates required to approximate arbitrary unitaries

If I understand correctly, there must exist unitary operations that can be approximated to a distance $\epsilon$ only by an exponential number of quantum gates and no less. However, by the Solovay-...
6
votes
1answer
318 views

Practical implementation of Hamiltonian Evolution

Following from this question, I tried to look at the cited article in order to simulate and solve that same problem... without success. Mainly, I still fail to understand how the authors managed to ...
8
votes
3answers
164 views

Does conditional gate collapse controller's superposition?

I've created a simple circuit in Q-Kit to understand conditional gates and outputted states on each step: In the beginning there is clear 00 state, which is the input The first qubit is passed ...
5
votes
1answer
55 views

Arbitrary powers of NOT and SWAP

The square-root of not and square-root of swap gates are often singled out for discussion of gates displaying important properties relating to quantum computers. How do I define arbitrary (non-...
6
votes
2answers
143 views

Is it possible to realize CNOT gate in 3 dimension?

CNOT gates have been realized for states living in 2-dimensional spaces (qubits). What about higher-dimensional (qudit) states? Can CNOT gates be defined in such case? In particular, is this possible ...
9
votes
2answers
406 views

CNOT Gate on Entangled Qubits

I was trying to generate Greenberger-Horne-Zeilinger (GHZ) state for $N$ states using quantum computing, starting with $|000...000\rangle$ (N times) The proposed solution is to first apply Hadamard ...
3
votes
1answer
69 views

Doing maths with controlled-half NOTs

In Quantum Computation with the simplest maths possible there is a section titled "Doing maths with a controlled-half NOT" which covers a reversible-(N)AND circuit with controlled-half NOTs. What ...
9
votes
3answers
701 views

Toffoli gate as FANOUT

I was searching for examples of quantum circuits to exercise with Q# programming and I stumbled on this circuit: From: Examples of Quantum Circuit Diagrams - Michal Charemza During my introductory ...
5
votes
0answers
119 views

Error: Simulation of “Quantum algorithm for linear systems of equations” for $4\times 4$ systems on Quirk (without SWAP) - Global phase

Following @DaftWullie's answer I tried to simulate the circuit given in Fig. 4 of the paper (arXiv pre-print): Quantum circuit design for solving linear systems of equations (Cao et al, 2012), on ...
6
votes
1answer
90 views

SWAP gate(s) in the $R(\lambda^{-1})$ step of the HHL circuit for $4\times 4$ systems

Context: On the 5th page of the paper Quantum circuit design for solving linear systems of equations (Cao et al, 2012) there's this circuit: Schematic: A brief schematic of what's actually ...
7
votes
2answers
140 views

Matrix representation of continuous-variable gates

In the introduction to continuous-variable quantum computing by Strawberry Fields (Xanadu), it lists the primary CV gates (rotation, displacement, squeezing, beamsplitter, cubic phase) along with ...
3
votes
1answer
63 views

How the joint state of these qubits is derived?

Can someone show to me the steps to derive the joint state at the bottom of this image, please? I tried to follow his explanation but I didn't get the same results… This is taken from the lecture ...
4
votes
1answer
66 views

Square root of not as a time-dependent unitary matrix

I want to express the square root of NOT as a time-dependent unitary matrix such that each $n$ units of time, the square root of NOT is produced. More precisely, I want to find a $U(t_0,t_1)$ such ...
4
votes
2answers
121 views

What is the matrix of the iSwap gate?

See title. Mostly I'm confused over whether the common convention is to use +$i$ or -$i$ along the anti-diagonal of the middle $2\times 2$ block.
7
votes
3answers
118 views

Why does the “Phase Kickback” mechanism work in the Quantum phase estimation algorithm?

I've probably read the chapter The quantum Fourier transform and its applications from Nielsen and Chuang (10 th anniversary edition) a couple of times before and this took this thing for granted, but ...
5
votes
0answers
74 views

How exactly is the stated composite state of the two registers being produced using the $R_{zz}$ controlled rotations?

This is a sequel to How are two different registers being used as "control"? I found the following quantum circuit given in Fig 5 (page 6) of the same paper i.e. Quantum Circuit Design for ...
4
votes
1answer
94 views

Projection operator on Time evolution Operator

From a 9×9 Hamiltonian lying 9D space, I choose a certain subspace of 4D for designing a two qubit gate. Now the original unitary time evolution operator also lies in 9D space and it's a 9×9 size ...
8
votes
2answers
80 views

How to prove/disprove universality for a set of gates?

A universal set of gates are able to mimic the operation of any other gate type, given enough gates. For example, a universal set of quantum gates are the Hadamard(H), the pi/8 phase shift(T), and the ...
4
votes
1answer
91 views

The general form of unitary operations on a single qubit

I want to understand the relation between the following two ways of deriving a (unitary) matrix that corresponds to the action of a gate on a single qubit: 1) HERE, in IBM's tutorial, they ...
6
votes
2answers
102 views

What are the P(0) and P(1) probabilities for the T transformation in quantum computing?

I'm just starting of on quantum computing, specifically following the IBM Q Experience documentation [1]. In here, they are explaining the following experiment: $T|+\rangle$ The expected outcomes ...
3
votes
1answer
68 views

How are two different registers being used as “control”?

On page 2 of the paper Quantum Circuit Design for Solving Linear Systems of Equations (Cao et al.,2012) there's this circuit: It further says: After the inverse Fourier transform is executed on ...
8
votes
1answer
124 views

How to implement a matrix exponential in a quantum circuit?

Maybe it is a naive question, but I cannot figure out how to actually exponentiate a matrix in a quantum circuit. Assuming to have a generic square matrix A, if I want to obtain its exponential, $e^{A}...
3
votes
2answers
97 views

Components for realizing a photonic CNOT gate

In Realization of a photonic CNOT gate sufficient for quantum computation FIG. 1 there is a "scheme to obtain a photonic realization of a CNOT gate with two independent qubits." What components are ...
5
votes
2answers
107 views

Controlled-U operation in IBMQ

Suppose we have any matrix in $\mathrm U(2)$ and we need to construct a Controlled-$U$ operation with the $H,T,S$ gates. Then I am aware of the construction given in N&C of decomposing $U$ into $e^...
3
votes
1answer
82 views

Nielsen & Chuang Exercise 2.3 - “Matrix representation for operator products”

Reproduced from Exercise 2.3 of Nielsen & Chuang's Quantum Computation and Quantum Information (10th Anniversary Edition): Suppose $A$ is a linear operator from vector space $V$ to vector space ...
5
votes
2answers
149 views

Expressing “Square root of Swap” gate in terms of CNOT

How could a $\sqrt{SWAP}$ circuit be expressed in terms of CNOT gates & single qubit rotations? CNOT & $\sqrt{SWAP}$ Gates Any quantum circuit can be simulated to an arbitrary degree of ...
7
votes
1answer
75 views

One-qubit gates results in QISKit

I found it odd that the result of the action of identity gate (namely a $2\times2$ identity matrix) on a pure state $|0\rangle$ (namely the vector corresponding to the $2\times1$ matrix $\begin{...
3
votes
3answers
65 views

Use of change of phase gates

As explained in this this answer, when we have different (relative) phases between two states, those two states will yield the same probabilities when measured in the same basis but different ...
3
votes
0answers
98 views

Transforming square lattice to hexagonal lattice

What would happen if, in a periodic medium, the oscillation that occupies in it is continuously transformed from a square lattice to a hexagonal or triangular lattice? The only guess would be that ...
2
votes
1answer
122 views

Nielsen & Chuang Exercise 2.2 - “Matrix representations: example”

Reproduced from Exercise 2.2 of Nielsen & Chuang's Quantum Computation and Quantum Information (10th Anniversary Edition): Suppose $V$ is a vector space with basis vectors $|0\rangle$ and $|1\...
8
votes
1answer
288 views

Implementing a CCCNOT gate using only Toffoli gates

A CCCNOT gate is a four-bit reversible gate that flips its fourth bit if and only if the first three bits are all in the state $1$. How would I implement a CCCNOT gate using Toffoli gates? Assume ...
5
votes
2answers
327 views

What are some open sources projects on quantum computing? [duplicate]

I am looking to collaborate on open source simulation efforts.
5
votes
1answer
62 views

How to implement a random selection of one of the 3 qubits on the IBM Q (composer)?

I would like to implement a quantum program on the IBM Composer with following characteristics: The output is the observed value of 3 qubits Only one of the 3 qubits should be observed as $1$, the 2 ...
6
votes
1answer
161 views

Quantum XOR Linked List Construction

After getting help here with XNOR & RCA gates I decided to dive into XOR Swaps & XOR linked lists. I was able to find this explanation for quantum XOR Swapping which seems sufficient for the ...
6
votes
1answer
96 views

Quantum Ripple Carry Adder Construction

There is an excellent answer to How do I add 1+1 using a quantum computer? that shows constructions of the half and full adders. In the answer, there is a source for the QRCA. I have also looked at ...
9
votes
2answers
174 views

Quantum XNOR Gate Construction

Tried asking here first, since a similar question had been asked on that site. Seems more relevant for this site however. It is my current understanding that a quantum XOR gate is the CNOT gate. Is ...
11
votes
1answer
633 views

How to interpret a quantum circuit as a matrix?

If a circuit takes more than one qubit as its input and has quantum gates which take different numbers of qubits as their input, how would we interpret this circuit as a matrix? Here is a toy example:...
6
votes
2answers
166 views

How to prove that Z operator rotates points on Bloch sphere about Z axis through 180°?

My idea was to apply $Z$ operator 𝐭𝐰𝐢𝐜𝐞, which leads us back to the point where we started from, and also show that after applying the $Z$ operator just 𝐨𝐧𝐜𝐞 we are not at the same point ...
6
votes
1answer
86 views

How to apply single and two qubit gates to 2 qubits multiple times?

Let's say we have the following quantum circuit: Let's say we input the state $|00\rangle$ . Both of the $H$ gates produce the output $1/\sqrt{2}$, but which one of the following $2$ vectors is the ...
7
votes
2answers
624 views

How to input 2 qubits in 2 Hadamard gates?

Let's say we have a circuit with $2$ Hadamard gates: Let's take the $|00\rangle$ state as input. The vector representation of $|00\rangle$ state is $[1 \ 0 \ 0 \ 0]$, but this is the representation ...
6
votes
1answer
87 views

How to implement a Square root of Swap gate that swaps 2n-qubits on the IBM Q (composer)?

I am looking for an implementation using the quantum gates provided by the IBM composer of the following quantum function: input $2n$ qubits output $2n$ qubits wherein $50\%$ of the cases the state ...