Narration / Transcript
Quantum Information Processing: Foundations - Part 3
This is what the narrator says, not what the page shows: equations are read as sentences, code blocks are described, and citations are spoken as citations.
- 0:00
Introduction
- 0:02
Having laid out some mathematical foundations in the previous part, we will proceed to discussing quantum gates and circuits in depth here. As usual, we will drive home the theories with worked examples from, see Rieffel and Polak, 2014 and check their accuracies with qiskit and/or cirq code.
- 0:21
Prerequisite
- 0:23
Understanding quantum gates and circuits will be greatly aided by the knowledge of classical gates (AND, OR, NOT, XOR and the universal gates: NAND and NOR). Also, some familiarity with the Python programming language will help you understand qiskit and/or cirq code.
- 0:42
Classical & Quantum gates
- 0:44
A classical computer, possibly the one you're reading this with, is a sophisticated engineering piece, no doubt. However, the underlying "magic" comprises logic gates. The National Institute of Standards and Technology (NIST) gives this incredible analogical description of classical computers in relation to logic gates, see Quantum Logic Gates., 2018:
- 1:08
Traditional computers are like microscopic cities. The roads of these cities are wires with electricity coursing through them. These roads have lots of gates, known as logic gates, which enable computers to do their job. Like physical gates that allow or block cars, logic gates allow or block electricity. Electricity that goes through the gates represents a “1” of digital data, and blocked electricity is a “0.”
- 1:34
When you pick up a motherboard, for instance, you may not see the said gates as they are made of tiny transistors (in modern systems, MOSFETs) in specific combinations. Also, the 0 and 1 referred to in the analogy mean low and high voltage ranges, respectively. Their actual voltage values depend on the hardware.
- 1:55
All schematics were written in and rendered by at schemd slash core. Check it out.
- 2:01
Logic Gates refresher
- 2:03
Since we will be realizing some classical circuits using quantum gates, it's necessary to get familiar with common logic gates.
- 2:11
NOT (not) Gate
- 2:13
This gate takes a single classical bit and flips it. For instance, if 0 is the input to this gate, 1 will be seen in the output, vice versa. Just like a flip of a coin. Below, you find both the IEEE symbol of the gate and its truth table:
- 2:29
in
- 2:31
out
- 2:32
0
- 2:34
1
- 2:36
1
- 2:37
0
- 2:39
AND (and) Gate
- 2:41
Borrowing NIST's analogy again, see Quantum Logic Gates., 2018:
- 2:46
One kind of logic gate, known as the AND gate, could, for example, quickly determine whether two people agree to a business deal. It takes in two bits of information, and generates a 1 if both incoming bits are 1s. So, if both business people say “yes” (1) to the deal, the AND gate will output 1. If one or both say “no” (0), the AND gate generates a 0 or a no.
- 3:10
From the analogy, the gate usually takes 2 bits (2 people who want to deal). It has the truth table and symbol shown below. i n sub 0 i n sub 1 o u t
- 3:21
0
- 3:23
0
- 3:25
0
- 3:26
1
- 3:28
0
- 3:30
0
- 3:31
0
- 3:33
1
- 3:35
0
- 3:36
1
- 3:38
1
- 3:39
1
- 3:41
OR (or) Gate
- 3:43
This logic gate also takes 2 bits and functions based on the analogy that if two founders are deciding whether to launch a product, OR says “launch if at least one says yes.” Only when both say no does the result become no. Its symbol and truth table are as follows: i n sub 0 i n sub 1 o u t
- 4:04
0
- 4:05
0
- 4:07
0
- 4:09
1
- 4:10
0
- 4:12
1
- 4:13
0
- 4:15
1
- 4:17
1
- 4:18
1
- 4:20
1
- 4:21
1
- 4:23
XOR (circled plus) Gate
- 4:25
Exclusive OR (XOR) gate is a core part of an adder circuit and, in algorithms, we use it for bitwise manipulation in problems including finding a number that does not have a duplicate in an array. For a 2-bit input, its output is 1 if and only if the bits are of opposite values. Its truth table sheds more light on this: i n sub 0 i n sub 1 o u t
- 4:48
0
- 4:50
0
- 4:52
0
- 4:53
1
- 4:55
0
- 4:57
1
- 4:58
0
- 5:00
1
- 5:01
1
- 5:03
1
- 5:04
1
- 5:06
0
- 5:08
XOR gate's symbol is as follows:
- 5:11
NAND
- 5:12
NAND (Not AND) is one of the universal gates in digital circuits; the other is NOR (Not OR). It is universal because, with only this single gate, all other gates and circuits can be designed. Its behavior is simply as its name sounds: invert the output of an AND gate! i n sub 0 i n sub 1 o u t
- 5:33
0
- 5:34
0
- 5:36
1
- 5:38
1
- 5:39
0
- 5:41
1
- 5:42
0
- 5:44
1
- 5:46
1
- 5:47
1
- 5:49
1
- 5:50
0
- 5:52
NAND gate's symbol is as follows:
- 5:55
NOR
- 5:56
NOR does the same thing to an OR gate: it inverts its output. Therefore, it only returns 1 when both inputs are 0. Like NAND, it is universal. i n sub 0 i n sub 1 o u t
- 6:10
0
- 6:12
0
- 6:14
1
- 6:15
1
- 6:17
0
- 6:18
0
- 6:20
0
- 6:22
1
- 6:23
0
- 6:25
1
- 6:26
1
- 6:28
0
- 6:30
Quantum Gates
- 6:31
Just as classical gates are the foundations of classical computers, quantum gates are those of quantum computers. They make it possible for quantum algorithms to run. The fundamental difference between them is that classical gates work on bits whose state is either 0 or 1 (and not both at the same time), whereas quantum gates operate on qubits where 0 and 1 can be superposed and even entangled (this will be discussed in the next part).
- 6:58
Quantum gates can either be single-qubit or multiple-qubit gates, see Gopalan College of Engineering and Management., 2022. As with almost anything in quantum computing, these gates can be mathematically expressed as matrices, and we will explore this heavily to understand how they work. One thing to keep in mind is that their matrices must be unitary. As discussed in the first part of this series, it means their inverses are the same as their Hermitian (conjugate transpose). It also means that the gate operations are reversible.
- 7:29
We will explore the X-, Y-, Z-, H-, S- and T- gates as examples of single-qubit gates. Though there are many multiple-qubit gates, we will only discuss the CNOT gate here. The reason is that the set of H-, CNOT, and T- gates is universal and can approximate any quantum computation to arbitrary precision, see MathWorks., n.d.. In simple terms, they can get as close as needed to any quantum operation.
- 7:55
X-Gate
- 7:57
This is the quantum equivalent of the classical NOT gate. In the quantum world, it is called the Pauli X-gate. Just like its classical counterpart, this gate flips its incoming qubit. If ket 0 is the input, ket 1 will be the output, vice versa. Mathematically, this gate can be expressed, in matrix form, as: Equation: X equals the 2 by 2 matrix Row 1: 0 1 Row 2: 1 0.
- 8:22
Now, let's look at the behaviour of this gate on a state, ket psi.
- 8:26
If Equation: ket psi equals alpha ket 0 plus beta ket 1.
- 8:32
Then, in matrix form, Equation: ket psi equals bmatrix alpha beta.
- 8:38
Feeding this into the Pauli X-gate, we have: Equation: X ket psi equals bmatrix 0 1 1 0 bmatrix alpha beta equals bmatrix 0 times alpha plus 1 times beta 1 times alpha plus 0 times beta equals bmatrix beta alpha equals beta ket 0 plus alpha ket 1.
- 8:59
It got flipped!
- 9:01
Therefore, it can be demonstrated that if we feed ket 0 (the 2 by 1 column matrix 1 0 in matrix form) into an X-gate, we will have: Equation: X ket 0 equals bmatrix 0 1 1 0 bmatrix 1 0 equals bmatrix 0 times1 plus 1 times0 1 times1 plus 0 times0 equals bmatrix 0 1 equals ket 1.
- 9:26
In the same vein, feeding ket 1 (the 2 by 1 column matrix 0 1 in matrix form) into the gate gives: Equation: X ket 1 equals bmatrix 0 1 1 0 bmatrix 0 1 equals bmatrix 0 times0 plus 1 times1 1 times0 plus 0 times1 equals bmatrix 1 0 equals ket 0.
- 9:50
The truth table can easily be built from here:
- 9:53
Input
- 9:55
Output ket 0 ket 1 ket 1 ket 0
- 9:59
Y-Gate
- 10:00
The Pauli Y-gate also flips a qubit. However, unlike the X-gate, it adds a phase to the result. Its matrix is: Equation: Y equals the 2 by 2 matrix Row 1: 0 negative i Row 2: i 0.
- 10:16
Let's feed the same arbitrary state, ket psi, into it: Equation: Y ket psi equals bmatrix 0 minus i i 0 bmatrix alpha beta equals bmatrix minus i beta i alpha equals minus i beta ket 0 plus i alpha ket 1.
- 10:34
The amplitudes have been swapped, but they now carry the phases negative i and i. From here, feeding ket 0 into the gate gives: Equation: Y ket 0 equals bmatrix 0 minus i i 0 bmatrix 1 0 equals bmatrix 0 i equals i ket 1.
- 10:53
In the same vein, feeding ket 1 into it gives: Equation: Y ket 1 equals bmatrix 0 minus i i 0 bmatrix 0 1 equals bmatrix minus i 0 equals minus i ket 0.
- 11:09
The truth table can be built from here:
- 11:11
Input
- 11:13
Output ket 0 i ket 1 ket 1 minus i ket 0 alpha ket 0 plus beta ket 1 minus i beta ket 0 plus i alpha ket 1
- 11:24
You may notice that i ket 1 and minus i ket 0 still give the same measurement probabilities as ket 1 and ket 0, respectively, in the computational basis. This is because an overall phase does not affect the measurement probabilities. However, when the qubit is in a superposition, a phase on one part of the state matters. We will see this with the next gate.
- 11:48
Z-Gate
- 11:49
The Pauli Z-gate is also called the phase-flip gate. Unlike the X- and Y- gates, it does not swap the amplitudes. Instead, it changes the sign of the ket 1 amplitude. Its matrix is: Equation: Z equals the 2 by 2 matrix Row 1: 1 0 Row 2: 0 negative 1.
- 12:09
Feeding our arbitrary state into it, we have: Equation: Z ket psi equals bmatrix 1 0 0 minus 1 bmatrix alpha beta equals bmatrix alpha minus beta equals alpha ket 0 minus beta ket 1.
- 12:26
For the basis states: Equation: Z ket 0 equals ket 0, Z ket 1 equals minus ket 1.
- 12:34
Input
- 12:35
Output ket 0 ket 0 ket 1 minus ket 1 alpha ket 0 plus beta ket 1 alpha ket 0 minus beta ket 1
- 12:45
You may ask: if ket 1 and minus ket 1 produce the same measurement probability, what exactly changed? When ket 1 is by itself, the minus sign is a global phase and cannot be observed. However, in a superposition, it changes the relative phase between the amplitudes. For example: Equation: Z (ket 0 plus ket 1 over the square root of 2) equals ket 0 minus ket 1 over the square root of 2.
- 13:11
Recall that ket 0 plus ket 1 over the square root of 2 equals ket plus and ket 0 minus ket 1 over the square root of 2 equals ket minus. Therefore, Z ket plus equals ket minus. Both states have a 50 percent probability of returning 0 or 1 when measured in the computational basis. They are, however, different states and behave differently when another gate, such as H, acts on them.
- 13:36
H-Gate
- 13:38
The Hadamard gate, commonly written as H, takes a basis state and puts it in an equal superposition. Its matrix is: Equation: H equals the fraction with numerator 1 and denominator the square root of 2 times the 2 by 2 matrix Row 1: 1 1 Row 2: 1 negative 1.
- 13:57
Let's first see its action on our arbitrary qubit: Equation: H ket psi equals 1 over the square root of 2 bmatrix 1 1 1 minus 1 bmatrix alpha beta equals 1 over the square root of 2 bmatrix alpha plus beta alpha minus beta. Equation: H ket psi equals alpha plus beta over the square root of 2 ket 0 plus alpha minus beta over the square root of 2 ket 1.
- 14:23
Now, if ket 0 is fed into the gate: Equation: H ket 0 equals 1 over the square root of 2 bmatrix 1 1 1 minus 1 bmatrix 1 0 equals 1 over the square root of 2 bmatrix 1 1 equals ket 0 plus ket 1 over the square root of 2 equals ket plus.
- 14:43
In the same vein: Equation: H ket 1 equals 1 over the square root of 2 bmatrix 1 1 1 minus 1 bmatrix 0 1 equals 1 over the square root of 2 bmatrix 1 minus 1 equals ket 0 minus ket 1 over the square root of 2 equals ket minus.
- 15:03
From H ket 0 equals 1 over the square root of 2 ket 0 plus 1 over the square root of 2 ket 1, the probabilities of measuring ket 0 and ket 1 are: Equation: P sub ket 0 equals | 1 over the square root of 2 | squared equals 1 over 2.
- 15:21
and Equation: P sub ket 1 equals | 1 over the square root of 2 | squared equals 1 over 2.
- 15:28
Before moving on, there is another interesting property of this gate. Applying H twice returns the original state. Let's confirm that from its matrix: Equation: H squared equals one half times the 2 by 2 matrix Row 1: 1 1 Row 2: 1 negative 1 times the 2 by 2 matrix Row 1: 1 1 Row 2: 1 negative 1 equals one half times the 2 by 2 matrix Row 1: 2 0 Row 2: 0 2 equals I.
- 15:55
Therefore, H squared equals I. This also means that H ket plus equals ket 0 and H ket minus equals ket 1. The gate takes us from the computational basis, ket 0, ket 1, to the Hadamard basis, ket plus, ket minus, and vice versa.
- 16:13
S-Gate
- 16:15
The S-gate is another phase gate. It leaves ket 0 unchanged but adds a phase of pi over 2 to ket 1. Its matrix is: Equation: S equals the 2 by 2 matrix Row 1: 1 0 Row 2: 0 i.
- 16:30
Applying it to our arbitrary state gives: Equation: S ket psi equals bmatrix 1 0 0 i bmatrix alpha beta equals bmatrix alpha i beta equals alpha ket 0 plus i beta ket 1.
- 16:45
Recall from Euler's formula that e raised to the i pi over 2 power equals i. Therefore: Equation: S ket 0 equals ket 0, S ket 1 equals i ket 1 equals e to the power i pi over 2 ket 1.
- 17:02
The truth table can be built from here:
- 17:05
Input
- 17:06
Output ket 0 ket 0 ket 1 i ket 1 alpha ket 0 plus beta ket 1 alpha ket 0 plus i beta ket 1
- 17:16
Also, applying S twice produces the Z-gate. From its matrix: Equation: S squared equals the 2 by 2 matrix Row 1: 1 0 Row 2: 0 i times the 2 by 2 matrix Row 1: 1 0 Row 2: 0 i equals the 2 by 2 matrix Row 1: Column 1, 1 Column 2, 0 Row 2: Column 1, 0 Column 2, i squared equals the 2 by 2 matrix Row 1: 1 0 Row 2: 0 negative 1 equals Z.
- 17:44
T-Gate
- 17:45
The T-gate works in a similar fashion to the S-gate. It is also called the pi over 8 gate, though the relative phase it adds to ket 1 is pi over 4. Its matrix is: Equation: T equals the 2 by 2 matrix Row 1: Column 1, 1 Column 2, 0 Row 2: Column 1, 0 Column 2, e raised to the i pi divided by 4 power.
- 18:09
Recall Euler's formula, e raised to the i theta power equals cosine theta plus i sine theta. Substituting theta equals pi over 4, we have: Equation: e raised to the i pi divided by 4 power equals the cosine of pi over 4 plus i the sine of pi over 4 equals the fraction with numerator 1 plus i and denominator the square root of 2.
- 18:34
Now, let's apply T to our arbitrary state: Equation: T ket psi equals bmatrix 1 0 0 e to the power i pi divided by 4 bmatrix alpha beta equals bmatrix alpha e to the power i pi divided by 4 beta equals alpha ket 0 plus e to the power i pi divided by 4 beta ket 1.
- 18:57
Input
- 18:59
Output ket 0 ket 0 ket 1 e to the power i pi divided by 4 ket 1 alpha ket 0 plus beta ket 1 alpha ket 0 plus e to the power i pi divided by 4 beta ket 1
- 19:14
From here, applying T twice should give S. Let's confirm this from its matrix: Equation: T squared equals the 2 by 2 matrix Row 1: Column 1, 1 Column 2, 0 Row 2: Column 1, 0 Column 2, e raised to the i pi divided by 4 power squared equals the 2 by 2 matrix Row 1: Column 1, 1 Column 2, 0 Row 2: Column 1, 0 Column 2, e raised to the i pi divided by 2 power equals the 2 by 2 matrix Row 1: 1 0 Row 2: 0 i equals S.
- 19:41
CNOT Gate
- 19:43
All the gates discussed thus far take a single qubit. The Controlled NOT (CNOT or CX) gate takes two: a control and a target. If the control is ket 0, the target remains unchanged. However, if the control is ket 1, an X-gate is applied to the target. The control itself does not change.
- 20:04
If we represent the control with c and the target with t, the operation can be written as: Equation: ket c,t longmapsto ket c,t oplus c.
- 20:14
where circled plus is XOR. Recall that XOR returns 1 only when its two inputs differ. In the computational basis ordered as ket 00, ket 01, ket 10, ket 11, the matrix of the gate is: Equation: CNOT equals the 4 by 4 matrix Row 1: Column 1, 1 Column 2, 0 Column 3, 0 Column 4, 0 Row 2: Column 1, 0 Column 2, 1 Column 3, 0 Column 4, 0 Row 3: Column 1, 0 Column 2, 0 Column 3, 0 Column 4, 1 Row 4: Column 1, 0 Column 2, 0 Column 3, 1 Column 4, 0.
- 20:42
Let's work through all four computational basis states:
- 20:46
ket 00 goes to ket 00: the control is 0, so the target remains 0;
- 20:52
ket 01 goes to ket 01: the control is 0, so the target remains 1;
- 20:59
ket 10 goes to ket 11: the control is 1, so the target flips from 0 to 1; and
- 21:06
ket 11 goes to ket 10: the control is 1, so the target flips from 1 to 0.
- 21:12
Input
- 21:14
Output ket 00 ket 00 ket 01 ket 01 ket 10 ket 11 ket 11 ket 10
- 21:22
Now, what happens if the control is in a superposition? Let's consider two qubits initialized to ket 00. First, we apply H to the first qubit while leaving the second unchanged: Equation: (H tensor product I) ket 00 equals ket 00 plus ket 10 over the square root of 2.
- 21:43
From here, we apply CNOT using the first qubit as the control: Equation: CNOT (ket 00 plus ket 10 over the square root of 2) equals ket 00 plus ket 11 over the square root of 2.
- 21:58
From here, both qubits are in one of the Bell states. Notice that we can no longer separate it into an independent state for the first qubit and another for the second. This is regarded as entanglement. We will properly unpack it in the next part.
- 22:13
Worked examples
- 22:15
Q1:
- 22:17
Design a circuit that rearranges three arbitrary single-qubit states in this manner: Equation: ket psi ket phi ket eta longmapsto ket eta ket psi ket phi.
- 22:29
Solution
- 22:30
Given: Equation: ket psi sub 1 ket phi sub 2 ket eta sub 3 longrightarrow ket eta sub 1 ket psi sub 2 ket phi sub 3.
- 22:41
where the subscripts represent the wire positions.
- 22:44
To solve this, let's compare the initial and final positions of the states:
- 22:49
State
- 22:51
Initial wire
- 22:53
Final wire ket psi 1 2 ket phi 2 3 ket eta 3 1
- 22:58
From the table: ket psi: 1 goes to2 ket phi: 2 goes to3 ket eta: 3 goes to1
- 23:05
Looking at the movements together, we see that they form a cycle. A SWAP gate exchanges the states in two positions, so we can complete this cycle with two of them.
- 23:16
First, swap the states in positions 2 and 3: Equation: ket psi sub 1 ket phi sub 2 ket eta sub 3 xrightarrow SWAP sub 2,3 ket psi sub 1 ket eta sub 2 ket phi sub 3.
- 23:30
The states are now in the order ket psi ket eta ket phi. We only need to move ket eta to the first position. So, let's swap the states in positions 1 and 2: Equation: ket psi sub 1 ket eta sub 2 ket phi sub 3 xrightarrow SWAP sub 1,2 ket eta sub 1 ket psi sub 2 ket phi sub 3. therefore Equation: ket psi ket phi ket eta xrightarrow SWAP sub 2,3 ket psi ket eta ket phi xrightarrow SWAP sub 1,2 ket eta ket psi ket phi.
- 23:57
The required circuit is:
- 24:00
Before going to the check, let's show how a SWAP gate can be built with three CNOT gates. Suppose the first and second qubits contain the basis values a and b, respectively. The gates are applied in this order: Equation: CNOT sub 1 comma 2 comma CNOT sub 2 comma 1 comma CNOT sub 1 comma 2.
- 24:21
The first subscript denotes the control qubit while the second denotes the target. Also, recall these properties of XOR: Equation: a circled plus a equals 0 comma a circled plus 0 equals a.
- 24:35
For the first CNOT, a is the control. It remains unchanged while the target, b, becomes a circled plus b: Equation: open paren a comma b close paren right arrow sign with CNOT sub 1 comma 2 over it open paren a comma a circled plus b close paren.
- 24:53
For the second CNOT, a circled plus b is now the control and a is the target. The new target is: Equation: 3 lines Line 1: a circled plus open paren a circled plus b close paren equals open paren a circled plus a close paren circled plus b Line 2: blank equals 0 circled plus b Line 3: blank equals b.
- 25:15
Therefore: Equation: open paren a comma a circled plus b close paren right arrow sign with CNOT sub 2 comma 1 over it open paren b comma a circled plus b close paren.
- 25:28
For the last CNOT, b is the control and a circled plus b is the target. The target becomes: Equation: 3 lines Line 1: open paren a circled plus b close paren circled plus b equals a circled plus open paren b circled plus b close paren Line 2: blank equals a circled plus 0 Line 3: blank equals a.
- 25:50
So: Equation: open paren b comma a circled plus b close paren right arrow sign with CNOT sub 1 comma 2 over it open paren b comma a close paren. therefore Equation: open paren a comma b close paren long right arrow open paren b comma a close paren.
- 26:09
We started with open paren a comma b close paren and ended with open paren b comma a close paren. The two values have been swapped! We used the basis values a and b to make the calculation easier. Since quantum gates are linear, the same result holds for arbitrary single-qubit states, including states in superposition.
- 26:31
Check
- 26:32
This is a Google Cirq code for checking the CNOT construction and the final permutation: The Python code below is 61 lines, from check dot py.
- 26:43
Q2:
- 26:45
Find the 4 times 4 unitary matrix represented by each of the following two-qubit circuits:
- 26:52
(a) Apply the Hadamard gate to x sub 1 while leaving x sub 2 unchanged.
- 26:57
(b) Leave x sub 1 unchanged while applying the Hadamard gate to x sub 2.
- 27:03
Solution
- 27:05
Before going into the two circuits, let's lay out some foundations.
- 27:09
There are 2 qubits in each circuit. Recall that an n - qubit gate has a 2 to the n-th power times 2 to the n-th power matrix. Therefore, the dimension of each matrix here is: Equation: 2 squared times 2 squared equals 4 times 4.
- 27:26
From the circuits, the matrices involved are the Hadamard matrix, H, and the identity matrix, I: Equation: H equals the fraction with numerator 1 and denominator the square root of 2 times the 2 by 2 matrix Row 1: 1 1 Row 2: 1 negative 1 comma I equals the 2 by 2 matrix Row 1: 1 0 Row 2: 0 1.
- 27:49
Also, recall that the tensor product of: Equation: A equals the 2 by 2 matrix Row 1: a b Row 2: c d.
- 27:58
and another matrix, B, is: Equation: A circled times B equals the 2 by 2 matrix Row 1: a B b B Row 2: c B d B.
- 28:08
(a) Hadamard on x sub 1
- 28:11
In circuit (a), H is applied to x sub 1 while x sub 2 remains unchanged. The identity matrix, I, represents the unchanged qubit. Since x sub 1 comes before x sub 2, the overall operation is: Equation: H circled times I.
- 28:29
Now, substitute the matrices: Equation: 5 lines Line 1: H circled times I equals the fraction with numerator 1 and denominator the square root of 2 times the 2 by 2 matrix Row 1: 1 1 Row 2: 1 negative 1 circled times the 2 by 2 matrix Row 1: 1 0 Row 2: 0 1 Line 2: blank equals the fraction with numerator 1 and denominator the square root of 2 times the 2 by 2 matrix Row 1: 1 I 1 I Row 2: 1 I negative 1 I Line 3: blank equals the fraction with numerator 1 and denominator the square root of 2 times the 2 by 2 matrix Row 1: Column 1, 1 times the 2 by 2 matrix Row 1: 1 0 Row 2: 0 1 Column 2, 1 times the 2 by 2 matrix Row 1: 1 0 Row 2: 0 1 Row 2: Column 1, 1 times the 2 by 2 matrix Row 1: 1 0 Row 2: 0 1 Column 2, negative 1 times the 2 by 2 matrix Row 1: 1 0 Row 2: 0 1 Line 4: blank equals the fraction with numerator 1 and denominator the square root of 2 times the 2 by 2 matrix Row 1: Column 1, 2 lines Line 1: 1 0 Line 2: 0 1 Column 2, 2 lines Line 1: 1 0 Line 2: 0 1 Row 2: Column 1, 2 lines Line 1: 1 0 Line 2: 0 1 Column 2, 2 lines Line 1: negative 1 0 Line 2: 0 negative 1 Line 5: blank equals the fraction with numerator 1 and denominator the square root of 2 times the 4 by 4 matrix Row 1: Column 1, 1 Column 2, 0 Column 3, 1 Column 4, 0 Row 2: Column 1, 0 Column 2, 1 Column 3, 0 Column 4, 1 Row 3: Column 1, 1 Column 2, 0 Column 3, negative 1 Column 4, 0 Row 4: Column 1, 0 Column 2, 1 Column 3, 0 Column 4, negative 1.
- 28:56
(b) Hadamard on x sub 2
- 28:58
In circuit (b), x sub 1 remains unchanged while H is applied to x sub 2. This time, I comes before H. Therefore, the operation is: Equation: I circled times H.
- 29:11
Substitute both matrices: Equation: 4 lines Line 1: I circled times H equals the 2 by 2 matrix Row 1: 1 0 Row 2: 0 1 circled times the fraction with numerator 1 and denominator the square root of 2 times the 2 by 2 matrix Row 1: 1 1 Row 2: 1 negative 1 Line 2: blank equals the fraction with numerator 1 and denominator the square root of 2 times the 2 by 2 matrix Row 1: Column 1, 1 times the 2 by 2 matrix Row 1: 1 1 Row 2: 1 negative 1 Column 2, 0 times the 2 by 2 matrix Row 1: 1 1 Row 2: 1 negative 1 Row 2: Column 1, 0 times the 2 by 2 matrix Row 1: 1 1 Row 2: 1 negative 1 Column 2, 1 times the 2 by 2 matrix Row 1: 1 1 Row 2: 1 negative 1 Line 3: blank equals the fraction with numerator 1 and denominator the square root of 2 times the 2 by 2 matrix Row 1: Column 1, 2 lines Line 1: 1 1 Line 2: 1 negative 1 Column 2, 2 lines Line 1: 0 0 Line 2: 0 0 Row 2: Column 1, 2 lines Line 1: 0 0 Line 2: 0 0 Column 2, 2 lines Line 1: 1 1 Line 2: 1 negative 1 Line 4: blank equals the fraction with numerator 1 and denominator the square root of 2 times the 4 by 4 matrix Row 1: Column 1, 1 Column 2, 1 Column 3, 0 Column 4, 0 Row 2: Column 1, 1 Column 2, negative 1 Column 3, 0 Column 4, 0 Row 3: Column 1, 0 Column 2, 0 Column 3, 1 Column 4, 1 Row 4: Column 1, 0 Column 2, 0 Column 3, 1 Column 4, negative 1.
- 29:38
Check
- 29:40
This is another cirq code for checking both matrices: The Python code below is 53 lines, from check dot py.
- 29:48
Outro
- 29:50
Enjoyed this article? I'm a Software Engineer and Technical Writer actively seeking new opportunities to impact and learn, particularly in areas related to web security, finance, healthcare, and education. If you think my expertise aligns with your team's needs, let's chat! You can find me on LinkedIn and X. I am also an email away.