Problem 1. Consider the unary gates (2 x 2 unitary matrices)
and the normalized state
calculate
Note that
Solution 1
xxxxxxxxxx1
1
using SymPyxxxxxxxxxx6
1
begin2
𝑖,π = sympy.symbols("𝑖 π")3
sqrthalf = 1/sympy.sqrt(2)4
e = sympy.exp5
⋅ = *6
end;xxxxxxxxxx13
1
begin2
N = sympy.Matrix([0 1;3
1 0])4
5
H = sqrthalf * sympy.Matrix([1 1;6
1 -1])7
8
V = sympy.Matrix([1 0;9
0 e(𝑖⋅π / 2)])10
11
W = sympy.Matrix([1 0;12
0 e(𝑖⋅π / 4)])13
end;xxxxxxxxxx4
1
begin2
ψ = sqrthalf * sympy.Matrix([1;1])3
ψᵀ = ψ'4
end;xxxxxxxxxx1
1
U = N ⋅ H ⋅ V ⋅ W;xxxxxxxxxx1
1
ψₜ = U⋅ψ;The expectation
xxxxxxxxxx1
1
𝙴 = ψᵀ ⋅ U ⋅ ψ;