Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [programming]

For questions relating to the process of assembling quantum programs that can be executed on a quantum computer. For questions using or about a specific programming language, consider using a more specific tag

50
votes
5answers
10k 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 ...
38
votes
6answers
1k 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.
26
votes
3answers
2k 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 ...
14
votes
3answers
752 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 ...
14
votes
3answers
633 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 ...
13
votes
2answers
2k 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?
13
votes
4answers
861 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' ...
12
votes
2answers
444 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 ...
11
votes
3answers
479 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 ...
11
votes
3answers
253 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 don't know anything about quantum mechanics?
9
votes
2answers
429 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 ...
9
votes
2answers
193 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 + [...] + - ...
9
votes
3answers
425 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 ...
9
votes
2answers
238 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 ...
8
votes
2answers
293 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 ...
8
votes
2answers
129 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 ...
8
votes
2answers
376 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): ...
8
votes
1answer
181 views

Submitting jobs to IBM devices without Python

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. ...
8
votes
1answer
1k views

Visualization of Quantum Circuits when using IBM QISKit

I have followed the installation steps, regarding QISKit working environment. For circuit visualization, I've installed latex as in addition to poppler to convert from PDF to images. Afterwards, I ...
7
votes
5answers
593 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?
7
votes
2answers
103 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?
7
votes
2answers
539 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 ...
7
votes
3answers
317 views

How do you send an array of qubits to an operation in Q#?

I have the following operation in my .qs files: operation myOp(qubits: Qubit[]) : () { // uses elements from the qubit array } How do I send an ...
7
votes
2answers
178 views

From Q# measurements to Bloch sphere

I would like to represent the state of a qubit on a Bloch sphere from the measurements made with Q#. According the documentation, it is possible to measure a qubit in the different Pauli bases (...
7
votes
1answer
330 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$ $...
7
votes
1answer
238 views

One-qubit gates results in QISKit

I found it odd that the result of the action of identity gate (namely a $2\times2$ identity matrix) on a pure state $|0\rangle$ (namely the vector corresponding to the $2\times1$ matrix $\begin{...
7
votes
1answer
140 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 ...
7
votes
0answers
77 views

Is it better to use fewer gates or fewer working qubits? [closed]

I have a script that takes a while to simulate. I can modify it in such a way where I can use fewer qubits at a time, but it will require more iterations of manipulation. I believe this will cut down ...
7
votes
0answers
103 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 ...
6
votes
1answer
344 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 ...
6
votes
3answers
296 views

Is there something like GitHub for quantum programming?

I'm just learning about quantum computer but some of it has been available for people to research & practice so I'd like to study it myself. The only kind of quantum computing I found so far is ...
6
votes
2answers
93 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: ...
6
votes
1answer
515 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$$
6
votes
1answer
239 views

Defining qubit operator from scratch

I'm a beginner with Qiskit and the Python language at all. Here is my question: One of the VQE function arguments is qubit operator (qubitOp). I saw some examples ...
6
votes
3answers
247 views

Measuring qubits in QuTiP

How can you measure qubits in QuTiP? As far as I have seen you can define a Hamiltonian and let it evolve in time. It is also possible to define a quantum circuit, however, measuring and running it ...
6
votes
2answers
133 views

Construct Controlled-$G^{\dagger}$ from known Controlled-$G$

Let there be a known a scheme (quantum circuit) of Controlled-G, where unitary gate G has G$^†$ such that G≠G$^†$ and GG$^†$=I (for example S and S$^†$, T and T$^†$, V and V$^†$, but not Pauli and H ...
6
votes
1answer
365 views

How would one implement a quantum equivalent of a while loop in IBM QISkit?

I'm writing a simple multiplication algorithm that uses the Quantum Fourier Transform to repetitively add a number (the multiplicand) to itself and decrements another number (the multiplier). The ...
6
votes
1answer
97 views

Why does job.running in QISKit output False, even if the job is still running?

I submitted a job in the 0.5.0 version of QISKit using job = execute(qc, 'ibmqx5', shots=shots) This just submits the job, and does not wait for a result. I ...
6
votes
0answers
68 views

Gradient boosting akin to XGBoost using a quantum device

I am currently trying to implement a boosting algorithm akin to XGBoost with a quantum device. The reason is that I want to make use of a quantum device to train weak classifiers. However, as far as I ...
5
votes
4answers
479 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}{...
5
votes
2answers
87 views

Why is Grover's algorithm not converging monotonically? (Python implementation)

I have tried to implement Grover's algorithm for three qubits in python/numpy and the first two iterations work like a charm but the third one starts to diverge. Is this expected, or is there a bug in ...
5
votes
1answer
350 views

List of qubit locations with cirq

As far I understand, qubits in cirq are labelled by their positions on chip. For example print( cirq.google.Foxtail.qubits ) yields ...
5
votes
1answer
162 views

What is the purpose of the TDG gate in QISKit?

The QISKIT documentation doesn't explain what a TDG gate does and I can't find it anywhere else online.
5
votes
1answer
131 views

How to construct the “Inversion About the Mean” operator?

It seems like it should be simple, based on how Nielsen and Chuang talk about it, but I cannot seem to correctly implement the Inversion About the Mean operator ($2|\psi\rangle \langle\psi| - \mathcal{...
5
votes
1answer
111 views

Q# factorization Method Program

Is there a method to calculate prime factorization in Q# of Visual Studio of Microsoft Quantum Development Kit? In the Python language, it is the sympy.factorint ...
5
votes
1answer
627 views

What is Qconfig in QISKit and how do I set it up?

To use certain things in QISKIt, such as acessing the real quantum processors, it seems that there is a file 'Qconfig.py'. That needs to be set up. How do I do this?
5
votes
1answer
117 views

What resources are available for learning QCL?

I'm struggling to find much about the language QCL, rather than about quantum computing itself. Is there anything out there like that? It doesn't have to be free.
5
votes
2answers
153 views

Quantum counting in Q#

I cannot seem to get an estimate for the number of solutions using the quantum counting algorithm described in Nielsen and Chuang, i.e. phase estimation with the Grover iteration acting as $U$. I try ...
5
votes
1answer
95 views

Flying qubits compared with stationary qubits

In a previous question I asked how stationary bits could be processed by logic gates. I casually mentioned that I could visualize qubits traversing stationary logic gates, and @DaftWullie said “It ...
5
votes
1answer
47 views

How to calculate the fidelity of a certain gate of a IBMQ device in Qiskit using randomized benchmarking/tomography?

For example, I want to calculate the fidelity of a 1-qubit and 2-qubit gates (similar to the result shown in figure 2 in this paper). Is there any way to do that in Qiskit? I've gone through the ...