Skip to main content
Share Your Experience: Take the 2024 Developer Survey
6 votes
Accepted

How to get QASM code from an Amazon Braket circuit in Python?

You can get OpenQASM output from Braket circuits by using the following code: ...
Milan-aws's user avatar
6 votes
Accepted

Can I postpone a Pauli gate $X$ over a conditioned measurement $Y$ or $X$?

A trick you can use in this situation is "control splitting". Replace "do X" with "do X if C; also do X if not C". Do this: Now you can advance each case individually. ...
Craig Gidney's user avatar
  • 37.5k
5 votes
Accepted

How to come up with Simon's Algorithm circuit for this 3 qubit system? (given truth table & s)

I'm not saying this is a good way of doing it, but if you're completely stumped, there is always a fallback: use a multi-controlled-not. For example, if you use controlled-controlled-controlled-not, ...
DaftWullie's user avatar
  • 58.7k
5 votes
Accepted

Controlled NOT gate which flips target when at least one of the control qubits is |1>

Use De Morgan's law to turn intersection into union.
Craig Gidney's user avatar
  • 37.5k
5 votes
Accepted

What is the "additive error" of Swap Test?

Additive error $\epsilon$ means that, if the true value of the expectation value we are attempting to measure is $\langle \hat{O} \rangle_{\textrm{True}}$, then our estimate $\langle \hat{O} \rangle_{\...
bm442's user avatar
  • 1,127
5 votes
Accepted

Qiskit reverse_bits is not equivalent to swapping qubits

The issue is that the qubit values are being mixed together throughout the circuit, so swapping at the end is not enough. However, if you also swap at the beginning of the circuit, the qubit values ...
Nick Mertes's user avatar
5 votes
Accepted

How to construct a quantum circuit for quantum Fourier transform in a prime dimensional Hilbert space?

This is covered in the paper "Exact quantum Fourier transforms and discrete logarithm algorithms": We show how the quantum fast Fourier transform (QFFT) can be made exact for arbitrary ...
Craig Gidney's user avatar
  • 37.5k
4 votes

How to get QASM code from an Amazon Braket circuit in Python?

Amazon Braket does not have native support for converting circuits to OpenQASM 2. So besides implementing your own Python script, there's not currently a way to do this that does not involve going ...
ryanhill1's user avatar
  • 2,503
4 votes
Accepted

Can any matrix be translated into a quantum circuit?

It depends on what you mean by "translated". Let's say you're given a matrix $A$ and an input state $|\psi\rangle$. I imagine that what you'd be seeking is the ability to produce a state $A|\...
DaftWullie's user avatar
  • 58.7k
4 votes

Can you decompose a 4-qubit Toffoli gate (CCCX) into basic gates without an ancillary state?

The seminal paper Barenco et al., Elementary gates for quantum computation is a great resource for decompositions of many quantum gates, including multi-control Toffoli gates, into elementary gates. (...
Norbert Schuch's user avatar
4 votes
Accepted

Where do I create my first circuit?

Google colab is one good option. You will need to install Qiskit module(s) at the beginning, then you are ready:
Egretta.Thula's user avatar
3 votes
Accepted

How do we measure the probability of outcomes in a quantum computer if qubits collapse when measured?

Do we have to repeat the whole process of the circuit 1000 times? Yes, the idea of (many) quantum circuits is that they produce the desired output with some probability, and thus to ensure the success ...
glS's user avatar
  • 25.3k
3 votes

How to read the result of this HHL algorithm circuit output?

One of your challenges is that you're only doing phase estimation over two qubits. Basically, this means you're trying to get a 2-bit approximation to the eigenvalues of $e^{i\pi A/2}$, i.e. ...
DaftWullie's user avatar
  • 58.7k
3 votes

How to convert a simple matrix into circuit?

In qiskit, you can run the following code: ...
Saksham's user avatar
  • 47
3 votes

How do I prove these gate identities?

For (a), and in accordance with the hint: With controls = 00, the target qubit is not operated on (because all the gates have their controls set to 0 and so they do not affect the target). With ...
Quantum Brilliance's user avatar
3 votes
Accepted

Computing the evolution of expectation values of the Pauli observable

$\langle X\rangle=\text{Tr}(X\rho)$. So, if we update by a single qubit unitary, $\rho\mapsto U\rho U^\dagger$, we have that $$ \langle X\rangle\mapsto \text{Tr}(XU\rho U^\dagger)=\text{Tr}(U^\dagger ...
DaftWullie's user avatar
  • 58.7k
3 votes

Quantum circuits, quantum Turing machine and universal quantum computer-comparing different models of quantum computations

A quantum computer (or quantum Turing machine or quantum circuit) cannot solve any problem that a classical computer could not, because one can simulate the other Initially in a comment I had ...
Mark Spinelli's user avatar
3 votes

How to apply rotation about X and Z in stim?

See Gates supported by Stim in stim's doc/ directory. Stim only supports stabilizer gates, so it can't rotate by 2 radians around the Z axis like you are doing in your circuit. The closest would be ...
Craig Gidney's user avatar
  • 37.5k
3 votes
Accepted

How to interpret the circuit that measures stabilizers in the 5-qubit error correcting code

The circuit image from wikipedia is quite mangled, and I am not quite sure if correct. Here is a nicely laid out syndrome measurement circuit for the $[[5,1,3]]$ code. Here, the top five qubits are ...
Abdullah Khalid's user avatar
3 votes
Accepted

Is the full quantum circuit always in a pure state?

Yes. If you prepare a state, say $|0\rangle ^{\otimes n}$ (or any pure state in general) and only perform quantum gates (which are unitary operations) and qubits are perfectly isolated (there are no ...
FDGod's user avatar
  • 2,401
3 votes
Accepted

Equivalence of circuits in measurement-based QC

In step 2, you are doing two measurements, $X$ on qubit 1 and $X$ on qubit 2. To move to step 3, you need to bring these measurements earlier in the circuit, which means updating what they look like ...
DaftWullie's user avatar
  • 58.7k
3 votes

Can any matrix be translated into a quantum circuit?

Not all matrices are allowed in the conventional quantum circuit model. That is, quantum circuits composed of gates correspond to unitary matrices that preserve distances, e.g., matrices $U$ such ...
Mark Spinelli's user avatar
3 votes
Accepted

Understanding how to solve group isomorphism given the state $\sum_{\pi \in S_n} |\pi(G) \rangle$

There are several pretty standard approaches to "solving" graph isomorphism given access to uniform superpositions over all the permutations of particular graphs (untensored with garbage). ...
Mark Spinelli's user avatar
3 votes
Accepted

What is the formula for the matrix representation of a general controlled gate?

Maybe this helps: The general way to construct a controlled unitary operator $U$ with the help of projectors is as follows. The projectors $P_{|0,1\rangle}$ are at the index of the controlling qubit, $...
rhundt's user avatar
  • 1,018
3 votes
Accepted

Why are qubits initialized to $|0\rangle$ in parametrized quantum circuits?

To be able to initialize a quantum computer with some initial state is one of DiVincenzo criteria of quantum computing. To start with all qubits in state $|0\rangle$ seems reasonable, as it is an ...
Martin Vesely's user avatar
3 votes

Where do I create my first circuit?

Once you have the .qasm, you can also upload it to the Classiq platform https://platform.classiq.io/circuit, and then run it on a simulator. To create your .qasm file (qiskit version 1.1) you will ...
relsmoler's user avatar
2 votes

Is there a clear, understandable example of Quantum Circuit Cutting I can use to understand the process?

Circuit Knitting Toolbox is a Qiskit extension for entanglement forging, circuit cutting, and classical embedding. One of its modules is cutqc which implements the ...
Egretta.Thula's user avatar
2 votes

Avoiding garbage amplitudes in block-encoding

If I understand your question correctly, you're right, there always will be 'garbage' after you act with a block-encoded matrix. Equivalently, block encoding only performs the transformation you need ...
Nikita Nemkov's user avatar
2 votes
Accepted

Finding the Clifford circuit that implement a particular mapping of Paulis strings

You can convert a stabilizer tableau (a Pauli observable mapping) into a circuit by transforming the tableau into the identity tableau and keeping track of the steps you used. Basically, it's the same ...
Craig Gidney's user avatar
  • 37.5k
2 votes

Trying to understand a quantum adder

The correct way to interpret the number is using a compiler that follows the qubit mapping. You can see how it is done in Classiq, for example, by running examples from the arithmetic library To your ...
Ron Cohen's user avatar
  • 1,402

Only top scored, non community-wiki answers of a minimum length are eligible