Problem 1. Consider the unary gates (2 x 2 unitary matrices)
and the normalized state
calculate
Note that
Solution 1
xxxxxxxxxx
1
1
using SymPy
xxxxxxxxxx
6
1
begin
2
𝑖,π = sympy.symbols("𝑖 π")
3
sqrthalf = 1/sympy.sqrt(2)
4
e = sympy.exp
5
⋅ = *
6
end;
xxxxxxxxxx
13
1
begin
2
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;
xxxxxxxxxx
4
1
begin
2
ψ = sqrthalf * sympy.Matrix([1;1])
3
ψᵀ = ψ'
4
end;
xxxxxxxxxx
1
1
U = N ⋅ H ⋅ V ⋅ W;
xxxxxxxxxx
1
1
ψₜ = U⋅ψ;
The expectation
xxxxxxxxxx
1
1
𝙴 = ψᵀ ⋅ U ⋅ ψ;