Skip to main content

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
12 views

(PyTket) Trouble with RoutingPass.apply() running forever -- seems to hang

I am attempting to route a circuit with 3 qubits, each connected via a 2 qubit gate that is defined using the Unitary2qBox. This sequence is repeated several times. So there are 3 choose 2 gates or 3 ...
Jack Ethridge's user avatar
0 votes
1 answer
19 views

Getting a Hermitian operator from a Quantum circuit, and taking its expectation value

I have a circuit $C$, which acting on a state $|\psi \rangle$ is equivalent to a Unitary $U$ acting on the state: $$C(|\psi \rangle) = U|\psi \rangle$$ Now, this circuit is just a Hamiltonian ...
Soumyadeep sarma's user avatar
0 votes
0 answers
19 views

Reading QuantumClifford.jl MixedDestabilizer state from a .csv file

This is more of a coding question, related to the Julia package QuantumClifford.jl. Hopefully this is the right place to ask. I am trying to prepare a specific stabilizer state, and in order to not ...
momiamfine's user avatar
2 votes
1 answer
43 views

General number of classical bits: recycles qubits

I am trying to write a Qiskit routine to perform qubit recycling for Shor's algorithm. This is a procedure by which the M-bit control register is replaced by a single quantum register, and the ...
Robert Singleton's user avatar
0 votes
0 answers
35 views

Tests of entanglement between one and many qubits

I have a 5-qubit state $|\psi \rangle$, which has a physical interpretation that the middle qubit is the "impurity" with spin $s_{imp} = 1/2$. The rest 4 qubits highlight the presence of ...
Soumyadeep sarma's user avatar
1 vote
2 answers
72 views

Can non-linear operations be implemented as a circuit on a quantum computer?

Suppose I have a Quantum circuit, which gives an output state $|\psi \rangle$ let's say. I wish to obtain the reduced density matrix by tracing out subsystem B, i.e. $\rho = |\psi \rangle \langle \psi ...
Soumyadeep sarma's user avatar
1 vote
0 answers
14 views

Error code 1217: "Session has been closed"

I am currently studying algorithms related to VQA. I have built a circuit to calculate the cost function and optimized it using a classical optimizer. During the initial optimization iterations, ...
MrEightL's user avatar
2 votes
0 answers
33 views

Are qiskit and qiskit aer identical or very similar in syntax?

I can't afford a IBM full access account, and can't learn an entire programming language with only ten minutes of run time a month. Are the qiskit lessons on YouTube/ github transferable given that I ...
diddyDANK's user avatar
2 votes
1 answer
45 views

Optimizing SymPy Implementation of prime factorization in form of QUBO

I'm trying to reproduce a paper on Prime Factorization. This paper converts the problem into a QUBO form, which then we can map it to an Ising Minimizer. I've basically done everything, and I've ...
Amirhossein Rezaei's user avatar
1 vote
2 answers
150 views

How to implement a quantum multiplier in Qiskit 1.0

I am looking at the homepage of Qrisp, and they have an example of how to multiply two registers with Qiskit: ...
Amir Naveh's user avatar
0 votes
1 answer
31 views

Obtaining and Applying XX and ZZ Parity in Stim for Controlled Paulis

I am attempting to perform a CNOT between two surface code qubits in Stim, based on this paper by Daniel Litinski and Felix von Oppen. The CNOT they perform is shown in the figure below (Figure 3 from ...
Maxwell Poster's user avatar
0 votes
1 answer
29 views

Error 400 on Variation Quantum Algorithm

As the title suggests, I am trying to optimize a cost function in a VQA (Variational Quantum Algorithm) code using a classical optimizer to obtain the best parameters. In my initial optimization ...
MrEightL's user avatar
1 vote
1 answer
83 views

For CHSH game, why does the mathematica program gives 75% as the best winning rate when sharing 2 EPR pairs?

In the CHSH game , the optimal quantum winning rate should be approximately 85% when Alice and Bob share the EPR states and this winning rate holds the same when they share arbitrarily many EPR states....
qmww987's user avatar
  • 169
1 vote
1 answer
27 views

How can I control multiple gate at once (qiskit)

I have the following circuit in qiskit: ...
Clamore's user avatar
  • 13
2 votes
1 answer
84 views

Finding Eigenvectors of a Unitary in a Quantum circuit

I have a unitary gate $U$, which is applied on some $n$-qubit quantum circuit ($n=7$ for my scenario). I wish to find the $n$-qubit state, which is the eigenvector (and possibly eigenvalues) of this ...
Soumyadeep sarma's user avatar
1 vote
2 answers
88 views

Hamiltonian Simulation: What's the meaning of t in $\exp(iAt)$?

My main goal is to find eigenvalues of some hamiltonian matrix $A$. When implementing Quantum Phase Estimation, I need to provide my circuit with informations about $A$. From what I have seen so far, ...
Max's user avatar
  • 13
1 vote
0 answers
44 views

is this a novel approach to visualization of qubits?

I am currently working on my Bachelor's Thesis and would love to hear your opinions about my project. The idea is to visualize the Binary parts of complex qubit states. White lines represent binary 0, ...
Mathias Pichler's user avatar
1 vote
1 answer
21 views

qiskit_aer.aererror.AerError: 'unknown instruction: ccry'

I'm trying to use qiskit_aer_gpu 0.14.2 with qiskit 1.1.0 I defined the class CCRYGate() y another script gate.py ...
ozark's user avatar
  • 31
1 vote
1 answer
27 views

having REPEAT with circuit append

In Stim's domain specific language, you can reapetdly add a code clock, as following REPEAT 10 { # code block } Is there a way to add that with ...
reza's user avatar
  • 11
2 votes
2 answers
51 views

The result of qiskit calculating T-depth and its calculation method

I have encountered doubts when using qiskit to calculate T-depth. I am not sure whether it is a problem with the way the code is written, or I am still a little vague about T-depth, so I would like to ...
Dona's user avatar
  • 21
0 votes
1 answer
52 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
  • 117
0 votes
1 answer
43 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
  • 21
2 votes
1 answer
32 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
1 answer
46 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
0 votes
2 answers
775 views

Where do I create my first circuit?

I want to get the result of this code: ...
Ritvik Chowdary's user avatar
4 votes
3 answers
246 views

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
  • 63
1 vote
1 answer
87 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 vote
0 answers
26 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
14 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
62 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
27 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
41 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
67 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
61 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
2 votes
1 answer
49 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
355 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
71 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
68 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
33 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
54 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
57 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
149 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
2 votes
1 answer
122 views
+50

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
  • 463
0 votes
1 answer
54 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
36 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

1
2 3 4 5
34