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

2
votes
1answer
44 views

How to find a common eigenstate of commuting operators?

I have multiple different operators in matrix form and I need to find their common eigenstates. The challenge is that the common eigenstate is in a superposition of multiple states and isn't just a ...
2
votes
1answer
40 views

Eliminating a term of a superposition state

Is there a way of eliminating a term of a superposition state? Let's say I have the state $$\frac{1}{\sqrt 2}|00\rangle + \frac{1}{2}|01\rangle + \frac{1}{2}|10\rangle$$ What operation would I do to ...
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?
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 ...
3
votes
1answer
74 views

Counting in Q#: number of solutions

I have this program derived from Microsoft Quantum Katas for counting (see here): ...
2
votes
0answers
38 views

Grover search for basis states with complex coefficents and multiple marked states

I tried to run Grover's search for basis states with complex coefficients, including the marked basis (complex coefficients because the states are obtained from inverse QFT), but it could not amplify ...
1
vote
1answer
27 views

Perform quantum gate operations using state vectors and matrices

I am getting confused as to how to perform gate operations using matrices and am hoping someone will help me walk through this example. Say I want to perform a Pauli-X gate on the 3rd qubit in a 3-...
3
votes
1answer
19 views

Plotting Bloch sphere in QuTiP

Is there anyone who reproduced the Bloch sphere given in the paper QuTiP: An open-source Python framework for the dynamics of open quantum systems by J. R. Johansson, P. D. Nation, Franco Nori? I am ...
3
votes
1answer
59 views

Can't draw figures with Qiskit in Visual Studio

I'm using Qiskit in Visual Studio 2019. I want to draw quantum circuits, but it only shows their sizes with text instead of figures. The output on the interactive window is like this. ...
3
votes
1answer
42 views

About the Qiskit draw function

Where does Qiskit put the rendered figure created by circuit.draw(output='mpl')?
3
votes
0answers
71 views

Measurement inconsistency in Qiskit

I am using Qiskit in an algorithm. In the end, I am measuring exactly a register of 4 qubits but the histograms show states with 5 qubits. This is the code I used: ...
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 ...
2
votes
1answer
43 views

How to define custom controlled unitaries in OPENQASM 2.0?

According to the OPENQASM 2.0 documentation, it's possible to define custom unitary gates using the format: gate name(params) qargs { body } where the optional ...
4
votes
1answer
35 views

How to see the QASM code corresponding to compiled Q# function?

I'm learning Q#. Is there any way to see the QASM code of a Q# function I write, the same way I can see the disassembly of a C# function?
5
votes
1answer
64 views

How does measurement calibration work?

One of the possible ways to improve the results of an experiment on the IBM machine using the Qiskit language is to use the measurement calibration methods. This is the link to the documentation. I ...
3
votes
3answers
149 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^{...
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 ...
1
vote
0answers
60 views

How to run quantum SVM algorithm from Qiskit in real IBM Quantum Computer using IBMQ?

I'm trying to run QSVM algorithm in IBMQ experience, want to run in one of those real quantum computers. ...
3
votes
3answers
248 views

How to run algorithms on IBMQ via Qiskit-Aqua?

I am trying to run an optimization problem on IBMQ. Running the same code on QASM simulator works fine. However, changing only the backend name to IBMQX takes long time. I am aware of the queues ...
1
vote
0answers
16 views

How to plot decision boundary with support vectors when running quantum SVM algorithm?

I'm working on QSVM to know the difference between SVM and QSVM. How much better quantum machine learning can do when compared to classical machine learning algorithms? Part of my code: ...
5
votes
1answer
225 views

Quantum SVM Algorithm Error on import

I am experimenting with some Qiskit ACQUA AI algorithms which require the following import statement: from datasets import * However, ...
2
votes
2answers
141 views

Result of a job for a list of circuits on QISKit

Suppose Circuits= [circuit1, circuit2, ..., circuitn] is a list of defined circuits. Then, ...
0
votes
1answer
125 views

How do I translate a quantum circuit for computing x + y mod 8 into a program?

I have made the above quantum circuit that gives the mod $8=2^3$ operation between $|x\rangle$ and $|y\rangle$. Now I want to write its corresponding program using some language. Where can I do that i....
2
votes
1answer
43 views

How to prepare a statistical mixture of $|0,0\rangle $ and $ |1,1\rangle $ in QuTiP?

A QuTiP novice here. It's easy to prepare a pure state in QuTiP. For example, to prepare $\frac{1}{\sqrt{2}}(|0,0\rangle + |1,1\rangle)$: ...
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 ...
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 ...
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 ...
2
votes
1answer
54 views

How do I multiply an integer and a double in Q#?

If I write this: function f(n: Int) : Double { return 1.5*n; } I get an error: ...
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 ...
1
vote
1answer
231 views

How to measure in an arbitrary basis in Q#?

Q# has a measurement operator defined as follows according to the docs: operation Measure (bases : Pauli[], qubits : Qubit[]) : Result Where you give a Pauli gate ...
2
votes
1answer
56 views

Programmatic access to wavefunction in Q# for tests

I'm trying to write unit tests for some small Q# operations. It would be ideal if I could access the wavefunction. Is there a way to get it? I found ...
2
votes
1answer
51 views

Type error creating R gate in Q#?

The R operation in Q# is listed by Microsoft in the documentation as follows operation R (pauli : Pauli, theta : Double, qubit : Qubit) : Unit However, when I try ...
3
votes
1answer
95 views

How does the cnx gate work in Qiskit (Python)?

Could somebody explain the cnx operator, and how it operates on its qubit parameters to flip the target qubit in Qiskit (Python)?
1
vote
1answer
56 views

Order of controls and targets of cnx gates in Qiskit (Python)

In the following piece of code: cnx(qwc, q[0], q[1],q[2],q[3]) in what order control qubits and target qubit are? Which qubit is inverted for which values of ...
2
votes
1answer
106 views
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 ...
1
vote
1answer
48 views

Default value for a state created by QuantumRegister

What's the default value for a state created by QuantumRegister(1,'name_of_the_register')? Is it a $|0\rangle$ or a $|1\rangle$?
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}{...
2
votes
1answer
32 views

How to draw a multiple qubit controlled NOT gate using qasm2circ?

In Example 6, the case of multiple qubit controlled custom $U$ gate is covered, but I want to reuse the standard NOT symbol i.e. $\bigoplus$. Say I want to draw this circuit, but with a $\bigoplus$ ...
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 ...
3
votes
1answer
69 views

Drawing tangent vectors to the Bloch sphere with qutip

I need to plot drawings of qubit dynamics on the Bloch sphere. I know QuTip allows to do such drawings but I specifically need to represent evolution velocities on the Bloch sphere so I need to draw ...
4
votes
0answers
107 views

How to build a quantum circuit representing the Ising Model?

Can someone explain to me how to build a quantum circuit representing the Ising Model? I just want to understand how to represent the Ising Model for the purposes of quantum state label classification....
2
votes
1answer
90 views

Experiment runtime on IBMQ

I have been trying to get the runtime of my experiment on IBM's quantum computer. I am using the classic stuff, i.e ...
4
votes
1answer
164 views

How to create the oracle matrix in Grover's algorithm?

I'm trying to implement Grover's algorithm in pyQuil, but I'm having trouble creating the oracle matrix given the function $f$, where $f(x)=1$ if $x=w$ and $f(x)=0$ otherwise. In most of the ...
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 ...
1
vote
1answer
50 views

How do you start a simulation with a random initial state in Cirq?

How do you create a random initial state by modifying the $2^{n}$ vector amplitudes instead of starting every simulation at $|0000...000\rangle$?
5
votes
0answers
54 views

Graphing the decoherence of qubits being used to perform an algorithm

How would I be able to graph the decoherence of qubits being used to perform an algorithm? I'm working with the IBMQ Qiskit framework and I'm trying to write a program that allows me to find the ...
1
vote
0answers
53 views

Exception encountered while running quantum-enhanced support vector machines

I am trying to run the code of the notebook example aqua/artificial_intelligence/qsvm_kernel_classification.ipynb. I save it in a python file and I have an exception at runtime the display of ...
2
votes
1answer
69 views

Qiskit DAG circuit - print information about individual gate/node by number

I created a DAG circuit in Qiskit and don't really understand how to see which gate is which. I want to call a function like dag_circuit.gate_info(gate_number), ...
1
vote
1answer
74 views

(name of gate) is not in the list of basis operations

I'm trying to define a custom gate for my computations. I decided to copy the structure in one of the files in qiskit.extensions.standard package. Here is the code ...