New answers tagged

1

You cannot force a superposition to collapse in a particular direction. When you perform a measurement that removes a superposition, that 'collapse' is random, and you cannot choose which way it collapses. However, if you know what superposition you have, you can always convert it into any other state that you want to via unitary evolution (at which point ...


0

You dont have to reset classical registers they store the current measurment result of the quantum bits. I.e. the value of the classical register is not the matter what it matter is that the value they hold after the measurment.


1

i think you have done entaglment $\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$ so when you measure the first qubit the second qubit forces to be collapses to the same state as the first qubit state.


0

I find two answers: (code tested and working) Answer (1) (read the register value before the execute command) from qiskit import * qiskit.IBMQ.disable_accounts() IBMQ.enable_account('change to your api','change to your url') #backend = qiskit.IBMQ.get_backend('ibmq_16_melbourne') backend = qiskit.IBMQ.get_backend('ibmq_qasm_simulator') qr = ...


0

The c_if in Qiskit only operates on a full classical register, following the OpenQASM spec. If you would like to condition on individual bits, you have to create a new ClassicalRegister for each bit. Then you can condition on each bit separately.


3

One problem is that you are resetting the $\left|z\right\rangle$ register after applying the Controlled X(z, y) operation. Right before you reset, your $\left|z\right\rangle$ register is entangled with the other two registers, such that resetting in that way collapses any superposition on the $\left|x\right\rangle \left|y\right\rangle$ registers. While that'...


1

Answering based off of the extra clarity from your comments: Wanting to calculate the decimal value of all cr as opposed to the binary This can be done by using the Python built in function int(). This function will return the integer value of the input in base 10 (decimal). So you can retrieve the counts from the job by calling job.result().get_counts(<...


0

if you want to excute the whole quantum algorithm again and again bases on the previous result then use while loop.


2

Here is another way to flip the phase of only |0...0⟩: using (ancilla = Qubit()){ (ControlledOnInt(0, X))(register, ancilla); // Bit flips the ancilla to |1⟩ if register is |0...0⟩ Z(ancilla); // Ancilla phase (and therefore whole register phase) becomes -1 if above condition is satisfied (ControlledOnInt(0, X))...


0

Quite simply: it's on the to-do list. Here is a sneak peak of how it will be done.


Top 50 recent answers are included