Question
The aim of this assignment is to practice understanding of basic mathematical structures in quantum computing by implementing them in Python 3. The specific goal
The aim of this assignment is to practice understanding of basic mathematical structures in quantum computing by implementing them in Python 3. The specific goal is to create a library of classes for handling a quantum register and its measurement, and transformation of the register through linear operators.
You are allowed to use pythons functionality for complex numbers, see here:
https://docs.python.org/3/library/cmath.html
Specifically, create classes with the following functionality, and use it to test if they work (e.g., test Grovers search 2-qubit algorithm):
QuantumRegister
-
1) initialization: with number n (number of qubits, default 1, max: 15), optional argument: 2^n complex numbers - the probability amplitudes, if not given, initialize to state Ket{0...0}
-
2) norm: returns norm of the register, that is
if register is in state |f> -
3) inner product: takes another register of the same size, and returns a single complex number, the
Hermitian inner product with that register
-
4) tensor product: takes two registers with n=n1 and n=n2, and produces a register with n1+n2 qubits, in
the correct state
-
5) measurement in computational basis: this should
a) change the state of the register to one of the computational basis states |0..0> .. |1.1> b) return a single integer - what is the binary number encoded by the basis state after measurement (e.g. |010> will return 2). Note that max n is 15, so this will always fit into a single int.
Optional (Bonus points): 6) permute qubits: takes on input a permutation vector of length n, and changes the state of the register
(the 2^n complex numbers) to the new numbering of qubits (e.g. takes (3,1,2), now qubit 3 will become qubit 1, qubit 1 will become qubit 2, and qubit 2 will become qubit 3
LinearOperator
-
1) initialization: number n (number of qubits the operator can work on, default 1), optional argument: 2^n x 2^n complex matrix (2Darray), if not given, initialize to identity matrix (diagonal matrix with 1 on the diagonal)
-
2) initialization through outer products, takes two QuantumRegisters |f> |g> of the same size n, and creates linear operator |f>
-
3) add operators: takes two linear operators A,B, and two complex number alpha, beta, and return a Linear Operator alpha*A+beta*B
4) transform register: takes QuantumRegister of size n, transforms it (changes its state) through this linear operator
Optional (Bonus points): 5) transform part of register: takes register of some arbitrary size >=n, and a set of n indices in that
register, and applies transformation to the qubits with those indices
Solution in a single .py file (classes, plus a couple of use cases) should be uploaded through Blackboard.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started