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.

Filter by
Sorted by
Tagged with
0
votes
0answers
32 views

How to write this in expression in python [closed]

Writing a ket $\vert{\phi}\rangle$ in position basis. Defining $\langle x\vert\phi\rangle = \phi(x)$, we can write the ket in position basis as $$\int_{-\infty}^{\infty}dx \hspace{1mm}\phi(x)\hspace{...
0
votes
1answer
35 views

Retrieve image from Histogram data of Qiskit

I am trying to understand the quantum image processing. Please refer the link- https://qiskit.org/textbook/ch-applications/image-processing-frqi-neqr.html. I am not able to understand how to process ...
0
votes
0answers
31 views

Quantum GAN implementation

Can anyone provide a good link to understand how to implement qgan using pytorch in qiskit. Trying to understand this ( https://qiskit.org/documentation/machine-learning/tutorials/...
0
votes
1answer
25 views

combine_results() attribute error

When I tried to execute the below program, The attribute error hits me every time, which is; name 'combine_result' is not defined What is the problem here? Did I miss a module? ...
2
votes
1answer
48 views

How to construct a Hamiltonian containing Pauli string by qiskit?

There is a Hamiltonian I want to construct by a Python package, which is the following: $$ H = 5.9I + 0.21Z_0 - 6.12 Z_1 - 2.14(X_0X_1 + Y_0Y_1) + 9.6(I-Z_2) - 3.9(X_1X_2 + Y_1Y_2) $$ It is very easy ...
1
vote
1answer
31 views

What happens to the elements of the simulated state vector when we set a qubit to $|0\rangle$?

In IBM's Qiskit online simulator, we have the (non-reversible) ability to set a specific qubit to $| 0\rangle$. This is convenient but I'm left confused as to what happens to the elements of the ...
1
vote
0answers
17 views

QuTip - Is there a way to simulate more than one inital state in one simulation?

I'm trying to use QuTip for a simulation of a qutrit system and I want to see how my system evolves under different initial states. Is there a way to do it using QuTip without running the simulation ...
2
votes
2answers
91 views

Is there a function in qiskit that allows me to insert quantum gates at certain indices of a circuit?

Here's my quantum circuit with mid-circuit measurements: ...
2
votes
1answer
141 views

Incorporating Idling Errors while using Stim

Is there a smart way to incorporate idling errors for a quantum error correction code using the open-source tool Stim (preferably using the tableau simulator)? I have perused the github website (https:...
1
vote
0answers
60 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 ...
0
votes
1answer
43 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 ...
3
votes
1answer
72 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,...
2
votes
1answer
55 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 ...
0
votes
2answers
84 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 ...
1
vote
2answers
32 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? ...
2
votes
1answer
29 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 ...
-1
votes
1answer
27 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... :)
1
vote
0answers
60 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
1answer
61 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: ...
1
vote
0answers
30 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 ...
5
votes
1answer
76 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 (...
3
votes
1answer
73 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 ...
3
votes
0answers
28 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
0answers
56 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: <...
0
votes
0answers
29 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 ...
3
votes
1answer
50 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 ...
1
vote
1answer
55 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(): <...
2
votes
0answers
26 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 ...
4
votes
1answer
114 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: ...
1
vote
0answers
35 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 ...
1
vote
0answers
26 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(...
2
votes
1answer
26 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
1
vote
1answer
82 views

Very simple matrix operation (Markov chain) in terms of Qiskit

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{...
2
votes
1answer
48 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 ...
1
vote
1answer
38 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
0answers
64 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&...
4
votes
2answers
65 views

Phase Oracle in Qiskit Solving Satisfiability Problems using Grover's Algorithm Section

In Qiksit 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 ...
1
vote
0answers
25 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 ...
3
votes
1answer
99 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 ...
1
vote
1answer
51 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, ...
3
votes
0answers
35 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 ...
5
votes
2answers
456 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 ...
1
vote
1answer
44 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: ...
2
votes
0answers
35 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 ...
1
vote
1answer
45 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 ...
1
vote
2answers
65 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 ...
1
vote
1answer
37 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 ...
2
votes
1answer
84 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?
2
votes
1answer
44 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 ...
1
vote
0answers
15 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 ...

1
2 3 4 5
25