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

Quantum circuit not showing when using qiskit with pycharm

By default, qiskit draws the quantum circuit for inline visualization (because inline figures are typlically used with jupyter lab). To fix this issue, you need to ...
Shravan Patel's user avatar
4 votes
Accepted

weird negative sign in a state vector in qiskit

We start with the state, $$\sqrt{1/3}|001\rangle + \sqrt{2/3}|111\rangle$$ Then apply $R_y(\pi/2)$ to the first qubit controlled by the second qubit. By linearity, we can calculate the impact of ...
Egretta.Thula's user avatar
4 votes
Accepted

Should I Stick to an Older Version of Qiskit Due to Tutorial Compatibility Issues?

You should learn the newer qiskit>=1.0.0 version because this newer version is released with emphasis on: High-performance code base: ...
Shravan Patel's user avatar
3 votes
Accepted

Relation between Rz gate and Phase gate

The $RZ(\theta)$ gate is defined by: $$RZ(\theta)=\begin{pmatrix}\mathrm{e}^{-\mathrm{i}\frac\theta2}&0\\0&\mathrm{e}^{\mathrm{i}\frac\theta2}\end{pmatrix}=\mathrm{e}^{-\mathrm{i}\frac\theta2}\...
Tristan Nemoz's user avatar
  • 6,462
3 votes
Accepted

Is there a qiskit method to obtain the generator (ie. Pauli operator) of a gate?

In general, multiple Hamiltonians can generate the same unitary. A simple way to get a Hamiltonian is to take the logarithm of the unitary matrix using ...
Egretta.Thula's user avatar
2 votes

Error while plotting the resulting distribution

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. Here's how to do this step by step: Step 1: Create and save ...
Amir Naveh's user avatar
2 votes

Help debugging implementation of Draper QFT adder

You can take a look at how to create an adder whether it is a QFT or a ripple-carry, using the answer here You also need a compiler that interprets the order of the qubits correctly; you can see how ...
Ron Cohen's user avatar
  • 1,432
2 votes

Does subtraction circuit have a class like full or half Carry adder circuit in qiskit? one subtraction circuit code-example in qiskit?

For subtraction as mentioned earlier you have to negate the number, and than use an adder. There are few possible implementations for that (adder can be with QFT or with ripple-carry adder with more ...
Ron Cohen's user avatar
  • 1,432
2 votes

How to learn about quantum computing and qiskit

I believe https://learning.quantum.ibm.com/ is a wonderful starting point for Qiskit and Quantum Information. I also recommend https://quantum.country/ which is more about the theory than the coding ...
Balint Pato's user avatar
  • 1,053
2 votes
Accepted

How is the controlled-n NOT gate represented in Qiskit?

For multi-controlled X gate, use Qiskit's class MCXGate which can be added to your circuit as follows: circ.mcx(range(7), 7)
Egretta.Thula's user avatar
2 votes
Accepted

IBM quantum computer backend cycle time and real gate duration

The integers in the InstructionDurations() are the multipliers of the real-system timestep dt. So for example, consider the ...
Shravan Patel's user avatar
2 votes

How to read QASM files for parametrized circuits (in QISKIT)? both from_qasm_file() and from_qasm_str() fail

You can use qiskit-qasm3-import library Once you have the QASM3 program, use : from qiskit_qasm3_import import parse And than ...
Amir Naveh's user avatar
2 votes

Where to find a generic implementation of Shor's algorithm with Qiskit?

You can use Shor's algorithm in Classiq QMOD library (if you want the qiskit version, you can convert the Classiq generated circuit to qasm). You can do this in one of 2 ways: With Native QMOD ...
Ron Cohen's user avatar
  • 1,432
2 votes

Where to find a generic implementation of Shor's algorithm with Qiskit?

The author of this site implements this paper. The implementation's generic. I hope this helps.
taketoshi kinoshita's user avatar
2 votes

Where to find a generic implementation of Shor's algorithm with Qiskit?

You can use the Shor's algorithm which was deprecated from qiskit.algorithms as the starting point and modify it to work with ...
Shravan Patel's user avatar
2 votes
Accepted

How to compose a larger circuit onto a smaller circuit in Qiskit, adding extra quantum registers to some fixed list

If you already know how many ancillas are needed for each subcircuit, just add to your circuit ancillas enough to support the subcircuit with maximum number of ancillas, then pass a subset of these ...
Egretta.Thula's user avatar
2 votes
Accepted

What is an introductory book or resource for qiskit?

I would suggest you start learning about the basics of quantum information and quantum circuits. These lessons also introduce basic qiskit programs. Then after this go through the next chapter on ...
Shravan Patel's user avatar
2 votes

How to convert a combinatorial optimization problem into a problem hamiltonian

This video tutorial is a very good starting point to the subject. Then you can go through the paper "Ising formulations of many NP problems" by Lucas for more advanced mappings.
Egretta.Thula's user avatar
2 votes

Why is the Choi matrix different from the analytic form for a depolarizing channel?

Your definition of the depolarizing channel is slightly off, it should read $$ \mathcal E(\rho)=(1-p)\rho+p\,\boxed{{\rm tr}(\rho)}\frac I2\,. $$ This extra term ${\rm tr}(\rho)$ is necessary for $\...
Frederik vom Ende's user avatar
2 votes
Accepted

doesn't a reset on an entangled qubit collapse a superposition?

In IBM quantum devices, reset instruction is implemented as a mid-circuit measurement followed by a conditional Pauli-X (see here). That means, your circuit is equivalent to the below circuit: This ...
Egretta.Thula's user avatar
2 votes

Solving quantum equation using qiskit

TLDR Yes, you are basically on the right track to calculate $A$. But there are some adjustments to make on how you model $U$. This is also where qiskit can be of help with the ...
qubitzer's user avatar
  • 187
1 vote
Accepted

Why circuit in Shor algorithm differs for different factorized numbers?

Shor's algorithm is indeed fascinating, but its implementation can vary based on the number you're trying to factorize. The main reason for this variation is the choice of parameters in the algorithm, ...
Shravan Patel's user avatar
1 vote
Accepted

Error when using crx gate in quantum circuit

You are getting unknown instruction error because qasm_simulator does not have crx gate in ...
Shravan Patel's user avatar
1 vote

Qiskit: Evolve TrotterQRTE from Operator

You can use SparsePauliOp.from_operator() method to construct a SparsePauliOp from an ...
Egretta.Thula's user avatar
1 vote

Easiest hash function to implement on Qiskit

I wrote an example hash function in the documentation of the qlasskit library; the result is directly exportable to qiskit, so it may be the answer for your question: https://dakk.github.io/qlasskit/...
Davide Gessa's user avatar
1 vote

How can I implement an n-bit Toffoli gate?

You can use MCXGate: def toffoli_general(qr, control, target): qr.append(MCXGate(num_ctrl_qubits=len(control)), control + [target]) With for example ...
antomax33's user avatar
1 vote

Solving optimization problems on real quantum hardware

Current quantum hardware based on a quantum circuit model has a limited number of qubits, which are prone to errors and decoherence. So, comparing solutions from classical solvers with those produced ...
MonteNero's user avatar
  • 2,646
1 vote

How to perform noisy simulation of qiskit fake backends?

The fake backends in qiskit are built to mimic the behaviors of IBM Quantum systems using system snapshots. This system snapshots (or fake backends) contain ...
Shravan Patel's user avatar
1 vote

How to perform noisy simulation of qiskit fake backends?

Qiskit fake backends can be used directly for noisy simulations. For example: ...
Egretta.Thula's user avatar
1 vote
Accepted

QisKit Matrix Exponential VQC

I think EvolvedOperatorAnsatz is a good option. It accepts a list of operators and an evolution synthesis and constructs a parametrized quantum circuit: ...
Egretta.Thula's user avatar

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