Qiskit is an open source SDK for working with quantum computers at the level of pulses, circuits and application modules. If appropriate, also use the [programming] tag. Please include the version of Qiskit you use when using this tag.
Questions tagged [qiskit]
2575 questions
34
votes
6 answers
How do I build a gate from a matrix on Qiskit?
I'm creating a gate for a project and need to test if it has the same results as the original circuit in a simulator, how do I build this gate on Qiskit? It's a 3 qubit gate, 8x8 matrix:
$$
\frac{1}{2}
\begin{bmatrix}
1 & 0 & 1 & 0 & 0 & 1 & 0 & -1…
Nillmer
- 785
- 1
- 5
- 13
30
votes
5 answers
How can I implement an n-bit Toffoli gate?
I want to create a Toffoli gate controlled by n qubits, and implement it in QISKit. Can this be done? If so, how?
Ali Javadi
- 1,652
- 1
- 9
- 11
24
votes
2 answers
What is a "barrier" in Qiskit circuits?
I just started studying IBM Qiskit, and cannot find details about the barrier method on the QuantumCircuit class. It is shown in the circuit drawing, but I never heard about it after reading quantum computing text books. Is it a unitary gate? If so,…
czwang
- 949
- 1
- 6
- 17
20
votes
1 answer
What's meant by the depth of a quantum circuit?
I'm using Qiskit to create quantum circuits wherein I've this attribute called depth. The documentation states it is the length of the critical path here. What does it represent and how to find it out manually?
Van Peer
- 617
- 1
- 6
- 15
20
votes
1 answer
How to measure in another basis
I am new to qiskit and I have to simulate a quantum circuit. I read this documentation https://qiskit.org/textbook/ch-states/single-qubit-gates.html where it is left as an exercise to the reader to write a function to measure in the $|+i\rangle$ and…
thedumbkid
- 329
- 1
- 2
- 11
15
votes
3 answers
How to calculate an Expected Value of some operator acting on qubits?
I'm trying to implement the Variational Quantum Eigensolver in Qiskit.
Suppose, I have an operator $A = \sigma_1^z\sigma_2^z$ acting on some two-qubit state $|\psi\rangle$. After a measurement I get a set of probabilities corresponding to states…
C-Roux
- 928
- 2
- 9
- 20
15
votes
4 answers
How is the Grover-Algorithm applied to a database?
Question
I want to use the Grover-Algorithm to search an unsorted database for an element $x$. Now the question arises, how do I initialize index and value of the database with the qubits?
Example
Let's say I have $4$ qubits. Thus, $2 ^ 4 = 16$…
alex
- 151
- 5
12
votes
3 answers
Big Endian vs. Little Endian in Qiskit
I've noticed that Q# favors Little Endian. Meaning that most operations are designed for this type of encoding.
Is is it the same with Qiskit?
Sorin Bolos
- 621
- 5
- 11
12
votes
4 answers
How to quickly calculate the custom U3 gate parameters $\theta, \phi$ and $\lambda$ for any unitary?
In IBM Qiskit and Quantum Experience, the custom U3 gate is defined as
$$
U(\theta, \phi, \lambda) =
\begin{pmatrix}
\cos\left(\frac{\theta}{2}\right) & -e^{i\lambda} \sin\left(\frac{\theta}{2}\right) \\
e^{i\phi}…
Sanchayan Dutta
- 17,945
- 8
- 50
- 112
12
votes
1 answer
How many qubits would be needed to do boson sampling in Qiskit?
In December 2020, there was this claim of quantum advantage/supremacy by a team of UST China using Gaussian boson sampling. Here is the paper and here is an explanatory news article in Nature. To get an idea of how that works, I wanted to try to…
Mauricio
- 2,426
- 4
- 25
12
votes
1 answer
Evaluating expectation values of operators in Qiskit
I'm wondering how in Qiskit one can calculate the expectation value of an operator given as a WeightedPauli (or, at least, of a single Pauli operator...) in a certain state (given as a QuantumCircuit object — meaning that the actual state is the…
mavzolej
- 2,271
- 9
- 18
12
votes
2 answers
Qiskit - Z expectation value from counts?
For a given state $|\psi\rangle$, how would I work out $\langle\psi|Z|\psi\rangle$ ?
If I run a quantum circuit and get the counts dictionary on qiskit, I get observables in the Z basis.
For n=1 qubits, the basis states returned are $|0\rangle$ &…
Zohim Chandani
- 121
- 1
- 5
11
votes
1 answer
Is it possible to run a general implementation Shor's algorithm on a real IBM quantum computer at least for N = 15?
I need to make a general implementation of Shor's algorithm that factors, at least, N = 15. I have been able to perform an implementation that works in simulators, with ProjectQ, but when running it on a real quantum computer.
I have decided to try…
WaSon
- 111
- 4
11
votes
2 answers
Submitting jobs to IBMQ backend via HTTP API Requests
Qiskit can be used to submit jobs to IBM devices using Python (or Swift and JavaScript). But what if I want to use a different language?
For example, suppose I have a specific circuit I want to run. Assume I've already created it in Python Qiskit,…
James Wootton
- 11,700
- 1
- 35
- 74
11
votes
2 answers
Composing multiple quantum circuits in single quantum program in Qiskit
I was wondering if there is a way to compose a program with multiple quantum circuits without having the register reinitialized at $0$ for each circuit.
Specifically, I would like run a second quantum circuit after running the first one, as in this…
asdf
- 503
- 3
- 15