5

No, quantum computers can't run for-loops faster in general. There are certain specific tasks that can be done using a for-loop that can instead be done in a different way on a quantum computer, with fewer total operations. For example, Grover search can replace the loop for x in range(N): if predicate(x): y = x with something that uses $O(\sqrt{N})$ calls ...


5

It's not a bug, if you don't give concrete names to the registers then Qiskit will number them increasingly. If you want them to have the same name, you can do that like from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister qr = QuantumRegister(2, 'q') cr = ClassicalRegister(2, 'c') circuit = QuantumCircuit(qr, cr) circuit.draw()


4

No, there isn't. We are avoiding having the means for types to impact the program flow, but I'd be interested to hear what the use case is. If is it only a matter of wanting to print the type rather than getting something that can be used within the program, then that is certainly something we could cover in the future (please consider making a feature ...


4

If you click the CX gate itself, it will be surrounded by a dashed box with a pen symbol in the top right corner. If you click this pen you can choose which qubit is the target and which is the control by drag-and-drop.


3

I tried to run your code with the same backend as you, ibmq_ourense, and also got the same kind of bad results. Although, I also tried on other backends, first the ibmq_qasm_simulator and I got the exact expectation value, so I assume there is no bug on your code since it is right with the ideal machine. I also tried with ibmq_vigo, which has a better ...


3

Here's a general strategy that doesn't quite fulfil the brief: for an $n$-qubit input where $n+1=2^k$, $k$ an integer (e.g. $n=3,k=2$), it uses $k$ ancilla qubits but no Toffolis. (You can do something similar if $n+1$ is not a powe of 2, but you'd need some classical post-processing and I'd have thought you might as well just measure the input qubits!) The ...


3

Welcome to QCSE! Sorry, but it's not possible. Quantum computers are not yet powerful enough to assist in any meaningful decryption. Currently available quantum chips, which are generally less than 100 qubits, are many orders of magnitude to small for this task. There are several other more technical reasons that this is impossible with the current state ...


3

I think the simplest way to think about this (inspired by Mark S's answer) is simply to acknowledge that with a series of slits, you'd get the correct interference pattern with a single photon. But to do an $n$-qubit computation, you need a Hilbert space of dimension $2^n$, which you're encoding in a path. In other words, you need $2^n$ possible paths. So, ...


2

I think in this case you can split the experiments into multiple jobs. The idea is that you split measurement calibration circuits generated by complete_meas_cal into a number of batches, execute the first batch and use the corresponding results to initialize a measurement correction fitter with CompleteMeasFitter. Then you can use the CompleteMeasFitter....


2

To remove the last gate you can do qc.data.pop(). Example: qc = QuantumCircuit(1) qc.h(0) qc.draw('text') output: ┌───┐ q_0: ┤ H ├ └───┘ Then: qc.data.pop() qc.draw('text') output: q_0:


2

c_if must be used on an entire ClassicalRegister. However, it is still possible to use it on a single classical bit. You would need to create a ClassicalRegister of size 1, and attach that to your circuit. This would be the register that you input into the c_if call. from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister c1 = ...


2

As I explained in my answer on a previous question of yours, the depolarizing channel is not really 'physical' - actual quantum systems don't really behave that way. So for simulations where you, for instance, investigate the performance of some code against the depolarizing channel, it doesn't really matter what the exact value of $p$ is in your simulations....


2

As @JSdJ indicated in their comment, one approach is to perform the assertion in the 𝑋-basis instead of the 𝑍-basis: open Microsoft.Quantum.Diagnostics; @Test("QuantumSimulator") operation CheckThatHPreparesPlus() : Unit { using (q = Qubit()) { within { H(q); } apply { ...


1

Well try doing this as it worked for me IBMQ.save_account("your_API_id", overwrite=True) provider = IBMQ.load_account() provider.backends()


1

Welcome Daniele! It's a fantastic question - some forms of physical hardware can measure on different axis', so you could verify the qubit state by measuring with the $| + \rangle $ and $ |-\rangle$ basis states (and, if you got $|+\rangle$ with high probability, you could assume $H |0\rangle \mapsto |+\rangle$). In Q#, I don't believe this has yet been ...


1

You can also create a Statevector, that can be directly initialized as follows: from qiskit.quantum_info import Statevector sv = Statevector.from_label('11') You can use sv.evolve(qc) to apply an operator/circuit to the state, where qc is the operator/circuit. sv.data gives you the numpy array, containing the actual implementation of the state. Check this ...


1

One potential strategy is to probabilistically estimate the qubits' probabilities. Here's some pseudocode: counts = Int[NumberOfQubits] for counter in trials: ApplyOperationToArray results = MeasureArray AddResults(results, counts) idx = maxIdx(counts) As mentioned in the comments, we cannot ascertain which qubit has the highest probability by the ...


1

Can a partial applicated operation be passed as an argument ? Yes. For example, let's say you want to pass an argument of type (Qubit => Unit) (an operation applied to a single qubit, say, a gate), and you want to get it by using Ry gate with a fixed rotation angle parameter. The signature of Ry operation is operation Ry (theta : Double, qubit : Qubit) : ...


1

@Cryoris answer is perfectly valid, but a more "Pythonic" way of doing this is with the help of the with keyword: import warnings with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=DeprecationWarning) # Run VQE here, respect the identation. # /!\ At this level of identation, warnings are no longer ignored....


1

You can add the following before running the VQE to suppress the deprecation warning import warnings warnings.filterwarnings('ignore', category=DeprecationWarning) # run VQE here That turns all the deprecation warnings off, if you want to turn them on again you can add warnings.filterwarnings('always', category=DeprecationWarning) I don't think there is a ...


1

Several quantum circuit representations for common distributions are given in uncertainty models. For generic probability distributions, you can train a quantum circuit representation using quantum generative adversarial networks. For a respective tutorial, please see here.


1

Every rotation or controlled operation you perform on each individual qubit has an error associated to it, you can check it here by selecting a computer and hovering over each Qubit, through the error range bar or through Python as you seem to have done. What I've found in my experiments is that what usually ruins an experiment is the error associated with ...


1

I believe there are several developments about this on Qiskit to make the use of Pulse easier. Try to check the PR or the issues regarding Pulse, maybe you'll find what you are looking for. I also found an issue about a QASM 3.0, I think this will interest you! :)


1

Just to add. If you do not have a possibility to switch control and target qubits, you can implement "upside down" CNOT with this circuit: $$ (H \otimes H) CNOT (H \otimes H), $$ where $H$ is Hadamard gate and $CNOT$ is controlled NOT with control qubit upside and target qubit downside.


1

I think unlike the relative phase in the answer you reference, it is a global phase in your case: Your XHP-circuit where P=ID, prepares the state: [0.707+0j,-0.707+0j], where P=X, prepares the state: [-0.707+0j, 0.707+0j]. These states are differ by a global phase ${e}^{i\pi}=-1$. But the global phase is undetectable $|ψ⟩:={e}^{iδ}|ψ⟩$, also see the answer.


1

Concerning Hamiltonian simulation, you can find very useful guide in this question. General approach to quantum circuit construction is explained in paper Elementary gates for quantum computation. Also paper Optimal Quantum Circuits for General Two-Qubit Gates can be helpful.


1

I have found the solution! The problem is that each time you use the transpile function, it generates a different transpiled circuit and the order of the outcome is not necessary the same as the order of the input, so you have to use swap gates to obtain the correct one. In order to always obtain the same circuit you have to fit the seed_transpiler (as with ...


1

All your real parts and imaginary parts are interchanged. Have you used complex(1,0) instead of complex(0,1) or something similar? Without the code one can only guess. Hope you can resolve it.


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