In[]:=
PacletInstall["https://wolfr.am/DevWQCF",ForceVersionInstall->True]​​<<Wolfram`QuantumFramework`
Out[]=
PacletObject
Name: Wolfram/QuantumFramework
Version: 1.0.24


Some problem-solving (QuantumState and QuantumBasis)


QuantumOperators


Problem solving (QuantumOperator)

- create a uniform superposition of 8-qubits using QuantumState only
- create the same state, by applying Hadamard operators on a register state
In[]:=
QuantumState[{"UniformSuperposition",8}]
Out[]=
QuantumState
Pure state
Qudits: 8
Type: Vector
Dimension: 256
Picture: Schrödinger
​
Purity: 1.
​
Von Neumann Entropy:
0.
b
​
Dimensions: {2,2,2,2,2,2,2,2}
​
ParameterArity: 0
Parameters: {}

In[]:=
QuantumState[{"Register",0}]
Out[]=
|0〉
In[]:=
QuantumOperator[{"H",8}]@QuantumState[{"Register",Table[2,8]}]
Out[]=
QuantumState
Pure state
Qudits: 8
Type: Vector
Dimension: 256
Picture: Schrödinger
​

In[]:=
QuantumOperator[{"H",8}][]
Out[]=
QuantumState
Pure state
Qudits: 8
Type: Vector
Dimension: 256
Picture: Schrödinger
​

In[]:=
QuantumOperator[{"H",9}][]
Out[]=
QuantumState
Pure state
Qudits: 9
Type: Vector
Dimension: 512
Picture: Schrödinger
​

In[]:=
QuantumOperator["H",{1,2,3,4,5,6,7,8}]
Out[]=
QuantumOperator

Picture: Schrödinger
Arity: 8
Dimension: 256→256
Qudits: 8→8
Data not in notebook. Store now

- Explore why Pauli-Z is also called phase flip
In[]:=
QuantumOperator["Z"]
Out[]=
|0〉〈0|-|1〉〈1|
In[]:=
QuantumOperator["Z"]@QuantumState[{a,b}]
Out[]=
a|0〉-b|1〉
- Create the rotation in the Bloch sphere, around an arbitrary unit vector
n
(usually this gate is denoted as
R
n
(θ)=Exp[-θ/2
n
.
σ
]
In[]:=
n={nx,ny,nz};
In[]:=
n.{"X","Y","Z"}
Out[]=
Xnx+Yny+Znz
In[]:=
QuantumOperator[{"R",θ,n.{"X","Y","Z"}}]
Out[]=
Failure

Message:
Wolfram`QuantumFramework`PackageScope`QuantumOperatorQ
​[​
QuantumOperator[n.{X,Y,Z}]
​] did not return True.
Tag:
ConfirmationFailed

In[]:=
Exp[-Iθ/2n.Table[QuantumOperator[pauli],{pauli,{"X","Y","Z"}}]]["Simplify"]
Out[]=
-
1
2

2
nx
+
2
ny
+
2
nz
θ

nz-

2
nx
+
2
ny
+
2
nz
θ

nz+1+

2
nx
+
2
ny
+
2
nz
θ


2
nx
+
2
ny
+
2
nz
(|0〉〈0|)
2
2
nx
+
2
ny
+
2
nz
-
-
1
2

2
nx
+
2
ny
+
2
nz
θ

-1+

2
nx
+
2
ny
+
2
nz
θ

(nx-ny)(|0〉〈1|)
2
2
nx
+
2
ny
+
2
nz
-
-
1
2

2
nx
+
2
ny
+
2
nz
θ

-1+

2
nx
+
2
ny
+
2
nz
θ

(nx+ny)(|1〉〈0|)
2
2
nx
+
2
ny
+
2
nz
+
-
1
2

2
nx
+
2
ny
+
2
nz
θ

-1+

2
nx
+
2
ny
+
2
nz
θ

nz+1+

2
nx
+
2
ny
+
2
nz
θ


2
nx
+
2
ny
+
2
nz
(|1〉〈1|)
2
2
nx
+
2
ny
+
2
nz
In[]:=
QuantumOperator[{"R",θ,nx"X"+ny"Y"+nz"Z"}]["Simplify"]
Out[]=
-
1
2

2
nx
+
2
ny
+
2
nz
θ

nz-

2
nx
+
2
ny
+
2
nz
θ

nz+1+

2
nx
+
2
ny
+
2
nz
θ


2
nx
+
2
ny
+
2
nz
(|0〉〈0|)
2
2
nx
+
2
ny
+
2
nz
-
-
1
2

2
nx
+
2
ny
+
2
nz
θ

-1+

2
nx
+
2
ny
+
2
nz
θ

(nx-ny)(|0〉〈1|)
2
2
nx
+
2
ny
+
2
nz
-
-
1
2

2
nx
+
2
ny
+
2
nz
θ

-1+

2
nx
+
2
ny
+
2
nz
θ

(nx+ny)(|1〉〈0|)
2
2
nx
+
2
ny
+
2
nz
+
-
1
2

2
nx
+
2
ny
+
2
nz
θ

-1+

2
nx
+
2
ny
+
2
nz
θ

nz+1+

2
nx
+
2
ny
+
2
nz
θ


2
nx
+
2
ny
+
2
nz
(|1〉〈1|)
2
2
nx
+
2
ny
+
2
nz
In[]:=
QuantumOperator[{"R",θ,n.{"X","Y","Z"}}]["Simplify"]
Out[]=
-
1
2

2
nx
+
2
ny
+
2
nz
θ

nz-

2
nx
+
2
ny
+
2
nz
θ

nz+1+

2
nx
+
2
ny
+
2
nz
θ


2
nx
+
2
ny
+
2
nz
(|0〉〈0|)
2
2
nx
+
2
ny
+
2
nz
-
-
1
2

2
nx
+
2
ny
+
2
nz
θ

-1+

2
nx
+
2
ny
+
2
nz
θ

(nx-ny)(|0〉〈1|)
2
2
nx
+
2
ny
+
2
nz
-
-
1
2

2
nx
+
2
ny
+
2
nz
θ

-1+

2
nx
+
2
ny
+
2
nz
θ

(nx+ny)(|1〉〈0|)
2
2
nx
+
2
ny
+
2
nz
+
-
1
2

2
nx
+
2
ny
+
2
nz
θ

-1+

2
nx
+
2
ny
+
2
nz
θ

nz+1+

2
nx
+
2
ny
+
2
nz
θ


2
nx
+
2
ny
+
2
nz
(|1〉〈1|)
2
2
nx
+
2
ny
+
2
nz
- create a canonical gate, which is a 3-parameter quantum logic gate that acts on two qubitsExp[- π/2
(
t
x
XX+
t
y
YY+
t
z
ZZ
)]
In[]:=
Exp[-IPi/2QuantumOperator[tx"XX"+ty"YY"+tz"ZZ"]]
Out[]=
1
2
1
2
π(tx-ty-tz)

+
1
2
-
1
2
π(tx-ty+tz)

(|00〉〈00|)+-
1
2
1
2
π(tx-ty-tz)

+
1
2
-
1
2
π(tx-ty+tz)

(|00〉〈11|)+
1
2
-
1
2
π(tx+ty-tz)

+
1
2
1
2
π(tx+ty+tz)

(|01〉〈01|)+
1
2
-
1
2
π(tx+ty-tz)

-
1
2
1
2
π(tx+ty+tz)

(|01〉〈10|)+
1
2
-
1
2
π(tx+ty-tz)

-
1
2
1
2
π(tx+ty+tz)

(|10〉〈01|)+
1
2
-
1
2
π(tx+ty-tz)

+
1
2
1
2
π(tx+ty+tz)

(|10〉〈10|)+-
1
2
1
2
π(tx-ty-tz)

+
1
2
-
1
2
π(tx-ty+tz)

(|11〉
〈00|)+
1
2
1
2
π(tx-ty-tz)

+
1
2
-
1
2
π(tx-ty+tz)

(|11〉〈11|)
In[]:=
QuantumOperator[{"R",Pi,tx"XX"+ty"YY"+tz"ZZ"}]
Out[]=
1
2
1
2
π(tx-ty-tz)

+
1
2
-
1
2
π(tx-ty+tz)

(|00〉〈00|)+-
1
2
1
2
π(tx-ty-tz)

+
1
2
-
1
2
π(tx-ty+tz)

(|00〉〈11|)+
1
2
-
1
2
π(tx+ty-tz)

+
1
2
1
2
π(tx+ty+tz)

(|01〉〈01|)+
1
2
-
1
2
π(tx+ty-tz)

-
1
2
1
2
π(tx+ty+tz)

(|01〉〈10|)+
1
2
-
1
2
π(tx+ty-tz)

-
1
2
1
2
π(tx+ty+tz)

(|10〉〈01|)+
1
2
-
1
2
π(tx+ty-tz)

+
1
2
1
2
π(tx+ty+tz)

(|10〉〈10|)+-
1
2
1
2
π(tx-ty-tz)

+
1
2
-
1
2
π(tx-ty+tz)

(|11〉
〈00|)+
1
2
1
2
π(tx-ty-tz)

+
1
2
-
1
2
π(tx-ty+tz)

(|11〉〈11|)
In[]:=
QuantumOperator["XX"]==QuantumOperator[{"X"->1,"X"->2}]
Out[]=
True
- create Givens gate: Exp[- θ/2 (YX-XY)]
In[]:=
QuantumOperator[{"R",θ,"YX"-"XY"}]
Out[]=
|00〉〈00|+
-θ

2
+
θ

2
(|01〉〈01|)+-
1
2

-θ

+
1
2

θ

(|01〉〈10|)+
1
2

-θ

-
1
2

θ

(|10〉〈01|)+
-θ

2
+
θ

2
(|10〉〈10|)+|11〉〈11|
- Pauli power gates are
t
σ
i
. Show that they are the same as corresponding rotation with the angle π t
(* up-to a phase Exp[I Pi/2 t] *)
In[]:=
t
QuantumOperator["X"]
==Exp[IPi/2t]QuantumOperator[{"R",πt,"X"}]//Simplify
Out[]=
True
- given a [fractional] phase shift gate (ie a phase operator an angle
2π/
n
2
), show that
P
1
=Z,
P
2
=Sand
P
3
=T
In[]:=
QuantumOperator[{"Phase",2π/2^n}]==QuantumOperator[{"PhaseShift",n}]
Out[]=
True
In[]:=
QuantumOperator[{"PhaseShift",1}]==QuantumOperator["Z"]​​QuantumOperator[{"PhaseShift",2}]==QuantumOperator["S"]​​QuantumOperator[{"PhaseShift",3}]==QuantumOperator["T"]
Out[]=
True
Out[]=
True
Out[]=
True
In[]:=
QuantumCircuitOperator["Fourier"]
Out[]=
- a global phase in front of a quantum state is not observable. Apply a global phase to a 2D random quantum state, and test if it is the same as the original one
States equality testing is up-to a phase, but not for operators
Find ZYZ decomposition of a random unitary operator
Create Berkeley B operator: Exp[ π/8 (2 XX + YY)]

QuantumMeasurementOperator

Either usual PVMs or generic POVMs
Think of it very similar to quantum operator (given basis, and order)
POVM: