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
23
votes
3answers
7k 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?
12
votes
2answers
885 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
1answer
2k 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 ...
6
votes
2answers
1k 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?
47
votes
6answers
2k 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.
22
votes
6answers
7k 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}{...
16
votes
3answers
936 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 ...
8
votes
1answer
6k 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 ...
9
votes
1answer
2k 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$$
7
votes
1answer
3k 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 ...
4
votes
1answer
144 views

How can I find a Clifford+T approximation of an arbitrary one qubit gate in Qiskit?

I know the Solovay-Kitaev algorithm can achieve this. Is there an implementation of this or any other algorithm for the same task in Qiskit? Or perhaps some other library that interfaces well with ...
0
votes
1answer
134 views

Error while trying to execute the Quantum Circuits in IBMQ

I have been trying to execute the quantum circuit in the backend of the IBM 16 qubit Melbourne machine. I end up getting ...
5
votes
2answers
348 views

Simple Hadamard Circuit gives incorrect results?

I am running the simplest Hadamard circuit possible - one qubit, initialised to 0, apply H gate, measure in Z basis. When I run the circuit on the simulator I obtain the expected result (50% in 0, 50% ...
3
votes
1answer
338 views

Counting in Q#: number of solutions

I have this program derived from Microsoft Quantum Katas for counting (see here): ...
1
vote
2answers
388 views

Why IBM Quantum Experience is giving different results under ibmq_qasm_simulator and ibmq_16_melbourne?

I am trying to run following 6 qubit quantum circuit and I am getting different results under ibmq_qasm_simulator and ibmq_16_melbourne (both involving 8192 shots). What is the reason? ...
72
votes
6answers
34k 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 ...
10
votes
5answers
1k 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?
13
votes
2answers
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 ...
9
votes
1answer
2k 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 ...
5
votes
1answer
594 views

How can noise on a device be simulated using measured noise parameters?

The real devices used as backends for Qiskit have calibration data that quantifies errors ($T_1$ and $T_2$, gate fidelities, etc). This can be accessed by, for example ...
4
votes
1answer
613 views

How to use external .csv data file in quantum support vector machine qiskit python code?

I am new to python programming and Qiskit. I would like to ask can we use sklearn for adding external .csv data file before Qiskit libraries, or without sklearn, we can do or is there any other Qiskit ...
3
votes
2answers
220 views

IBM Quantum Experience API Without QISKit

I am a computer science master's student who is doing research in the field of quantum computing. I have an IBM quantum experience account(https://quantum-computing.ibm.com/) and as such I was ...
3
votes
2answers
123 views

Qiskit: Get approximate execution time

The IBMQ web interface shows both queue position and an approximate execution time for every pending job (see image below). Is there a way to retrieve this information via Qiskit? I know that ...
3
votes
5answers
250 views

How do I get the Unitary matrix of a circuit without using the 'unitary_simulator'?

I am using jupyter notebook and qiskit. I have a simple quantum circuit and I want to know how to get the unitary matrix of the circuit without using 'get_unitary' from the Aer unitary_simulator. i.e.:...
3
votes
1answer
115 views

How to make a half adder for x number of qubits with min. cost?

How to make a half adder for N inputs and getting the output on another x+1 output. Where x ...
2
votes
2answers
152 views

Conjugate transpose of a U-gate

I want to be able to create the circuit depicted below, but running the code below results in an empty circuit when viewing the job afterwards. ...
2
votes
0answers
521 views

Decomposition of an arbitrary gate using given matrix in Qiskit

If I have an arbitrary non-unitary matrix of say $$ U = \begin{pmatrix} 1.5 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1.6 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ \end{...
1
vote
1answer
180 views

A problem with application of multi controlled rotation gates [closed]

This message pops up when I run an mcrx gate The mcrx gate needs a single qubit as target. Here is a part of code I run: ...
1
vote
2answers
157 views

How to measure a qubit Hamiltonian in qiskit

I am using qiskit to get some measurement results of observables similar to the Hamiltonian. Can someone provide the way how qiskit measures the Hamiltonian (Jordan-Wigner transformed) when using VQE? ...
1
vote
1answer
60 views

Bit Flip, Seperable state and Several Question about Cirq

1)I want to use noise model for my state and bit_flip is not defined on cirq. ...
0
votes
3answers
155 views
8
votes
3answers
3k 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 ...
10
votes
3answers
483 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{...
9
votes
3answers
4k 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^{...
4
votes
1answer
649 views

How good is basic_device_noise_model() simulating the noise in the quantum computer?

Is there any paper or article about the performance of the noise model using basic_device_noise_model()? For example, like the noise model in the code below. ...
8
votes
2answers
1k 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 ...
11
votes
3answers
708 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 ...
3
votes
2answers
192 views

How can I load a probability distribution using a quantum circuit in Qiskit?

Can someone suggest me a way to load a distribution (for example a discretized Gaussian distribution) into a quantum computer using a quantum circuit? I tried to implement the code using Qiskit.
20
votes
4answers
3k 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' ...
13
votes
2answers
390 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 + [...] + - ...
8
votes
1answer
339 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 ...
8
votes
3answers
1k 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 (...
8
votes
2answers
2k 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 ...
7
votes
2answers
978 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
2answers
429 views

Checking value of variable using quantum approach

A beginner question after watching few videos. Say, var=a; var can be either of two values, ...
4
votes
3answers
2k views

Comparing run times on IBM Quantum Experience

I have run this program - ...
4
votes
1answer
531 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 ...
4
votes
3answers
480 views

How to plot custom gate labels in Qiskit?

How can I create a custom gate in qiskit that is plotted using latex formatting (or another type of formatting)? For example the following code generates a circuit diagram ...
3
votes
2answers
301 views

How many shots should one take to get a reliable estimate in a quantum program?

When testing my quantum programs, I wonder how many shots I must take to get a specific accuracy. Are there any papers that you can recommend that analyze this?
2
votes
2answers
225 views

Unit testing for quantum programs?

Does unit testing on real quantum computers make sense as any observation in the quantum system can cause the system to loose its superposition state?