I’m trying to calculate the probability amplitudes for this circuit:
My Octave code is:
sys = kron([1; 0], [1;0], [1;0])
h = 1/sqrt(2) * [1 1; 1 -1];
c = [1 0 0 0; 0 1 0 0; 0 0 0 1; 0 0 1 0];
op1 = kron(h, eye(2), eye(2));
op2 = kron(c, eye(2));
op3 = kron(eye(2), c);
op4 = kron(h, eye(2), eye(2));
op4*op3*op2*op1 * sys
The output is:
ans =
0.50000
0.00000
0.00000
0.50000
0.50000
0.00000
0.00000
-0.50000
This differs from the results the quantum circuit simulator gives me, where have I gone wrong?