I am currently writing a script to automate the creation of parity curves for a 2 qubit bell state and then calculate fidelity and proving entanglement from that (inspired by this paper). It was going really well. I am able to run simulations perfectly for states 00 and its complement state 10 (getting fidelity values on ibmqx4 of roughly 0.7). Although, it then starts to get weird running states 11 and its complement 01. Although I haven't run state 01 on the real machine yet, the simulation of it runs perfectly. State 11 however, doesn't. As far as I understand 11 and 01 should output similar results. Here's a sample of my 01 states results.


As you can see, a variety of states come out, allowing me to calculate parity. Running exactly the same code with state 11 instead gives


which, obviously looks a lot more like a generic bell state with no rotation. The code used to set up the circuit and rotation for simulation is shown below. The math for theta, lam and phi for states 00 and 10 are taken from the paper mentioned above (on the second column of text on page 2). Math for states 11 and 01 are not on the paper but was worked out by my supervisor.

# Set range for rotation 
phi_range = np.linspace(0, np.pi, 128)

for phi_value in phi_range:
    # inside the loop because putting it outside breaks it and makes it run 
    # really really slow
    qr = QuantumRegister(2, name='qr')
    cr = ClassicalRegister(2, name='cr')
    bell = QuantumCircuit(qr, cr, name='bell')

    # Set the details of the rotation
    if startingState == '00' or startingState == '10':
        theta = np.pi/2
        lam = -phi_value - np.pi/2

    elif startingState == '01' or startingState == '11':
        theta = phi_value
        lam = 0 - np.pi/2
        raise ValueError('Setting rotation problems')

    phi = -lam

    # initializing the starting state of the circuit (done separately to 
    # above for clarity)
    if startingState == '01':
    elif startingState == '10':
    elif startingState == '11':

    # this is the bell state code itself
    bell.cx(qr[0], qr[1])

    bell.u3(theta, lam, phi, qr)

    bell.measure(qr[0], cr[0])
    bell.measure(qr[1], cr[1])

I have checked that this creates the correct circuit several times over, and again, it works for all states except 11. Can anyone work out why?

  • $\begingroup$ Thanks for the question. Could you explain what phi is in your program? $\endgroup$ Jun 18 '19 at 12:35
  • $\begingroup$ @JamesWootton Thanks for the reply. The u3 gate needs 4 arguments, as far as I could work out they are rotations around the x, y and z axis respectively plus the 4th argument being the quantum register. If that is correct (which I'm not 100% sure about), that would mean phi is rotation around the z axis. This is the qiskit documentation of the u3 gate. The matrix equation for the gate is shown in the paper linked at the top. $\endgroup$
    – thewolfaxe
    Jun 18 '19 at 13:26
  • $\begingroup$ Ah, sorry. I mean phi_value. The thing you loop over $\endgroup$ Jun 18 '19 at 14:21
  • $\begingroup$ @JamesWootton No worries, phi_value loops through phi_range, which is just a array of (in this case 128) numbers between 0 and pi. It later allows me to create a nice evenly spaced plot of the parity at the corresponding phi_value. $\endgroup$
    – thewolfaxe
    Jun 18 '19 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.