# Questions tagged [programming]

For any questions whose answer is expected to require code or programming notions. For questions about a specific framework (e.g. qiskit or cirq) please also include a more specific tag. If your question is about installation or any specific framework error, consider posting it in https://stackoverflow.com/ instead.

1,358 questions
Filter by
Sorted by
Tagged with
173 views

### Implementation of Unitary in Shor's Algorithm in PennyLane

I've been working on implementing Shor's Algorithm in PennyLane, but am struggling to understand how the circuit for 'U' has been constructed according to Qiskit. In the Qiskit textbook, they seek to ...
1 vote
229 views

### Visualize full UCC circuit in qiskit

I am experimenting with the UCC module in qiskit nature. From pyscf, I got 1-body and 2-body integrals (I need to use custom integrals) and thus created a mapped ...
• 374
136 views

### Quantum Phase Estimation - Should be getting exact answer

Having read the Qiskit demonstration in the Qiskit textbook on how to implement Quantum Phase Estimation, I tried to do so on PennyLane's framework. My code pretty well follows what was done in Qiskit,...
100 views

### Efficient Way to Create an LUT in Stim

What is the fastest and most resource-efficient way to create an LUT decoder for a quantum error correction code using Stim (https://quantum-journal.org/papers/q-2021-07-06-497/)? Specfically, I am ...
• 221
158 views

### Given this code fragment, what is the probability that a measurement would result in $|0\rangle$?

Trying to understand below probability how it occured? qc = QuantumCircuit(1) qc.ry(3 * math.pi/4, 0) A. 0.8536 B. 0.5 C. 0.1464 D. 1.0 And the answer is C. But I ...
• 111
1 vote
63 views

### How does one use the Qiskit CDMKRippleCarryAdder?

How does one use (call from a main program) Qiskit's CDKMRippleCarryAdder in a quantum circuit, or for that matter, any other Qiskit library of a similar nature? ...
121 views

### Error : Cannot unroll the circuit to the given basis

I want to run the circuit given below, but I am getting the following error. QiskitError: "Cannot unroll the circuit to the given basis, ['u1', 'u2', 'u3', 'cx', 'id', 'unitary']. Instruction ...
• 55
46 views

### How to make qiskit jupyter plot and draw properly [closed]

The problem: You try to plot or draw more than once within a cell, or you try to plot or draw within a code block,but nothing comes out and you're going nuts... :)
• 55
1 vote
134 views

### QuTip: How to multiply symbol with matrix

I am trying to multiply a symbol with a matrix which is defined by QuTip quantum object, but I got this error: TypeError: Incompatible object for multiplication I ...
1 vote
162 views

### Writing Toffoli Gate Matrix by one and two qubit gate matrices

I am trying to write Toffoli gate matrice by using one and two qubit gates matrices. I follow this circuit link for the circuit I first started to write the matrices of one and two qubit gates: ...
• 446
1 vote
41 views

### Quantum circuit error in QISKIT

I am trying to build a simple 16-qubit Quantum circuit where I am appending an 8-qubit quantum circuit to the first 8-qubits of my custom circuit. Then I measure all the qubits. However when I execute ...
• 11
109 views

### Is there a software to simplify commutators such as $[{\hat a}^\dagger{\hat a}^\dagger {\hat a},{\hat a}^\dagger\hat a \hat a]$?

Sometimes I need to simplify some commutators in the form $[{\hat a}^\dagger{\hat a}^\dagger {\hat a},{\hat a}^\dagger\hat a \hat a]$. Doing it by hand is exhausting and boring. Is there software (...
• 255
309 views

### Calculating the quantum euclidean distance between vectors

I am trying to get the distance using the swap test circuit. , With the help of the codes I shared, I can only estimate the distance between two vectors. Can it calculate the distances of many vectors ...
• 55
37 views

### Why the pulse scheduler produces a different output from the original circuit?

As part of a larger code, I have to convert a quantum circuit into a Pulse scheduler. The problem is that the scheduler output is incompatible with the circuit output. In particular, the difference ...
1 vote
84 views

### When I try to transpile circuit with Qiskit, how can I use $Ry(\pi/2)$ as a basis gate?

When I try to transpile circuit with Qiskit, I can use 'ry' as a basis gate. But I want to set one of the basis gate as $R_y(\pi/2)$. How can I do that? Edited: <...
• 317
46 views

### How can I delay the construction of the power of a gate in a parametric circuit?

I want to implement the parametric power of a gate. I know that the parametric power is impractical to implement (cf https://github.com/Qiskit/qiskit-terra/issues/4751). So, I want to delay the ...
93 views

### How to order results after multi-circuit qiskit.execute parallel run?

I'm kinda new to qiskit and I find really fascinating its parallelization capabilities, then I'm trying to creating all the needed circuits for my application at once and transpile, assemble and ...
• 321
1 vote
93 views

### What does a statevector with 3 elements (in Qiskit) represent?

I wasn't quite sure where to post this as I don't know if this is a Qiskit specific thing or not, but I'm not sure how to interpret this result I got from running a simulation. from result.data(): <...
• 61
113 views

### Projection Operator in qiskit.opflow

I am looking for a way to implement a projection operator like $\mid +\rangle\langle+\mid$ in qiskits opflow module. I tried Plus @ ~Plus but this gives me an error ...
179 views

### Simulating flag qubits and conditional branches using Stim

In a quantum error correcting code using flag qubits, it's common to have flag measurements that tell you it's necessary to do some extra measurements for safety. So, for example, I want to say: ...
• 23.4k
46 views

### How to create this feature map?

In this paper, the following feature map is used: $$x \to \vert\phi(x)\rangle = \frac{1}{\sqrt{2^k}}\sum_{i=0}^{2^k-1}\vert x\cdot g^i\rangle$$ But no circuit is provided. A theoretical description of ...
• 41
54 views

### I can not extract the final statevector when using a binded Parametric Controlled gate

I'm trying to implement a Parametric Hadamard Test. I have already my parametric evolution gate $\exp(-i\theta H)$ where $\theta$ is the parameter. When I defined the controlled-gate with Gate.control(...
• 21
56 views

### Can the ancilla for Qiskit's mcx with mode="recursion" be dirty?

I think their implementation is close to the one from here which does use a dirty ancilla, but I just want to make sure
• 356
1 vote
128 views

I am trying to approach Markov chains as a use case for Quantum Computing. For this I took the simple introductory case from Wikipedia (Markow-Kette): $v_0=\begin{pmatrix} 1 & 0 & 0 \end{... 3 votes 1 answer 132 views ### Variational quantum eigensolver in qiskit I have implemented a hybrid quantum NN on a dataset to perform classification. Now I want to apply quantum PCA to my dataset to find the eigenvalues. After going through a few qiskit tutorials, I ... • 159 1 vote 1 answer 201 views ### 'Internal error. Error code 9999' when running job on IBMQ I'm trying to run a series of circuits in a job and I keep getting this error message which I haven't been able to find the meaning of anywhere in qiskit's documentation, online, etc. The job appears ... 1 vote 0 answers 88 views ### QuTiP VS RK45: Which one gives the correct results for time-dependent systems? I am writing a code for a quantum thermal machine which includes both coherent and dissipative time evolutions in its different stages of operation. However, evolving the system with "mesolve&... • 111 4 votes 2 answers 211 views ### Phase Oracle in Qiskit Solving Satisfiability Problems using Grover's Algorithm Section In Qiskit Textbook, there is a section on solving satisfiability problems using Grover's Algorithm. For the 3SAT instance they construct the following phase oracle: Is there any reasoning behind ... • 441 2 votes 1 answer 40 views ### Applying QPE on a large matrix on amazon-braket I'm running a QPE algorithm on the amazon-braket but it can only apply on a 22 or 44 matrix, when I want to expand it into a 5*5 or more, it will come an error. As I know, there is no theoretical ... 4 votes 1 answer 331 views ### Replace Gate with Known Identity in Quantum Circuit I have a quantum circuit with 3 two-qubits gates XX, YY, and ZZ (as defined in the qiskit circuit library) with arbitrary angles on each gate. I'd like to replace the YY and ZZ gates with XXs. I know ... • 340 1 vote 1 answer 106 views ### How could I choose cost function in Qiskit TwoLayerQNN? So here is the problem, I've found that in a TwoLayerQNN, the backward gradient is only to minimize the expectation of observable I've chosen. But I'm not going to minimize the predict of the input, ... • 11 3 votes 0 answers 46 views ### Computing specific observable for a Clifford circuit Given a clifford circuit, how can I simulate it efficiently to get the 2-RDM (reduced density matrix)$D^2=\langle a_i^\dagger a_j^\dagger a_k a_l\rangle$in the presence of deplorizing error? The ... • 655 5 votes 2 answers 527 views ### Can I initialize only one qubit in a 4-qubit circuit? I wonder if there's a way we can initialize the quantum state only for part of the qubits in a quantum circuit. Say if I have a quantum circuit defined as ... • 2,228 1 vote 1 answer 116 views ### Qiskit does not interpret qasm string as 3.0? I am trying to get my first openqasm3.0 program and I am getting error messages that I cannot interpret. Here is my program: ... • 645 2 votes 0 answers 39 views ### How to return phase angles as seen in IBMQ composer using qiskit? I recently transitioned from using the IBMQ composer and am using qiskit in the IBM lab. To start, I wanted to learn how to reproduce the computational basis states, probabilities and phase angles as ... • 21 1 vote 1 answer 56 views ### queueinfo() module in Qiskit I want to know how to use queueinfo() module in IBM Qiskit. When I type job.QueueInfo(), it says "QueueInfo" is not defined. How to import it? I'm trying to use queueinfo() to know the time ... • 29 1 vote 2 answers 92 views ### Setting the$\texttt{state_preparation}$for$\texttt{AmplificationProblem()}\$ in the scope of Grover's algorithm

I am having trouble setting the state_preparation parameter of AmplificationProblem() from ...
• 438
1 vote
82 views

### Openfermion state transformation from Bravyi-Kitaev basis to occupation number

I'm working in the Bravyi-Kitaev basis implemented by the openfermion.bravyi_kitaev() function to find the ground state of a fermionic operator in the BK ...
• 107
252 views

### What is the difference between Qiskit Terra, Aer, Ignis and Aqua?

I am going through the Qiskit tutorials and they have an article on each of the above 4. however, As a beginner, I am not very clear. Could anyone share some insights on these?
• 153
90 views

### How can I add readout error in constructing a quantum noise model?

I'm trying to construct a quantum noise model with readout error only: qiskit.providers.aer.noise.NoiseModel.add_readout_error. However, when I try to specify the ...
• 2,228
18 views

### Is there any software package tracking Pauli errors in stabilizing circuits with GUI?

I want to track the Pauli errors propagating in stabilizer circuits like surface code. I wonder whether there is any developed package that can do this elegantly. It will be better if it has GUI that ...
• 317
113 views

### VQE from scratch, what have I got wrong?

I've been working on a code to run VQE with a grouped measurement. For some reason, my expectation values are slightly off from those computed by pennylane, the software I decided to use for this ...
• 469
228 views

### Qiskit - Simpler way to create a Hamiltonian

I am looking for an efficient way to create a Hamiltonian in Qiskit. Following are my desired input and outputs input: 'ZZI' output: Z^Z^I, where Z and I are operators. Here is how I am doing it ...
• 175
1 vote
136 views

### Tweak the parameter p of QAOA in qiskit

I am solving a QUBO using QAOA. It works flawlessly with default parameters for smaller instances of the problem, but my RAM is saturated when I try to solve a problem of size 15. I suspect this can ...
• 81
54 views

I'm trying to create a Stim.Circuit, given a list of qubits and operations on them. Does the API support adding comments to the circuit's string representation? I've tried using ...
111 views

### Reading a classical register in OPENQASM

The IBM OpenQASM program below clones a state selected from an orthogonal pair. It seems to work but there is a mystery. I declare the classical register as an array c[1] but when I try to test its ...
• 645
1 vote
182 views

### Binary classification using a very simple Neural Net with Qiskit and Pennylane

I implemented a simple Neural Net with Pennylane and Qiskit for classifying two half moons: notebook for two half moons (GitHub). It works somehow (not overwhelmingly by any means): I tried running ...
1 vote
177 views

### QUBO defined in Qiskit/DOcplex: how to solve it using Pennylane?

I have a complex Integer Linear Programming model defined in DOcplex/Qiskit representing a combinatorial optimization problem. Using the Qiskit utils, it is possible to covert it to either an Ising ...
1 vote