# Tag Info

8

QuantumProgram was removed in Qiskit 0.6.0. (Release Notes) Your example code is likely for an older version. You can either install Qiskit 0.5.7, or find an updated Shor's Algorithm example.

7

Yes, that notation means the Hadamard on the second qubit depends on the first qubit and the Hadamard on the third qubit depends on the first qubit. The gates aren't connected to each other in any way.

6

For most functions $f(x)$, there is nothing better than calculating all the values. After all, for most functions, there is no better way of defining the function than giving its truth table. Probably, you want to talk about the relatively small fraction of cases in which the function $f(x)$ has some reasonably compact description. In that case, you should ...

6

Running programs on a quantum computer will indeed require some routines which are not required for running them on a classical simulation. Two easiest examples are error correction (a classical simulation is perfect but a quantum device will be noisy and will require error correction to produce useful results) and translating logical qubits and gates to ...

6

You can use the controlled_by method on any Operation: op = cirq.X(target_qubit).controlled_by(control_qubit) You can also use controlled before specifying the target qubits: op = cirq.X.controlled().on(control_qubit, target_qubit) There are also built-in controlled operations such as cirq.CNOT, cirq.CZ, and cirq.CSWAP. The built-in operations are ...

6

One can recommend PennyLane by Xanadu.AI. You can find complete examples of quantum machine learning algorithms (e.g. Iris Classification), using hybrid quantum-classical computations. Additionally, they offer built-in plugins for IBM QisKit, Pyquil etc., to enable running Pennylane QML codes on IBM and Rigetti quantum hardwares.

6

Qiskit does not save the rendered Figure of the circuit anywhere, unless you provide a filename to the call. For example: circuit.draw(filename='<file_path>'). In regards to having the Figure render and stay open, you simply need to remove a line of code. If you go to where qiskit is installed in your environment, go into the file qiskit/...

6

I don't think I agree - you really do need a grasp of quantum computing mechanics (including the math) in order to do any programming TLDR: Quantum computers are so specialized and the software is so close to the physical realization that you need an understanding of the math of quantum algorithms. Here's my logic With classical computers, we have a large ...

6

Let us look at each observation and question in perspective. Before delving deep into the questions, please let me share a few reference architecture diagrams on the components of a quantum computer. We need to review the mentioned observations and understandings from a practical implementation vantage point. When we consider the quantum realm in its ...

5

Cirq distinguishes between "running" a circuit, which is generally supposed to act like hardware would (e.g. only getting samples), and "simulating" a circuit, which has more freedom. Most "simulate" methods, like cirq.Simulator().simulate(...) have a parameter initial_state which can either be a computational basis state (specified as an integer e.g. ...

5

A quick googling reveals that Bernhard Ömer has worked extensively on this topic. Check out the documentation section here. He describes the installation procedure on the corresponding GitHub page. Quantum Programming in QCL (PDF) My master thesis in computing science deals with computational and architectural questions of quantum programming and ...

5

You can build your gate with Operator and unitary function e.g: from qiskit import QuantumCircuit, QuantumRegister from qiskit.quantum_info.operators import Operator controls = QuantumRegister(2) circuit = QuantumCircuit(controls) cx = Operator([ [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0] ]) circuit.unitary(cx, [0, 1], label='...

5

When mapping a circuit to a quantum device using Qiskit, the choice of which virtual qubits (the ones in your circuit) get mapped onto which physical (device) qubits depends on whether you let qiskit decide or you implement your own initial_layout. By default, qiskit will pick the most connected subset of the device graph that fits your circuit. These ...

5

Qiskit's QuantumCircuit has mct method to build multiple-control Toffoli gate with several modes: basic, basic-dirty-ancilla, advanced, noancilla. For instance Toffoli gate with 3 control qubits: from qiskit import QuantumCircuit, QuantumRegister controls = QuantumRegister(3, "c_qb") target = QuantumRegister(1, "t_qb") circuit = QuantumCircuit(controls, ...

5

(QuantumRegister(3, 'a'), 0) means the 0th qubit in a QuantumRegister called 'a' of size 3. The other numbers (10 and 41) are node ids for the predecessors and successors of the node. So what ({(QuantumRegister(3, 'a'), 0): 41}, {}) is saying is there is an edge from node 41 along wire (QuantumRegister(3, 'a'), 0) that ends at node 2 (the node you ...

5

The question refers to the VQE, so let's start with this and Max_Cut; they can be built on the VQE. There used to be a vqe.ipynp but I can't find, look for an example. The VQE algorithm doesn't need much input. You can fill it with the paulis_dict. This could be a simple Z gate for finding the eigenvalues= -1. pauli_dict = { 'paulis': [{"coeff": {"imag"...

5

It seems like this gate is controlled on the top qubit (which I will call qubit 0) and performs a hadamard on both the other qubits (qubits 1 and 2) when the control is in state $|1\rangle$. In this case it is equivalent to separte two controlled-hadamards: each controlled on qubit 0, with qubit 1 as the target for one and qubit 2 as the target for the other....

5

As given in the documentation, if your operation is unitary, you can add the statement adjoint auto; within the operation after the body block. This will generate the adjoint (which is the inverse for unitary). Then, to use the inverse call Adjoint A(parameters)

5

In the case that your operation can be represented by a unitary operator $U$ (this is typically the case if your operation doesn't use any measurements), you can indicate that by adding is Adj to your operation's signature, letting the Q# compiler know that your operation is adjointable: open Microsoft.Quantum.Math as Math; /// # Summary /// Prepares a ...

5

Qiskit implements a transpiler which optimizes the circuits that you provide. This means it modifies the circuit so that it can be run on the backend and also optimizes it so that anything that can possibly be run in parallel is done so. To run with the maximum level of optimization you can run execute(circuit, optimization_level=3). There is more ...

5

Your circuit does not measure $q_2$ qubit after teleportation; I guess that is why teleportation of $|1\rangle$ qubit is shown incorrectly.

5

Prepare a qubit in state $|\psi\rangle=\mathrm{cos}\frac{\theta}{2}|0\rangle+\mathrm{e}^{i\phi}\mathrm{sin}\frac{\theta}{2}|1\rangle$, given the angles $\psi$ and $\theta$. Let's start with a qubit in the $|0\rangle$ state, as is customary for Q#. You can use one of the general library operations to prepare the state, such as PrepareArbitraryState. Or you ...

4

To follow up on esduran's answer, another great source is the Quantum Open Source Foundation, run the authors of the same paper. It contains a constantly updated list of all open source projects in quantum computation, which ones are active, good learning resources and community channels, as well as evaluations of the bigger software packages.

4

You use the standard rotations. In this case, you're looking for the ry operator (rotation around the y-axis). To rotate the state vector counter-clockwise around the unit circle by $\theta$, call ry with $2\theta$ or in your case $\frac{2\pi}{8}$ applied to state $|0\rangle$. from qiskit import * import numpy as np q = QuantumRegister(1) qc = ...

4

I was able to reproduce your issue by changing the key a few times... seems to be a bug. Either way, I was able to resolve my issue by removing the qiskitrc file. rm ~/.qiskit/qiskitrc (your location may vary) After that, set the key again and you should be good.

4

Your algorithm is working exactly as it should. Grover's algorithm does not monotonically converge. Instead, the better intuition is to think about a point moving around a circle at constant speed. If you choose the right moment, you will be close to a particular point, but leave it longer and it'll go past, although it will eventually come back again. ...

4

This seems normal by applying the definition of the inversion about average operator which transforms the amplitudes $\alpha_i$ by the formula : $$- \alpha_i + 2 \langle\alpha\rangle\,,$$ Apply this to your example (using the above formula for each step to verify your intermediary steps) and you should retrieve this numbers. This operator is periodic. ...

4

I don't think that's possible: Suppose your initial state is $\vert \phi\rangle$. Let $\vert \psi\rangle$ be a state with the numbers $1,4,8,13$ in superposition. Then $\langle \psi \vert \phi\rangle\neq 0$, since the states have $8$ and $13$ in common. But if we have some sort of $n$th minimum circuit $U_n$ with \$U_2\vert \phi\rangle\vert 0\rangle=\vert\phi\...

4

These messages pop up in the linter due to the way gates are dynamically added as circuit attributes in Qiskit Terra. They can safely be ignored. In a future update of Terra these warnings will disappear.

4

You are probably running Python 3.7 on Windows. There is a known issue for the bug you are seeing: https://github.com/Qiskit/qiskit-aer/issues/80

Only top voted, non community-wiki answers of a minimum length are eligible