# Tag Info

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'...

2

Just use [0.5**0.5, 0.5**0.5], or similarly np.array([np.sqrt(0.5), np.sqrt(0.5)], dtype=np.complex128). Yes, the representation will be approximate instead of exact. Mainly that means you need to use approximate comparison methods like np.allclose instead of ==. This is significantly less of a hassle than dealing with exact analytic representations, which ...

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))...

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 ...

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.

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(<...

1

You could either do a numerical approximation 1/math.sqrt(2) but that would get evaluated to a floating point approximation. You could do a symbolic expression that is left unevaluated 1/sympy.sqrt(2) Symbolic results like this can be symbolically simplified with usual rules of mathematics without resorting to calculations with their floating point ...

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