TransWikia.com

Hadamard gate for three qubits; inconsistency between IBM and Matlab

Quantum Computing Asked on December 1, 2020

I am trying to build a large and quite complex three qubit quantum circuit on IBMs quantum computer. I have a specific unitary which I am trying to implement and I am building a circuit following the paper ‘Realisation of a general three qubit quantum unitary’. I am checking the unitary at each stage of the circuit on Matlab, just to make sure I fully understand it, but I have come across something which I cannot explain. I have split the circuit into two unitaries, $U_a$ and $U_b$ and for each unitary separately my IBM unitary agrees with my Matlab unitary,however when I combine the two circuits in IBM and multiply the two unitaries in Matlab I get different results. The problem boils down to an issue I am having with the Hadamard gate. Consider the following two IBM circuits

#both independently correct
circuit2 = QuantumCircuit(3);
circuit2.u3(1,1,1,2);
job = execute(circuit2, backend)
job.result().get_unitary(circuit2, decimals=6)

i.e. a three qubit circuit where a unitary acts on the final qubit (IBM’s final qubit is the first qubit in more widely used bra-ket notation), and the second circuit is:

#both independently correct
circuit2 = QuantumCircuit(3);
circuit2.h(2)
job = execute(circuit2, backend)
job.result().get_unitary(circuit2, decimals=6)

i.e. a three qubit circuit with a Hadamard gate on the final qubit. These produce the following two unitaries

   0.8776 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i  -0.2590 - 0.4034i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i
   0.0000 + 0.0000i   0.8776 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i  -0.2590 - 0.4034i   0.0000 + 0.0000i   0.0000 + 0.0000i
   0.0000 + 0.0000i   0.0000 + 0.0000i   0.8776 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i  -0.2590 - 0.4034i   0.0000 + 0.0000i
   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.8776 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i  -0.2590 - 0.4034i
   0.2590 + 0.4034i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i  -0.3652 + 0.7980i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i
   0.0000 + 0.0000i   0.2590 + 0.4034i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i  -0.3652 + 0.7980i   0.0000 + 0.0000i   0.0000 + 0.0000i
   0.0000 + 0.0000i   0.0000 + 0.0000i   0.2590 + 0.4034i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i  -0.3652 + 0.7980i   0.0000 + 0.0000i
   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.2590 + 0.4034i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i  -0.3652 + 0.7980i
    0.7071         0         0         0    0.7071         0         0         0
         0    0.7071         0         0         0    0.7071         0         0
         0         0    0.7071         0         0         0    0.7071         0
         0         0         0    0.7071         0         0         0    0.7071
    0.7071         0         0         0   -0.7071         0         0         0
         0    0.7071         0         0         0   -0.7071         0         0
         0         0    0.7071         0         0         0   -0.7071         0
         0         0         0    0.7071         0         0         0   -0.7071

I have taken these unitaries from my Matlab code, not the IBM output but they are the same in both softwares. Now the bizarre part is when I multiply these unitaries in Matlab using the following code

function test=utottest(x)
x1=[1,1,1];
Hadamard=1/sqrt(2)*[1 1;1 -1];

R1=kron(U1IBM(x1),eye(4));
R12=kron(Hadamard,eye(4));


test=R12*R1;

function U1=U1IBM(x)
% single qubit unitary 
th=x(1);
phi=x(2);
lam=x(3);

U1=[cos(th/2) -exp(i*lam)*sin(th/2); exp(i*phi)*sin(th/2) exp(i*lam+i*phi)*cos(th/2)];
end
end

the unitary produced is different to that produced by the following IBM circuit

circuit2 = QuantumCircuit(3);
circuit2.u3(1,1,1,2);
circuit2.h(2)
job = execute(circuit2, backend)
job.result().get_unitary(circuit2, decimals=6)

I do not understand what is happening here. Can anyone explain/reconcile this difference?

One Answer

Someone pointed out where I was going wrong. The two unitaries being produced were the same up to a global phase shift

Answered by LOC on December 1, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP