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

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.

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

Qiskit error: too many subscripts in einsum when calling DensityMatrix.evolve(Operator)

Minimal details: My density matrix is of dims=(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)). I want to use DensityMatrix.evolve(qc) to evolve this DM with a quantum circuit qc. Below is the code ...
tomek's user avatar
  • 115
0 votes
1 answer
24 views

How to understand the matrix representation of the Toffoli produced by qiskit?

I would like to ask about the results of running the Toffoli gate matrix and circuit diagram on colab Possible reasons for inconsistent results with the following correct matrix results. I would also ...
Dona's user avatar
  • 1
2 votes
1 answer
28 views

How to apply gates on a subspace of a superposition of qubits?

Let us say that I have the state $a|00\rangle + b|01\rangle + c|10\rangle + d|11\rangle$. I wish to apply a one-qubit unitary (a $2\times2$ matrix) U on the subspace spanned by $|01\rangle$ and $|10\...
Soumyadeep sarma's user avatar
0 votes
0 answers
10 views

What is TICK layer in stim

I'm trying to simulate a circuit in stim and I get the following error in my stack trace. ...
Palash Goiporia's user avatar
1 vote
2 answers
734 views

Where do I create my first circuit?

I want to get the result of this code: ...
Ritvik Chowdary's user avatar
3 votes
1 answer
75 views
+50

Solving quantum equation using qiskit

I am struggling to solve the mathematical equations using qiskit in the below paper. https://arxiv.org/pdf/2205.00081 The mathematical equation I tried to solve is below: I tried solving it using ...
Manu's user avatar
  • 53
1 vote
1 answer
58 views

Pauli Strings on the same qubit?

I am working on solving a Max-Cut problem using fewer qubits via efficient encoding methods of more classical information onto a single qubit.Using the method of The original problem has the ...
Another Random Guy's user avatar
-1 votes
0 answers
15 views

How do I setup the Jupyter Lab as for Quantum Computing to import everything? [closed]

I'm coming from the IBM Quantum Lab and since it got switched recently, I've switched over to the Jupyter lab. However, I was wondering how to set it up properly and have everything imported.
Ark Rana's user avatar
1 vote
0 answers
23 views

Custom classical control in qiskit

I'm generating a qiskit circuit and want to add an X gate to a qubit if the sum of some previous measurements modulo 2 is equal to 1. In cirq, I could just use a sympy expression that would look ...
Palash Goiporia's user avatar
0 votes
0 answers
9 views

Particle number expectation value in QuTip

I am learning now to use QuTiP by going through their documentation site. I am trying to understand what does the argument - particle number expectation value in thermal density matrix do? How does it ...
CuriousMind's user avatar
1 vote
0 answers
13 views

On the construction of quantum circuits for S-boxes with different criteria based on the SAT solver

I'm reading this paper: On the construction of quantum circuits for S-boxes with different criteria based on the SAT solver. Here's the link: https://eprint.iacr.org/2024/565.pdf#page=29&zoom=100,...
Huy By's user avatar
  • 93
1 vote
1 answer
55 views

How to correctly compute expectation value in QAOA?

In QAOA after prepating $|\psi(\gamma, \beta) \rangle$, expectation value $\langle \psi(\gamma, \beta)|H_c|\psi(\gamma, \beta) \rangle$ is computed. In tutorials, I see two approaches to this ...
Oleksii's user avatar
  • 21
1 vote
1 answer
23 views

Qiskit: Evolve TrotterQRTE from Operator

I am trying to implement the method in the following paper: Exponential Quantum Speedup in Simulating Coupled Classical Oscillators using Qiskit. All is good until I call evolve on ...
guest's user avatar
  • 11
3 votes
0 answers
38 views

Algorithm for computationally generating the single qudit clifford group

For a d dimensional single qudit, knowing the generators of the group being the Hadamard gate and the Phase gate, how would I generate the entire group computationally in python? Or for any finite ...
Son100's user avatar
  • 33
1 vote
0 answers
42 views

Shor’s / qiskit.circuit.exceptions.CircuitError: 'duplicate qubit arguments' [closed]

All code for Quantum Realiazition Shor's algoritm P.S. I hope all operation almost correct. ...
Bekzad Dzhanpolatov's user avatar
1 vote
0 answers
16 views

Why we do SWAP operations for applying a mode N function in Shor algorithms and How we do this swapping? [duplicate]

I am working on implementing shor algorithm for finding prime factors of N = 15. I am trying to understand a code of qiskit, but i am confused how and why the code editor is using swap codes to define ...
Tayyab Yahya's user avatar
2 votes
1 answer
59 views

weird negative sign in a state vector in qiskit

I run the following simple code in qiskit, which get statevector of a quantum circuit. ...
mike_gz's user avatar
  • 23
1 vote
1 answer
45 views

Showing the Toffoli gate can be constructed from one-qubit gates using computer matrix multiplication

I need help coming up with the code that I can use in a computer algebra system like Sage, Python, or Mathematica that can evaluate the circuit. I am not a programmer and used ChatGPT to try to help ...
user2521987's user avatar
3 votes
1 answer
325 views

Quantum circuit not showing when using qiskit with pycharm

I am trying to run below code in PyCharm: ...
Aleah Turner's user avatar
0 votes
1 answer
61 views

How to implement a depolarizing noise channel for qutrits using cirq?

Anyone have any idea how I can implement a depolarizing noise channel for qutrits using cirq? Say using the kraus operators within a class inheriting from cirq.Gate or so?
Son100's user avatar
  • 33
1 vote
1 answer
35 views

Error when binding parameters to a quantum circuit

When I try to run the circuit below: ...
Opal Gill's user avatar
0 votes
0 answers
60 views

An 8-bit integer is a ring. What do eight qubits form?

I don't know if this question is well-posed, but I'm looking at computational proofs with classical fixed-width integers. The ones I'm looking at write proofs using rings (the algebraic structure), ...
joel's user avatar
  • 101
0 votes
1 answer
28 views

Plot_state_city question

qc = QuantumCircuit(2) qc.h(0) qc.x(1) qc.cx(0,1) state = Statevector(qc) plot_state_city(state, alpha=0.6) When this is graphed out, the following image is shown: ...
Ark Rana's user avatar
-1 votes
1 answer
23 views

How to add command `noise_model = get_noise ( 0.05,0.05 )` to my simulator in qiskit

I'm using qiskit online, and want to run my simulator with the following command: noise_model = get_noise ( 0.05,0.05 ) However, where previously I could insert lines of code to affect my circuit, I ...
רואי בורלא's user avatar
2 votes
2 answers
47 views

Can save_statevector() be used on a real quantum computer?

In a real quantum computer, can the save_statevector function be used to obtain the state vector of a circuit? I attempted to run the following code on a real ...
MrEightL's user avatar
1 vote
1 answer
47 views

Is there an up-to-date programming reference for qiskit?

Every example of code for qiskit that I've seen has one or more commands that don't work out of the box. Even the way to verify that qiskit is installed from qiskit.org failed. I've managed to either ...
Robert Megee's user avatar
1 vote
1 answer
135 views

How to represent unitary evolution in Python?

How to represent $U(t)$ (a unitary operator) in a code? Is there any package available for that in Python?
saaru darshini's user avatar
1 vote
0 answers
68 views

Generating Equal Amplitude Superposition States from Another Equal Amplitude Superposition State

Can we prepare a state regarding a transformation in quantum computing that seems to generate another equal amplitude superposition state when applying a Hadamard gate? Specifically, I observed that ...
Aman's user avatar
  • 503
0 votes
1 answer
48 views

How to use stim to implement a specific circuit

I'm doing a QEC job, and I want to apply an error like $U_{err}(\theta) = \prod_j e^{-i\frac{\theta_j}{2}P_j} = \prod_j (I\cos(\frac{\theta_j}{2}) - iP_j\sin(\frac{\theta_j}{2}))$, where $\theta_j$ is ...
Yule Su's user avatar
1 vote
1 answer
35 views

How to suppress long parameters list that appears in the initialize gate?

Below is a simplified code which I am using for a quantum circuit. ...
Shravan Patel's user avatar
0 votes
0 answers
27 views

BQSkit Selecting Starting Circuit Structure

Background On the BQSKit repository, there is a nice example of using the qfactor algorithm to instantiate a 3-qubit Toffoli circuit. For this to work, however, it is first necessary to specify an ...
Shadow43375's user avatar
0 votes
2 answers
39 views

Quantum Computing - via Qiskit - error 403

A year ago, I registered in the IBM Quantum Computing app, which provides access to quantum computers and to simulators. I got an API key, and was able to run some programs. However, lately, I try to ...
JDias's user avatar
  • 11
5 votes
2 answers
725 views

Are Quantum Computers Bad at Addition?

I recently built a dynamic full adder gate with Qiskit. The gate essentially copies the classical computing method for a full adder by emulating the classical gates e.g. AND == Toffoli (Quantum AND ...
Aidan's user avatar
  • 61
0 votes
0 answers
44 views

Calibrating qubits using Qiskit Pulse with Qiskit 1.0

I am trying to implement this notebook using the updated Qiskit 1.0. I have managed to update the code so that the job runs successfully on the IBM computer and I get the correct result. However, ...
rexyforbes00's user avatar
1 vote
0 answers
61 views

How to convert QUBO (with non-zero diagonal elements) to Maxcut?

I want to solve QUBO with non-zero diagonal elements in matrix Q using QAOA. But I want to solve for a large enough problem size (30+ variables) and hence want to divide my circuit into subcircuits. ...
Oleksii's user avatar
  • 21
1 vote
1 answer
40 views

How do I extract information from stim.PauliString?

Suppose I have stim.PauliString("+Z_Z_ZZ__"). I want to extract its data information in Python: either as a string ...
Craig Gidney's user avatar
  • 37.7k
0 votes
0 answers
36 views

CircuitTooWideForTarget error when using Clifford simulator in Qiskit

I want to use the local Clifford AerSimulator with the Estimator primitive in Qiskit to calculate expectation values on Clifford circuits, but I am getting a CircuitTooWideForTarget error: ...
jth's user avatar
  • 368
2 votes
0 answers
57 views

Layout error with after compilation with custom Qiskit pass manager

I am trying to implement the custom Qiskit pass manager from this paper. The code from the authors is provided here on GitHub. I am able to get the pass manager working, and a compiled circuit is ...
greelious's user avatar
  • 121
2 votes
1 answer
68 views

What does Qiskit AerSimulator(memory=True) do?

I followed this Qiskit course through Deutsch's algorithm and all seems clear to me except the use of the optional parameter memory=true when making the call to <...
kipawaa's user avatar
  • 23
2 votes
1 answer
101 views

IBM fake backend vs real backend

It is claimed that the fake backends of IBM will have noise similar to the real backends. However, to what extent can we expect them to produce the same results? I have run my quantum circuit on the ...
Deren  Liu's user avatar
2 votes
1 answer
117 views

Where to find the Grover's algorithm for Qiskit 1.0.2?

Can anyone please provide me with the latest version of qiskit 1.0.2 Grover's algorithm, as the earlier version is throwing an error.
Ayush Agarwal's user avatar
3 votes
1 answer
351 views

Why do the same circult yields very different results from different IBM backends?

I was running the IBM qiskit sample code and noticed that the results vary on different backends. I thought it was quantum noise, so I repeated the same calculation on many different backends and got ...
Guangliang's user avatar
1 vote
0 answers
26 views

Calculating Nested Commutator using a program

The $\tilde\alpha_{\text{comm}}$ mentioned in Theory of Trotter Error paper is calculated via the nested commutators. For a Hamiltonian $H = \sum_\gamma H_\gamma$, the formula for pth order is as ...
Zee's user avatar
  • 381
3 votes
1 answer
65 views

Multiplying two real variables in D Wave

I have two real variables from dimod: from dimod import Real A = Real("A") B = Real("B") However, when I try to multiply them ...
Dilshan Sonnadara's user avatar
4 votes
0 answers
54 views

Failed to load program into HAL component

I'm getting this error message when I execute my qiskit code on one of the available quantum computers of IBM: ...
Pablo Falegre's user avatar
0 votes
1 answer
29 views

Strange non-normal distribution histogram when applying Hadamard gate in a loop

Recently I have explored Q# quantum programming language. My basic test was this,- for 10000 times in a loop reset qubit to ...
Agnius Vasiliauskas's user avatar
1 vote
2 answers
64 views

How to generate the Bell state $\frac{1}{\sqrt{2}}(|01\rangle+|10\rangle)$ from the state $|00\rangle$ using Qiskit?

I want to generate the Bell state $(|01\rangle+|10\rangle)/\sqrt{2}$ from the state $|00\rangle$ in qiskit, applying the Hadamard gate followed by the $\text{CNOT}$ gate. But it generates $(|11\rangle-...
Xilot Xilot's user avatar
0 votes
0 answers
18 views

How to run pegasosQSVC in backend using qiskit ibm runtime session?

I am trying to run pegasosQSVC on quantum backend using a qiskit-ibm-runtime session, following is the code I am using : ...
khalil mehdi's user avatar
1 vote
0 answers
27 views

How to combine a VQE circuit with normal qiskit quantum circuit without parameters and give the measured set of qubits to the estimator?

I want to use a parameterized quantum-circuit which is $\text{CNOT}$ with another quantum-circuit that has no parameters, then after a series of gates on the second quantum-circuit, I want to measure ...
Syed Shahmir Kazmi's user avatar
0 votes
2 answers
75 views

How can I get the state of my quantum circuit like save_statevector() in qiskit 1.0.2?

Just as the title, I want to get the state of my quantum circuit when running simulation locally with fake provider. But I cannot use save_statevector since Aer has been removed from qiskit. My code ...
MrEightL's user avatar

1
2 3 4 5
33