Dirac Notation
Contents
Dirac Notation#
In this section we want to understand how to represent a quantum state of
One approach is to use Dirac notation.
Classically, we know that a wire carries a bit that can be in a “state” such as
Notice a couple things about these amplitudes:
First, amplitudes can be positive, negative, or complex
Second, the sum of the absolute value of the amplitudes squared has to equal 1.
Now, suppose that instead of having one wire, you have two wires. Classically, the two bits carried by the two wires can be in four possible states, “00” or “01” or “10” or “11”. The most general quantum state of two wires is a superposition of all the possible classical states, which can be represented as
An example state is
There’s another (less general) way to represent what’s going on in two wires. Suppose wire 0 is in the state
This is called a tensor product. It is equal to
It is important to notice that while some states, called product states, can be represented as a tensor product over each wire, this is not true of all states. If you can’t represent the state as a product state, then that state is called entangled. It is a useful exercise to come up with an example of an entangled state of two wires to see why it cannot be written as a product state.
Vectors#
Another approach to represent a quantum state of
Suppose we are going to represent a two qubit (or two wire) state in terms of a vector. The vector is of length
Consider the two wire state we discussed above:
In words, the amplitude in front of
It will be useful to manipulate states in both Dirac and vector notation and to switch back and forth between the two notations.
Suppose we define the state
myState=[
(numpy.sqrt(0.1), '00'),
(numpy.sqrt(0.4), '01') ,
(-numpy.sqrt(0.5), '11' )
]
Write a piece of code def PrettyPrintBinary(myState)
to take this state and print it out in a pretty way like:
( 0.316227766017 |00> + 0.632455532034 |01> + -0.707106781187 |11>)
Notice that we have been considering two qubit states with a basis in a binary representation. By that, we mean that the four basis vectors,
Therefore, write some code def PrettyPrintInteger(myState)
that prints out the state in the decimal (or integer) basis:
( 0.316227766017 |0> + 0.632455532034 |1> + -0.707106781187 |3>)
(This code should work for any number of wires.)
Grading
Post the output of the following code into your document:
myState2=[
(numpy.sqrt(0.1)*1.j, '101'),
(numpy.sqrt(0.5), '000') ,
(-numpy.sqrt(0.4), '010' )]
PrettyPrintBinary(myState2)
PrettyPrintInteger(myState2)
Now, write code def StateToVec(myState)
and def VecToState(myVec)
which converts back and forth between states in vector notation and states in Dirac Notation.
Grading
Post the output of the following code into your document.
print(StateToVec(myState2))
print(VecToState(StateToVec(myState2)))