Toffoli Gate Using Two-Qubit Gates Name root sigma x, rsx in qgates.h library The first input is the control input, like cnot. This is a controlled rotation, thus matrix is: |1+0i 0 0 0 | |0 1+0i 0 0 | = rsx |0 0 .5+.5i .5-.5i | |0 0 .5-.5i .5+.5i | conjugate transpose, rsxt is |1+0i 0 0 0 | |0 1+0i 0 0 | = rsxt |0 0 .5-.5i .5+.5i | |0 0 .5+.5i .5-.5i | Using kets, |x> = (a+bi)|0> + (c+di)|1> = vector |a+bi c+di| |0> = vector |1 0| by definition, called a "pure" ket |1> = vector |0 1| input |0>|0> = |00> = |1 0 0 0| input state (tensor product) output state = rsx * input state |00> = rsx * |1 0 0 0| = |1 0 0 0| = |00> = |0>|0> |01> = rsx * |0 1 0 0| = |0 1 0 0| = |01> = |0>|1> |10> = rsx * |0 0 1 0| = |0 0 .5+.5i .5-.5i | = |1>|.5+.5i .5-.5i> |11> = rsx * |0 0 0 1| = |0 0 .5-.5i .5+.5i | = |1>|.5-.5i .5+.5i> state kets Toffoli circuit, X is cnot a ----. -------------.-----------.----- a | | | | | b1 | b ------------.------X-----.-----X----- b2 should be just b | | | | c1 | c2 | c ---rsx-----rsx----------rsxt--------- cout should be same as Toffoli See don_t.cpp for program source of simulation See don_t_cpp.out for program simulation output