Overview
The absolute basics for beginners

Welcome to the absolute beginner’s guide to QuTIpy! If you have comments or suggestions, please don’t hesitate to reach out!

QuTIpy (Quantum Theory of Information for Python; pronounced /cutiɛ paɪ/) is an open source Python library that’s used for performing calculations with quantum states, channels and protocols. While there are many quantum information theory toolboxes that allow the user to perform basic operations such as the partial transposition, new tests are constantly discovered.

To install QuTIpy, we strongly recommend using a scientific Python distribution. If you’re looking for the full instructions for installing QuTIpy on your operating system, see Installing QuTIpy.
If you already have Python, you can install QuTIpy with:
$ python -m pip install https://github.com/sumeetkhatri/QuTIpy.git

To access QuTIpy and its functions import it in your Python code like this:
# Importing necessary dependencies
import cvxpy
import numpy as np
# Importing QuTIpy
from qutipy.general_functions import dag, eye, ...
We suggest numpy and cvxpy to be imported as complimentary packages.

We can start with a Complex Conjugate Transpose as an example for our demonstration.
Let's define an arbitrary matrix. Say X:
X=[12345678910111213141516]X=\begin{bmatrix} 1 & 2 & 3 & 4 \\ 5 & 6 & 7 & 8 \\ 9 & 10 & 11 & 12 \\ 13 & 14 & 15 & 16 \end{bmatrix}
# Creating an arbitrary matrix
X = np.array(
[
[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9, 10, 11, 12],
[13, 14, 15, 16]
]
)
Now that we have our matrix X defined, we can import the dag function from our QuTIpy library and use it to find the complex conjugate transpose of our defined matrix.
from qutipy.general_functions import dag
# getting the complex conjugate transpose of `X`
dag(X)
The output will be the Complex Conjugate Transpose of the array X :
# Output
np.array([
[1, 5, 9, 13],
[2, 6, 10, 14],
[3, 7, 11, 15],
[4, 8, 12, 16]
])

Let's jump into another common example, Driac Notation or Bra-Ket Notation as an example for our next demonstration.
The Bra-Ket notation is a concise and convenient way to describe quantum states.
A Ket is of the form
v{\displaystyle |v\rangle }
. Mathematically it denotes a vector,
v{\displaystyle {\boldsymbol {v}}}
, in an complex vector space
V{\displaystyle V}
, and physically it represents a state of some quantum system. An example of a Ket can be
r=[xyz]{\displaystyle |r\rangle } = \begin{bmatrix} x \\ y\\ z\end{bmatrix}
can represent a vector
r=[xyz]\vec{r} = \begin{bmatrix} x \\ y\\ z \end{bmatrix}
.
A bra is of the form
f{\displaystyle \langle f|}
. Mathematically it denotes a linear form
f:VC{\displaystyle f:V\to \mathbb {C} }
, i.e. a linear map that maps each vector in
V{\displaystyle V}
to a number in the complex plane
C{\displaystyle \mathbb {C} }
. Letting the linear functional
f{\displaystyle \langle f|}
act on a vector
v{\displaystyle |v\rangle }
is written as
fvC{\displaystyle \langle f|v\rangle \in \mathbb {C} }
.
Lets define a ket v for
v=[10]{\displaystyle |v\rangle } = \begin{bmatrix} 1 \\ 0 \end{bmatrix}
,
To define
v{\displaystyle |v\rangle }
using numpy, one need to define the vector space as matrices .
import numpy as np
# Define a Ket using numpy
v = np.array([
[1.],
[0.]
])
But one can directly define
v{\displaystyle |v\rangle }
with QuTIpy.
Example: ket( 2, 0 )=
0{\displaystyle |0\rangle }
and ket( 2, 1 )=
1{\displaystyle |1\rangle }
from qutipy.general_functions import ket
# Define a Ket using QuTIpy
v = ket(2, 0)
The ket function takes the vector space as the first argument, and the ket value as the second argument.
Different states of different sizes can be generated based on the arguments.
ket( 2, 1 )=
01{\displaystyle |01\rangle }
=
[01]\begin{bmatrix} 0 \\ 1 \end{bmatrix}
ket( 3, 1 )=
010{\displaystyle |010\rangle }
=
[010]\begin{bmatrix} 0 \\ 1 \\ 0 \end{bmatrix}
Copy link
On this page
QuTIpy: the absolute basics for beginners
Welcome to QuTIpy!
Installing QuTIpy
How to import
Starting with an example code
Bra-Ket Notation