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
86 votes
6 answers
39k views

What programming languages are available for quantum computers?

From this question, I gathered that the main quantum computing programming languages are Q# and QISKit. What other programming languages are available for programming quantum computers? Are there ...
Pro Q's user avatar
  • 993
50 votes
6 answers
3k views

Programming quantum computers for non-physics majors

I come from a non-physics background and I am very much interested in pursuing Quantum Computing - especially how to program them. Any guidance on how to get started will be very helpful.
Koder101's user avatar
  • 997
37 votes
3 answers
4k views

How do you write a simple program for a D-Wave device?

I would like to know how a job for a D-Wave device is written in code and submitted to the device. In the answer it would be best to see a specific example of this for a simple problem. I guess that ...
James Wootton's user avatar
31 votes
6 answers
13k views

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}{...
Nillmer's user avatar
  • 735
29 votes
4 answers
12k views

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's user avatar
  • 1,622
29 votes
4 answers
7k views

Are quantum computers just a variant on Analog computers of the 50's & 60's that many have never seen nor used?

In the recent Question "Is Quantum Computing just Pie in the Sky" there are many responses regarding the improvements in quantum capabilities, however all are focussed on the current 'digital' ...
Philip Oakley's user avatar
20 votes
3 answers
1k views

What would a very simple quantum program look like?

After reading the "first programmable quantum photonic chip". I was wondering just what software for a computer that uses quantum entanglement would be like. Is there any example of code for specific ...
Didix's user avatar
  • 785
18 votes
1 answer
13k views

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 ...
thedumbkid's user avatar
17 votes
3 answers
1k views

Does a complete list of open quantum software projects exist?

An answer to Is there any source which tabulates quantum computing algorithms for simulating physical systems? mentions the Quantum Algorithm Zoo, a list of quantum algorithms. Several answers to ...
agaitaarino's user avatar
  • 3,827
15 votes
2 answers
1k views

Does a study guide exist that starts from a "purely CS background" and advances towards "making a new quantum programming language"?

I am from a computer science background and I find it difficult to decide on the resources I should focus on while learning quantum computing, since there is so much to read/watch. My ultimate goal is ...
Kushajveer's user avatar
14 votes
1 answer
6k views

How many logical qubits are needed to run Shor's algorithm efficiently on large integers ($n > 2^{1024}$)?

First, I know there are differences in logical qubits and physical qubits. It takes more physical qubits for each logical qubit due to quantum error. Wikipedia states that it takes quantum gates of ...
LeWoody's user avatar
  • 844
14 votes
3 answers
6k views

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 ...
C-Roux's user avatar
  • 888
13 votes
6 answers
2k views

Resources for quantum algorithm basics

I have just started to learn about quantum computing, and I know a little bit about qubits. What is a resource where I can learn a basic quantum algorithm and the concepts behind how it works?
Vashi's user avatar
  • 177
13 votes
2 answers
2k views

Does quantum computing already possess the level of abstraction to be explicable even without knowledge of physics?

Currently, quantum computer science (in contrast to classical computer science) can mostly only be understood if one has a good inside knowledge of physics, or more precisely quantum physics. Only ...
Tetragrammaton's user avatar
13 votes
3 answers
469 views

Which programming language is suitable for a beginner?

I understand there are a lot of programming languages (e.g. Q#, Qiskit, etc.) Which one is suitable for someone that just started learning programming and doesn't know anything about quantum ...
Daniel Mana's user avatar
13 votes
3 answers
955 views

Superposition of quantum circuits

Given a quantum circuit $C_1$ that generates a state $\vert\psi\rangle$ and another circuit $C_2$ that generates $\vert\phi\rangle$, is there a way to construct a circuit that outputs $$\frac{1}{\sqrt{...
Kolp's user avatar
  • 133
13 votes
2 answers
661 views

Hamiltonian simulation with complex coefficients

As part of a variational algorithm, I would like to construct a quantum circuit (ideally with pyQuil) that simulates a Hamiltonian of the form: $H = 0.3 \cdot Z_3Z_4 + 0.12\cdot Z_1Z_3 + [...] + - ...
Mark Fingerhuth's user avatar
13 votes
2 answers
1k views

Automatic compilation of quantum circuits

A recent question here asked how to compile the 4-qubit gate CCCZ (controlled-controlled-controlled-Z) into simple 1-qubit and 2-qubit gates, and the only answer given so far requires 63 gates! The ...
user1271772 No more free time's user avatar
13 votes
0 answers
262 views

Does the Curry-Howard correspondence have a quantum-specific type system?

In Wikipedia we can read that the Curry–Howard correspondence is a correspondence between formal proof calculi and type systems for models of computation. In particular, it splits into two ...
fr_andres's user avatar
  • 754
12 votes
3 answers
4k views

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's user avatar
12 votes
1 answer
8k views

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 ...
mavzolej's user avatar
  • 1,921
12 votes
4 answers
5k views

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^{...
Sanchayan Dutta's user avatar
11 votes
3 answers
765 views

Are there any quantum software startups?

I am aware of the quantum hardware startup Rigetti and I wonder if there are any quantum startups that build software on top of current quantum computer hardware for commercial applications? Related ...
QNerd's user avatar
  • 113
11 votes
2 answers
4k views

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 ...
Zohim Chandani's user avatar
11 votes
1 answer
561 views

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. ...
James Wootton's user avatar
11 votes
2 answers
487 views

AWS Braket Backend for Qiskit?

Is there a working AWS Braket backend provider for Qiskit 0.29 that can be used with the MinimumEigenOptimizer interface? The qiskit-aws-braket-provider package is unfortunately not working.
Nepomuk Hirsch's user avatar
11 votes
2 answers
5k views

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 ...
asdf's user avatar
  • 503
10 votes
1 answer
4k views

Can I remove gates from a QuantumCircuit?

Suppose I want to implement run several circuits one after another, but they are constructed in a similar fashion. I could reinstantiate a QuantumCircuit for each ...
Alexey Uvarov's user avatar
9 votes
1 answer
3k views

Phase-Shift Gate in Qiskit

How to implement the phase shift gate in qiskit or ibmq? Phase Shift Gate : $$\begin{pmatrix}e^{ia} && 0 \\ 0 && e^{ia}\end{pmatrix} = e^{ia}I$$
Debarghya Kundu's user avatar
9 votes
2 answers
2k views

Transpilation into custom gate set in qiskit

In qiskit, I can transpile a given circuit into a some predefined gate set as follows (just an example) ...
Nikita Nemkov's user avatar
9 votes
2 answers
798 views

How to program a controlled Hadamard-Hadamard gate?

I'm trying to program a controlled gate as the figure below in Qiskit. Should it be sufficient to separate and control individually the Hadamard gates?
German Alamilla's user avatar
9 votes
2 answers
842 views

Qubits specification on IBMQ devices

As it is shown here, CNOT gates between different qubits have different error rates. I have the following questions: 1) While defining a circuit on QISkit, does ...
Mathist's user avatar
  • 495
9 votes
1 answer
4k views

What are the differences between Qiskit's AerSimulator, QasmSimulator and StatevectorSimulator?

In Qiskit, we can see the names of available simulators with the command Aer.backends(). These include: ...
user3886914's user avatar
9 votes
2 answers
10k views

How to get state vector from QasmSimulator in Qiskit

I'm currently able to get state vector in Qiskit using state_vector backend using something like : ...
user12910's user avatar
  • 451
9 votes
1 answer
1k views

How efficient is Qiskit's unitary decomposition?

In Qiskit's extension package we have the UnitaryGate module that you can initialize using a unitary matrix and then add it to your circuit. How efficiently is this ...
Dani007's user avatar
  • 532
9 votes
3 answers
527 views

A sample quantum algorithm, useful for demonstrating languages

I'm looking for a quantum algorithm which I can use to demonstrate the syntax of different quantum-languages. My question is similar to this, however, for me, "good" means: What it does could be ...
klenium's user avatar
  • 193
9 votes
2 answers
434 views

Quantum implementation of arcsin

I am looking to implement a quantum version of the arcsinus function. Such a problem is motivated by the HHL algorithm where $x\mapsto 1/x$ and $\arcsin$ can be used to get $1/x$ from the ...
SRichoux's user avatar
  • 319
9 votes
2 answers
471 views

How does the Curry-Howard correspondence apply to quantum programs?

In words of Wikipedia, The Curry–Howard correspondence is the observation that two families of seemingly unrelated formalisms—namely, the proof systems on one hand, and the models of computation ...
fr_andres's user avatar
  • 754
9 votes
1 answer
2k views

In Cirq, how do you display circuit diagrams that are "prettier" than the ones displayed by default?

This is a duplicate of a question that was asked on the Cirq issues page. I'm duplicating this question to increase it's visibility.
Victory Omole's user avatar
9 votes
1 answer
579 views

Inequality constraints on D-Wave (using PyQUBO)

Inequalities cannot be directly converted into a QUBO form. By inequality, I mean something like this: 0⩽ Expression ⩽ N. We can introduce a slack variable and convert it to an equality problem: ⟹ ...
amp's user avatar
  • 91
9 votes
1 answer
2k views

QUBO, Ising Hamiltonians and VQA

I understand that usually the combinatorial optimisation problems are turned into QUBO, which has a very simple mapping to Ising Hamiltonians. Ising Hamiltonians in turn have the desired properties of ...
karolyzz's user avatar
  • 279
8 votes
2 answers
272 views

How does one obtain amplitude information in Q#?

Is it possible to obtain amplitude information (in lexicographic ordering) for a particular qubit register in Q#? For example, in the following code: ...
jman's user avatar
  • 443
8 votes
2 answers
493 views

Apply readout error mitigation to mid-circuit measurement

I'm trying to construct a quantum circuit with 3 mid-circuit measurements, here's an example: ...
ZR-'s user avatar
  • 2,388
8 votes
3 answers
2k views

Which quantum computing programming language should I learn?

Which quantum computing programming language should I learn? What are the benefits of said language? As of Wikipedia, there's quite a bit to choose from. I'm looking to develop end-user applications (...
AJ_4real's user avatar
  • 153
8 votes
2 answers
285 views

Can we perform quantum mechanical simulations using a quantum computer?

I'm a computer science major who's really keen on physics and quantum mechanics. I have started learning about Q# and D-Wave, but I just wanted to know if it's possible to test quantum mechanical ...
Yashank's user avatar
  • 253
8 votes
2 answers
2k views

Possibility of a "reset" quantum gate

I wish to have a "reset" gate. This gate would have an effect to bring a qubit to the $\mid0\rangle$ state. Clearly, such a gate is not unitary (and so I'm unable to find any reliable implementation ...
Ntwali B.'s user avatar
  • 443
8 votes
1 answer
8k views

How to create an arbitrary state in QISKit for a local_qasm_simulator?

I would like to play with a quantum circuit local_qasm_simulator in QISKit, but I do not want to implement a separate quantum circuit that would prepare an initial ...
Alexander Pozdneev's user avatar
8 votes
2 answers
860 views

There was an error in the circuit!. Error = 'QISkit Time Out'

I've got the following quantum code using QISKit (based on hello_quantum.py): ...
kenorb's user avatar
  • 662
8 votes
2 answers
1k views

Changing indices of qubits in QISKit

I was wondering if something like this is possible in QISKit: let's say we have two registers containing target and ancilla qubits: $a_0$ ------------------- $a_1$-------------------- $\vdots$ $...
brzepkowski's user avatar
  • 1,049
8 votes
1 answer
3k views

Qiskit - difference between qasm_simulator and statevector_simulator in terms of memory and speed?

I'm trying to profile qiskit backends and I use randomized_benchmarking provided by qiskit.ignis. Initially I ran a circuit with ...
izumi's user avatar
  • 81

1
2 3 4 5
33