Show that the ket
is an eigenvector of
with eigenvalue
.
Here are we check that all our definitions of the pauli matrices and kets are
consistent in this sense.
Here we use anticommutator(
) to test the anticommutation relations among
the pauli matrices:
for
The Maxima function
mat_unblocker
,
flattens the
blocks in the above expression, so we can write
Now we load the
itensor package, which provides the levi-civita tensor, and make use of the
Maxima functions
permutations
(which returns
the set
of all permutations of a list)
and listify (which converts the set data type into the (ordered) list data type).
The qinf package provides
mapapply(
), which
apply s func to each of the lists and
returns a list of the results. (see the Maxima
documentation for
apply
.) With all these, we can test
the commutation relations of the pauli
matrices. (In reality, the matrix definitions are not
complicated, we are actually testing the other functions.):
.
The next three functions
pauliexp(
), invpauliexp(
), and correlation_tensor(
)
are related. An example using them follows their definitions.
Here is the tensor product of the three matrices. This is not a generic element in
the three qubit Hilbert space represented by
. For instance,
the three matrices have
complex parameters while a generic matrix in
the tensor product space has
complex parameters.
We compute the correlation tensor of mp
Check that the tensor has
elements and see what a coefficient looks like.
Check that the inverse of the expansion gives the original matrix back
Here is the convenience function to return an element of the correlation tensor by index
, with some of the identity operators
insert_operator(8,[pauli[1],1,3],[pauli[2],2,5],[pauli[3],8])
The function hadamard(
) returns the tensor product
of nbits one-qubit operators each of which is
except
for the operators in positions i1,i2,... which are the hadamard
operator given by the variable hadamard. The function is defined
by hadamard(nbits,[t]) := insert_operator(nbits,cons(hadamard,t)),
which is an idiom that will work for similar user defined functions as well.
The dummy argument [t] causes all arguments after nbits to
be collected in a single list. The Maxima function
cons
, invoked as cons(
),
returns the list given by prepending
expr to the list list.
nbits-qubit operator. The target qubit is at the index t,
while the control qubits are at the indices listed in the list clst.
In the returned operator, the qop at qubit t if all of
the control qubits are set (ie are controlled_gate(2,pauli[1],2,[1]).
The controlled gate in an
nbits-qubit
register with the target at index t and control qubits at indices
c1,c2,.... The definition of this function is
cnot(nbits,t,[c]) := controlled_gate(nbits,pauli[1],t,c).
The functions cphase and crot are defined in the same way except
that operators pauli[3] and %i*pauli[2] respectively are
substituted for pauli[1]. For example, the elementary cnot gate
is given by cnot(2,2,1).
t1
and t2 in an nbits-qubit register. It is defined by
swap(nbits,t1,t2) := cnot(nbits,t1,t2) . cnot(nbits,t2,t1) . cnot(nbits,t1,t2).
toffoli(nbits,t,c1,c2) := cnot(nbits,t,c1,c2). Note that there
are exactly two control qubits.
t1 and t2 are swapped if the control qubit at index c is set.