The above picture is taken from a document. Can anyone please let me know the detailed internal calculations and how it is doing? like I don't understand how after the Tdagger gate when we apply H gate, the '01' state vanishes. So what are the step-by-step calculations is happening here? It will actually help me to underatnd other complex circuits also.Please help.
1 Answer
The state progression looks like this (in my own infra):
>>> qc.reg(2, 0)
<src.lib.state.Reg object at 0x7f14e2d98d00>
>>> qc.s(0)
>>> qc.h(1)
>>> qc.psi.dump()
|00> (|0>): ampl: +0.71+0.00j prob: 0.50 Phase: 0.0
|01> (|1>): ampl: +0.71+0.00j prob: 0.50 Phase: 0.0
>>> qc.h(0)
>>> qc.psi.dump()
|00> (|0>): ampl: +0.50+0.00j prob: 0.25 Phase: 0.0
|01> (|1>): ampl: +0.50+0.00j prob: 0.25 Phase: 0.0
|10> (|2>): ampl: +0.50+0.00j prob: 0.25 Phase: 0.0
|11> (|3>): ampl: +0.50+0.00j prob: 0.25 Phase: 0.0
>>> qc.t(0)
>>> qc.psi.dump()
|00> (|0>): ampl: +0.50+0.00j prob: 0.25 Phase: 0.0
|01> (|1>): ampl: +0.50+0.00j prob: 0.25 Phase: 0.0
|10> (|2>): ampl: +0.35+0.35j prob: 0.25 Phase: 45.0
|11> (|3>): ampl: +0.35+0.35j prob: 0.25 Phase: 45.0
>>> qc.cx(1, 0)
>>> qc.psi.dump()
|00> (|0>): ampl: +0.50+0.00j prob: 0.25 Phase: 0.0
|01> (|1>): ampl: +0.35+0.35j prob: 0.25 Phase: 45.0
|10> (|2>): ampl: +0.35+0.35j prob: 0.25 Phase: 45.0
|11> (|3>): ampl: +0.50+0.00j prob: 0.25 Phase: 0.0
>>> qc.tdag(0)
>>> qc.psi.dump()
|00> (|0>): ampl: +0.50+0.00j prob: 0.25 Phase: 0.0
|01> (|1>): ampl: +0.35+0.35j prob: 0.25 Phase: 45.0
|10> (|2>): ampl: +0.50+0.00j prob: 0.25 Phase: 0.0
|11> (|3>): ampl: +0.35-0.35j prob: 0.25 Phase: -45.0
>>> qc.h(0)
>>> qc.psi.dump()
|00> (|0>): ampl: +0.71+0.00j prob: 0.50 Phase: 0.0
|01> (|1>): ampl: +0.50+0.00j prob: 0.25 Phase: 0.0
|11> (|3>): ampl: +0.00+0.50j prob: 0.25 Phase: 90.0
>>> qc.sdag(0)
>>> qc.psi.dump()
|00> (|0>): ampl: +0.71+0.00j prob: 0.50 Phase: 0.0
|01> (|1>): ampl: +0.50+0.00j prob: 0.25 Phase: 0.0
|11> (|3>): ampl: +0.50+0.00j prob: 0.25 Phase: 0.0
So the state after the $T^\dagger$ is: $$ |\psi\rangle = [ 0.5, 0.35+0.35i, 0.5, 0.35 - 0.35i ]^T $$
And indeed, multiplying the $H \otimes I$ now with $|\psi\rangle$ gives:
ops.Hadamard() * ops.Identity()
Operator([[ 0.70710677+0.j 0. +0.j 0.70710677+0.j 0. +0.j]
[ 0. +0.j 0.70710677+0.j 0. +0.j 0.70710677+0.j]
[ 0.70710677+0.j 0. +0.j -0.70710677+0.j -0. +0.j]
[ 0. +0.j 0.70710677+0.j -0. +0.j -0.70710677+0.j]])
results in:
(ops.Hadamard() * ops.Identity())(s)
State([0.70710677+0.j 0.49497473+0.j 0. +0.j
0. +0.49497473j])