Following the notes "Quantum Information and Computing" lecture notes by Richard Jozsa, DAMTP Cambridge, January 2019 version.

So these are notes of notes.


Define a qubit as a $\mathbb{C}^2$ vector space.

Let $|\psi\rangle$ be a '-ket' vector in our qubit with components (and vector representation). So $|\psi\rangle = \left[\begin{matrix} \psi_0 \\ \psi_1 \end{matrix}\right]$

Let $\langle\psi| = (|\psi\rangle)^*$ define the 'bra-' vector which is the Hermitian adjoint of the respective '-ket vector.
So $\langle\psi| = \left[\begin{matrix} \overline{\psi_0} & \overline{\psi_1} \end{matrix}\right]$


1-qubit basis vectors:
Let $\{ |0\rangle, |1\rangle \}$ be our qubit vector space orthonormal basis.

$|0 \rangle = \left[\begin{matrix} 1 \\ 0 \end{matrix} \right]$, $|1 \rangle = \left[\begin{matrix} 0 \\ 1 \end{matrix} \right]$

Notice this means that the -ket vectors represented as column vectors of a matrix take on the following form to depict the orthonormal basis:
$\left[\begin{matrix} & | & \\ | 0 \rangle & | & | 1 \rangle \\ & | & \end{matrix}\right] = \left[\begin{matrix} 1 & | & 0 \\ 0 & | & 1 \end{matrix}\right]$

Using our bra- and -ket definitions, we can define the inner product of our basis as the following:

$\langle 0 | 0 \rangle = \left[ \begin{matrix} 1 & 0 \end{matrix} \right] \left[ \begin{matrix} 1 \\ 0 \end{matrix} \right] = 1$
$\langle 0 | 1 \rangle = \left[ \begin{matrix} 1 & 0 \end{matrix} \right] \left[ \begin{matrix} 0 \\ 1 \end{matrix} \right] = 0$
$\langle 1 | 0 \rangle = \left[ \begin{matrix} 0 & 1 \end{matrix} \right] \left[ \begin{matrix} 1 \\ 0 \end{matrix} \right] = 0$
$\langle 1 | 1 \rangle = \left[ \begin{matrix} 0 & 1 \end{matrix} \right] \left[ \begin{matrix} 0 \\ 1 \end{matrix} \right] = 1$

This can also be written in matrix form as:
$\left[\begin{matrix} \langle 0 | \\ --- \\ \langle 1 | \end{matrix}\right] \left[\begin{matrix} & | & \\ | 0 \rangle & | & | 1 \rangle \\ & | & \end{matrix}\right] = \left[\begin{matrix} 1 & 0 \\ -- & -- \\ 0 & 1 \end{matrix}\right] \left[\begin{matrix} 1 & | & 0 \\ 0 & | & 1 \end{matrix}\right] = \left[\begin{matrix} \langle 0 | 0 \rangle & \langle 0 | 1 \rangle \\ \langle 1 | 0 \rangle & \langle 1 | 1 \rangle \end{matrix}\right] = \left[\begin{matrix} 1 & 0 \\ 0 & 1 \end{matrix}\right]$

Notice that combining 'bra-' and '-ket' vectors will combine the 'bra(c)ket' as an inner product:
$\langle a|b \rangle = \langle a, b \rangle = (a_0 \langle 0| + a_1 \langle 1|) (\bar{b}_0 |0\rangle + \bar{b}_1 |1\rangle) = a_0 \bar{b}_0 \langle 0|0\rangle + a_1 \bar{b}_0 \langle 1|0\rangle + a_0 \bar{b}_1 \langle 0|1\rangle + a_1 \bar{b}_1 \langle 1|1\rangle = a_0 \bar{b}_0 + a_1 \bar{b}_1 $

Repeating the process using vector notation:
$\langle a|b \rangle = \langle a, b \rangle = \left[\begin{matrix} a_0 & a_1 \end{matrix}\right] \left[\begin{matrix} \bar{b}_0 \\ \bar{b}_1 \end{matrix}\right] = a_0 \bar{b}_0 + a_1 \bar{b}_1$

In analogy to differential geometry, '-ket' vectors can be thought of as vectors and 'bra-' vectors can be thought of as one-forms.

Bra(c)ket vectors combine in inner products $\langle e_i | e_j \rangle = \delta_{ij}$ in the same way that our differential geometry one-form basis $e^i = dx^i$ and vector basis $e_i = \frac{\partial}{\partial x^i}$ Combine to form an inner product: $e^i(e_j) = dx^i ( \frac{\partial}{\partial x^j} ) = \frac{\partial x^i}{\partial x^j} = \delta^i_j$



One alternative basis that comes up often:
$|+\rangle = \frac{1}{\sqrt{2}} (|0\rangle + |1\rangle)$
$|-\rangle = \frac{1}{\sqrt{2}} (|0\rangle - |1\rangle)$

Using components of our $\{ |0\rangle, |1\rangle \}$, we find:
$|+\rangle = \frac{1}{\sqrt{2}} \left[\begin{matrix} 1 \\ 1 \end{matrix}\right]$
$|-\rangle = \frac{1}{\sqrt{2}} \left[\begin{matrix} 1 \\ -1 \end{matrix}\right]$

Computing the inverse, we get:
$|+\rangle = \frac{1}{\sqrt{2}} \left[\begin{matrix} &|& \\ |0\rangle &|& |1\rangle \\ &|& \end{matrix}\right] \left[\begin{matrix} 1 \\ 1 \end{matrix}\right]$
$|-\rangle = \frac{1}{\sqrt{2}} \left[\begin{matrix} &|& \\ |0\rangle &|& |1\rangle \\ &|& \end{matrix}\right] \left[\begin{matrix} 1 \\ -1 \end{matrix}\right]$
...combined...
$\left[\begin{matrix} &|& \\ |+\rangle &|& |-\rangle \\ &|& \end{matrix}\right] = \frac{1}{\sqrt{2}} \left[\begin{matrix} &|& \\ |0\rangle &|& |1\rangle \\ &|& \end{matrix}\right] \left[\begin{matrix} 1 & 1 \\ 1 & -1 \end{matrix}\right] = \frac{1}{\sqrt{2}} \left[\begin{matrix} 1 & 1 \\ 1 & -1 \end{matrix}\right]$

So what is the $\{ |0\rangle, |1\rangle \}$ basis in terms of the $\{ |+\rangle, |-\rangle \}$ basis?

$\left[\begin{matrix} &|& \\ |0\rangle &|& |1\rangle \\ &|& \end{matrix}\right] = \left[\begin{matrix} &|& \\ |+\rangle &|& |-\rangle \\ &|& \end{matrix}\right] \left( \frac{1}{\sqrt{2}} \left[\begin{matrix} 1 & 1 \\ 1 & -1 \end{matrix}\right] \right)^{-1} = \left[\begin{matrix} &|& \\ |+\rangle &|& |-\rangle \\ &|& \end{matrix}\right] \frac{1}{\sqrt{2}} \left[\begin{matrix} 1 & 1 \\ 1 & -1 \end{matrix}\right] $

...which means...

$|0\rangle = \frac{1}{\sqrt{2}} (|+\rangle + |-\rangle)$
$|1\rangle = \frac{1}{\sqrt{2}} (|+\rangle - |-\rangle)$

Which shows us that the transform from $\{ |0\rangle, |1\rangle \}$ to $\{ |+\rangle, |-\rangle \}$ is its own inverse.
This makes sense if this transform is a mirror, since a mirror is its own inverse.


Next comes the outer product:

For the outer product of '-ket' and '-ket vectors:
$|a \rangle = \left[\begin{matrix} a_0 \\ a_1 \end{matrix}\right]$ and $|b \rangle = \left[\begin{matrix} b_0 \\ b_1 \end{matrix} \right]$ we get:
$|a \rangle \otimes |b \rangle = |a \rangle |b \rangle = |ab \rangle = \left[\begin{matrix} a_0 |b \rangle \\ a_1 |b \rangle \end{matrix} \right] = \left[ \begin{matrix} a_0 \left[\begin{matrix} b_0 \\ b_1 \end{matrix}\right] \\ a_1 \left[\begin{matrix} b_0 \\ b_1 \end{matrix}\right] \end{matrix} \right] = \left[ \begin{matrix} a_0 b_0 \\ a_0 b_1 \\ a_1 b_0 \\ a_1 b_1 \end{matrix} \right]$

Therefore $|00\rangle = \left[\begin{matrix} 1 \\ 0 \\ 0 \\ 0 \end{matrix}\right]$, $|01\rangle = \left[\begin{matrix} 0 \\ 1 \\ 0 \\ 0 \end{matrix}\right]$, $|10\rangle = \left[\begin{matrix} 0 \\ 0 \\ 1 \\ 0 \end{matrix}\right]$, $|11\rangle = \left[\begin{matrix} 0 \\ 0 \\ 0 \\ 1 \end{matrix}\right]$

Combine them all to form our '-ket' degree-2 identity basis:

$\left[ \begin{matrix} & | & & | & & | & \\ |00\rangle & | & |01 \rangle & | & |10 \rangle & | & |11 \rangle \\ & | & & | & & | & \end{matrix} \right] = \left[ \begin{matrix} 1 &|& 0 &|& 0 &|& 0 \\ 0 &|& 1 &|& 0 &|& 0 \\ 0 &|& 0 &|& 1 &|& 0 \\ 0 &|& 0 &|& 0 &|& 1 \end{matrix} \right]$

Therefore a '-ket' degree-2 vector $\left[\begin{matrix} a \\ b \\ c \\ d \end{matrix}\right]$
can be represented as $a |00\rangle + b |01\rangle + c |10\rangle + d|11\rangle$

Notice that not just any $a, b, c, d$ are valid as outer products of two '-ket' vectors.
Only $ad - bc = 0$ works, and any other values are said to be 'entangled'. TODO demonstrate this.

Once again to connect this with differential geometry, A degree-2 '-ket' vector $|e_i e_j\rangle$ is equivalent to a differential geometry degree-2 bivector $e_i \otimes e_j$.

Equivalently for the outer product of '-ket' and 'bra-' vectors:

$|a\rangle \otimes \langle b| = \left[\begin{matrix} a_0 \\ a_1 \end{matrix}\right] \left[\begin{matrix} b_0 & b_1 \end{matrix}\right] = \left[\begin{matrix} a_0 b_0 & a_0 b_1 \\ a_1 b_0 & a_1 b_1 \end{matrix}\right]$

Therefore any (1,1)-degree tensor can be represented as:
$A = \left[\begin{matrix} a & b \\ c & d \end{matrix}\right]$
$= a \left[\begin{matrix} 1 & 0 \\ 0 & 0 \end{matrix}\right] + b \left[\begin{matrix} 0 & 1 \\ 0 & 0 \end{matrix}\right] + c \left[\begin{matrix} 0 & 0 \\ 1 & 0 \end{matrix}\right] + d \left[\begin{matrix} 0 & 0 \\ 0 & 1 \end{matrix}\right]$
$= a \left[\begin{matrix} 1 \\ 0 \end{matrix}\right] \left[\begin{matrix} 1 & 0 \end{matrix}\right] + b \left[\begin{matrix} 1 \\ 0 \end{matrix}\right] \left[\begin{matrix} 0 & 1 \end{matrix}\right] + c \left[\begin{matrix} 0 \\ 1 \end{matrix}\right] \left[\begin{matrix} 1 & 0 \end{matrix}\right] + d \left[\begin{matrix} 0 \\ 1 \end{matrix}\right] \left[\begin{matrix} 0 & 1 \end{matrix}\right] $
$= a |0\rangle \langle 0| + b |0\rangle \langle 1| + c |1\rangle \langle 0| + d |1\rangle \langle 1| $

Notice that the inner product applied to higher degree vectors uses the 'plug in the first slot' rule:
$\left( \langle e_i | \otimes \langle e_j | \right) \cdot \left( | e_k \rangle \otimes |e_l \rangle \right)$ $= \langle e_i | e_k \rangle \langle e_j | e_l \rangle$ $= \delta_{ik} \delta_{jl}$

This looks just like the differential geometry plug-in-first-slot rule for differential q-forms acting on p-vectors:
$e^i \otimes e^j (e_k \otimes ... \otimes e_l) = \delta^i_k \delta^j_l$


1-qubit gates:
Hadamard gate H is defined as:

$H = \frac{1}{\sqrt{2}} \left[\begin{matrix} 1 & 1 \\ 1 & -1 \end{matrix}\right]$

In component form with basis $\{ |0\rangle, |1\rangle \}$ this becomes $H = \left[\begin{matrix} & | & \\ |+\rangle & | & |-\rangle \\ & | & \end{matrix}\right]$

Also $H = \frac{1}{\sqrt{2}} \left[\begin{matrix} 1 & 0 \\ 1 & 0 \end{matrix}\right] + \frac{1}{\sqrt{2}} \left[\begin{matrix} 0 & 1 \\ 0 & -1 \end{matrix}\right]$

So $H = \frac{1}{\sqrt{2}} \left[\begin{matrix} 1 \\ 1 \end{matrix} \right] \cdot \left[\begin{matrix} 1 & 0 \end{matrix}\right] + \frac{1}{\sqrt{2}} \left[\begin{matrix} 1 \\ -1 \end{matrix} \right] \cdot \left[\begin{matrix} 0 & 1 \end{matrix}\right]$

So $H = |+\rangle \langle 0| + |-\rangle \langle 1|$

Substitute the definitions of $\langle 0|, \langle 1|$ in terms of $\langle +|, \langle -|$ to find:
So $H = |+\rangle \frac{1}{\sqrt{2}} (\langle+| + \langle-|) + |-\rangle \frac{1}{\sqrt{2}} (\langle+| - \langle-|)$
simplify to find:
So $H = \frac{1}{\sqrt{2}} \left( (|+\rangle \langle+|) + (|+\rangle \langle-|) + (|-\rangle \langle+|) - (|-\rangle \langle-|) \right)$

Notice that, when using the $\{ |0\rangle, |1\rangle \}$ basis, we see:
$H = \frac{1}{\sqrt{2}} \left( (|0\rangle \langle 0|) + (|0\rangle \langle 1|) + (|1\rangle \langle 0|) - (|1\rangle \langle 1|) \right)$
So this means that H has the same components using the $\{ |0\rangle, |1\rangle \}$ basis or using the $\{ |+\rangle, |-\rangle \}$ basis.



1-qubit gates:

The X gate:
$X = \left[\begin{matrix} 0 & 1 \\ 1 & 0 \end{matrix}\right]$

Therefore $X = X \left[\begin{matrix} 1 & 0 \\ 0 & 1 \end{matrix}\right] = X \left[\begin{matrix} &|& \\ |0\rangle &|& |1\rangle \\ &|& \end{matrix}\right] = \left[\begin{matrix} &|& \\ X |0\rangle &|& X |1\rangle \\ &|& \end{matrix}\right] = \left[\begin{matrix} 0 & 1 \\ 1 & 0 \end{matrix}\right] = \left[\begin{matrix} &|& \\ |1\rangle &|& |0\rangle \\ &|& \end{matrix}\right] $

This means, for all discrete basis values:
$X |0\rangle = |1\rangle$
$X |1\rangle = |0\rangle$

So one way to look at a linear transform of a qubit is that the leading '1' in the column corresponds with the output value associated with the input value of the index of that column.

This means that X works like a classical binary NOT operation.
In terms of the geometric interpretation of X, it operates as a mirror along the 45-degree line



2-qubit basis vectors / outer product:

The CX gate. Notice that 'CX' is the name of the variable, not 'C' times 'X'.

$CX = \left[\begin{matrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{matrix} \right]$

Rewriting this in terms of the 2-qubit basis vectors we can say:
$CX = \left[ \begin{matrix} & | & & | & & | & \\ |00\rangle & | & |01 \rangle & | & |11 \rangle & | & |10 \rangle \\ & | & & | & & | & \end{matrix} \right]$

Also, for notation's sake, $CX = CNOT = CX_{12} = CNOT_{12}$

Now we can say:
$CX = CX \cdot I$ $= CX \cdot \left[ \begin{matrix} & | & & | & & | & \\ |00\rangle & | & |01 \rangle & | & |10 \rangle & | & |11 \rangle \\ & | & & | & & | & \end{matrix} \right]$ $= \left[ \begin{matrix} & | & & | & & | & \\ CX |00\rangle & | & CX |01 \rangle & | & CX |10 \rangle & | & CX |11 \rangle \\ & | & & | & & | & \end{matrix} \right]$ $= \left[ \begin{matrix} & | & & | & & | & \\ |00\rangle & | & |01 \rangle & | & |11 \rangle & | & |10 \rangle \\ & | & & | & & | & \end{matrix} \right]$
...which implies that the columns of CX are equal to the results of CX when each equivalent 2-qubit basis vector is applied to CX.

In other words:
$CX |00 \rangle = |00 \rangle$
$CX |01 \rangle = |01 \rangle$
$CX |10 \rangle = |11 \rangle$
$CX |11 \rangle = |10 \rangle$
So $CX |b_1 b_2 \rangle = CX |b_1 \rangle | b_2 \rangle = |b_1 \rangle |b_1 XOR \ b_2\rangle$

Note that $CX = CNOT = CX_{12} = CNOT_{12}$

Now comes $CNOT_{21}$, which is defined only in terms of its function results:
$CNOT_{21} |b_1 \rangle |b_2 \rangle = |b_1 XOR \ b_2 \rangle |b_2 \rangle$

Reverse-engineering this function:
$CNOT_{21} |00 \rangle = |00 \rangle$
$CNOT_{21} |01 \rangle = |11 \rangle$
$CNOT_{21} |10 \rangle = |10 \rangle$
$CNOT_{21} |11 \rangle = |01 \rangle$
...and representing the results as a linear system ...
$\left[ \begin{matrix} & | & & | & & | & \\ |00\rangle & | & |11 \rangle & | & |10 \rangle & | & |01 \rangle \\ & | & & | & & | & \end{matrix} \right]$ $= \left[ \begin{matrix} & | & & | & & | & \\ CNOT_{21} |00\rangle & | & CNOT_{21} |01 \rangle & | & CNOT_{21} |10 \rangle & | & CNOT_{21} |11 \rangle \\ & | & & | & & | & \end{matrix} \right]$
$= CNOT_{21} \left[ \begin{matrix} & | & & | & & | & \\ |00\rangle & | & |01 \rangle & | & |10 \rangle & | & |11 \rangle \\ & | & & | & & | & \end{matrix} \right]$
$= CNOT_{21} \cdot I = CNOT_{21}$

So we can say that:
$CNOT_{21} = \left[ \begin{matrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{matrix} \right]$


The notes also explain that $CNOT_{21} = (H \otimes H) \cdot CNOT_{12} \cdot (H \otimes H)$

$H \otimes H = \frac{1}{\sqrt{2}} \left[\begin{matrix} \frac{1}{\sqrt{2}} \left[\begin{matrix} 1 & 1 \\ 1 & -1 \end{matrix}\right] & \frac{1}{\sqrt{2}} \left[\begin{matrix} 1 & 1 \\ 1 & -1 \end{matrix}\right] \\ \frac{1}{\sqrt{2}} \left[\begin{matrix} 1 & 1 \\ 1 & -1 \end{matrix}\right] & -\frac{1}{\sqrt{2}} \left[\begin{matrix} 1 & 1 \\ 1 & -1 \end{matrix}\right] \end{matrix}\right]$ $ = \frac{1}{2} \left[\begin{matrix} 1 & 1 & 1 & 1 \\ 1 & -1 & 1 & -1 \\ 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 \end{matrix}\right]$

The identity from the book, page 19: $CNOT_{21} = (H \otimes H) \cdot CNOT_{12} \cdot (H \otimes H)$
$CNOT_{21} = \frac{1}{2} \left[\begin{matrix} 1 & 1 & 1 & 1 \\ 1 & -1 & 1 & -1 \\ 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 \end{matrix}\right] \cdot CNOT_{12} \cdot \frac{1}{2} \left[\begin{matrix} 1 & 1 & 1 & 1 \\ 1 & -1 & 1 & -1 \\ 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 \end{matrix}\right]$

$CNOT_{21} = \frac{1}{2} \left[\begin{matrix} 1 & 1 & 1 & 1 \\ 1 & -1 & 1 & -1 \\ 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 \end{matrix}\right] \cdot \left[\begin{matrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{matrix}\right] \cdot \frac{1}{2} \left[\begin{matrix} 1 & 1 & 1 & 1 \\ 1 & -1 & 1 & -1 \\ 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 \end{matrix}\right]$

$CNOT_{21} = \left[\begin{matrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{matrix}\right]$

So this is verified to agree with the book's identity.



CZ gate:

$CZ = \left[\begin{matrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{matrix}\right]$

$CZ | 00 \rangle = | 00 \rangle$
$CZ | 01 \rangle = | 01 \rangle$
$CZ | 10 \rangle = | 10 \rangle$
$CZ | 11 \rangle = -| 11 \rangle$