1 00:00:00,000 --> 00:00:07,009 Okay. So now, let's try to understand some specific unitary transformations on single 2 00:00:07,009 --> 00:00:15,005 qubits. Some specific transformations that we'll use all the time. And, in fact, 3 00:00:15,005 --> 00:00:22,000 it's, it's useful to, you know, the way they think about these unitary 4 00:00:22,000 --> 00:00:29,003 transformations on single qubits as, as, is as quantum gates. So, I'm sure many of 5 00:00:29,003 --> 00:00:35,000 you know about classical circuits where you have wires that carry bits of 6 00:00:35,000 --> 00:00:40,076 information and then you have gates that transform these bits in someway. So, in 7 00:00:40,076 --> 00:00:47,006 the quantum manual analog of that, we think of we think of a wire as carrying a 8 00:00:47,006 --> 00:00:55,000 quantum bit. And then we have a gate that performs a unitary transformation on that, 9 00:00:55,000 --> 00:01:01,000 on that qubit. And the output is carried on the output wire. And that's, that's the 10 00:01:01,000 --> 00:01:06,000 output qubit after the unitary transformation has been performed on it. 11 00:01:06,000 --> 00:01:11,003 Later in the course, we'll, we'll think about quantum circuits, where we have 12 00:01:11,003 --> 00:01:17,001 many, many wires carrying many cubits. And then we'll have gates which, which act on 13 00:01:17,001 --> 00:01:23,001 one or two qubits, on multiple qubits. And the cubits get transformed along the way. 14 00:01:23,001 --> 00:01:28,007 Okay, but for now, we are just thinking about single qubits, and how they get 15 00:01:28,007 --> 00:01:33,082 transformed as, as quantum gates are applied to them. Okay. So, so the first 16 00:01:34,008 --> 00:01:41,070 gate that we'll consider, which is a particularly simple one, is a bit flip. 17 00:01:41,070 --> 00:01:49,075 So, what the bit flip does is, it's given by this transformation X here. And now, 18 00:01:49,075 --> 00:01:56,039 of, of course we, we'd want to check that X is a unitary transformation. So, what we 19 00:01:56,039 --> 00:02:06,036 want to do is look at what's X dagger. But now, since X is real, of course and, and 20 00:02:06,036 --> 00:02:13,005 it's symmetric, when you do the conjugate transpose, you'll just get back X itself. 21 00:02:18,005 --> 00:02:29,051 And in fact, you can even check that x^2 , X, X dagger = X dagger X Well, it's, it's 22 00:02:29,051 --> 00:02:36,055 just identity. So, it's, it is in fact a unitary transformation. And, okay, so, 23 00:02:36,055 --> 00:02:43,026 what does, what does x do? If you start off in the zero state, then you, x0 is, 24 00:02:43,026 --> 00:02:48,084 is the one state. And if you start in one, then you, you end up in< /i> the zero 25 00:02:48,084 --> 00:02:55,046 state. And so, it's a bit flip. But, of course, you might start, the qubit might 26 00:02:55,046 --> 00:03:01,002 start in a superpos ition of zero and one. And so, if you apply X to this 27 00:03:01,002 --> 00:03:07,004 superposition, then zero and one swap places. So, you end up in, well, the 28 00:03:07,004 --> 00:03:13,007 amplitude of zero is now alpha one, and the amplitude of one is alpha zero because 29 00:03:13,007 --> 00:03:21,009 zero and one, swap positions. Here's another gate that that's, that's 30 00:03:21,009 --> 00:03:28,065 interesting. It called the phase flip gate. It's given by this transformation Z 31 00:03:28,065 --> 00:03:36,003 and once again, Z dagger is equal to Z. And so Z times Z, Z, Z dagger is just Z^2 32 00:03:36,003 --> 00:03:43,004 which is the identity. So, this is another unitary transformation. And what it does 33 00:03:43,004 --> 00:03:50,005 is it, it leaves the zero state alone, but applies a phase of -one to the one state. 34 00:03:51,005 --> 00:03:57,006 Now, of course, an overall phase is never, never, you know, it's, it's irrelevant. 35 00:03:57,006 --> 00:04:04,004 Well, what this means is that if you start in the superposition of zero and one, then 36 00:04:04,004 --> 00:04:10,006 the relative phases of these two get changed by the Z gate. And so you, end up 37 00:04:10,006 --> 00:04:21,071 in alpha 0,0 - alpha 1,1. Okay. It's, it's simple to think about this geometrically. 38 00:04:21,071 --> 00:04:29,047 So, the bit flip, one way you can think about it is, that, it's a reflection of 39 00:04:29,047 --> 00:04:40,058 this picture, the 0,1, about the 45-degree line, okay, about this 45 degree access. 40 00:04:40,058 --> 00:04:46,093 But now, if you were living in 3-dimensional space, then you could also 41 00:04:46,093 --> 00:04:53,046 think about it as a rotation. A 180 degree or a pi rotation about this 45 degree 42 00:04:53,046 --> 00:04:58,044 axis. Because what you would do is, you would, you would rotate about this axis 43 00:04:58,044 --> 00:05:04,068 and zero would, let's say, come off the plane and one would go under the plane and 44 00:05:04,068 --> 00:05:10,000 they'd keep rotating until they'd be in the orthogonal plane. And then, they'd 45 00:05:10,000 --> 00:05:16,045 keep rotating until they, they switch places when you, when you go all the way 46 00:05:16,045 --> 00:05:25,027 around. But now, remember, we are working in not the 2-dimensional real space but we 47 00:05:25,027 --> 00:05:30,080 are working in a complex 2-dimensional space. And so, what happens is in this 48 00:05:30,080 --> 00:05:38,009 complex 2-dimensional space, you actually have enough room to do this rotation about 49 00:05:38,009 --> 00:05:43,083 this 45 degree axis. You have these, you know, the imaginary directions where you 50 00:05:43,083 --> 00:05:49,098 can actually do this rotation. And so, so X is really a rotation, a pi rotation 51 00:05:49,098 --> 00:05:57,056 around this 45-degree axis. Similarly, for the phas e flip, well, the phase flip, 52 00:05:57,056 --> 00:06:06,059 what does it do. Well, if you, if you were to draw a zero and one here, then what it 53 00:06:06,059 --> 00:06:19,038 does is, it leaves the, the zero axis alone but it flips one to -one. And so, 54 00:06:19,038 --> 00:06:28,047 it's a 180 degree, well, you could think of it as a reflection about this, this, 55 00:06:28,047 --> 00:06:36,034 this, the, the zero vector or again, in the complex plane, you can think of it as, 56 00:06:36,034 --> 00:06:43,049 it's a rotation through 180 degrees or pi about this axis, about the axis of the 57 00:06:43,049 --> 00:06:50,098 x-axis. Here's another way to think about, about the phase flip. So, what does the 58 00:06:50,098 --> 00:07:00,020 phase flip do to the plus state? Well, remember the plus state is one / square 59 00:07:00,020 --> 00:07:10,000 root two zero + one / square root two one. And so what it does is, it leaves zero 60 00:07:10,000 --> 00:07:20,003 alone, but it applies a phase of -one to one. And that' exactly the minus state. 61 00:07:20,006 --> 00:07:26,007 And similarly, Z, when you applied it to the minus state, gives you plus. And so, 62 00:07:26,007 --> 00:07:32,009 what it's doing is, if you look at the plus and minus states, then it's swapping 63 00:07:32,009 --> 00:07:41,004 these two. Now, that's still, this 180 degree rotation about the, about the zero 64 00:07:41,004 --> 00:07:49,005 axis. Okay. So, now, let's look at the third gate, which is called the Hadamard 65 00:07:49,005 --> 00:07:55,008 gate, or the Hadamard transform. This is one of the most basic quantum gates. And 66 00:07:55,008 --> 00:08:01,005 what it is, is it's given by this transformation, which, in which all the 67 00:08:01,005 --> 00:08:07,043 entries are one / square root two, except the lower right entry, which is -one / 68 00:08:07,043 --> 00:08:20,057 square root two. So, once again, H dagger is equal to H. You take the conjugate and 69 00:08:20,057 --> 00:08:28,073 then transform. You get back the same matrix and you can verify that H^2 is the 70 00:08:28,073 --> 00:08:35,081 identity, H, H dagger is the identity. So, it's a unitary transformation. And now, 71 00:08:35,081 --> 00:08:42,003 let's see what happens if you start with the zero state and apply this gate to it. 72 00:08:42,003 --> 00:08:48,025 Well, if you start with zero, you get the first column, which is one / square root 73 00:08:48,025 --> 00:08:54,084 2,0 + one / square root 2,1, which is a plus state. And if you apply H to one, get 74 00:08:54,084 --> 00:09:02,006 the second column, which is one / square root 2,0 - one / square root 2,1, which is 75 00:09:02,006 --> 00:09:15,066 the minus state. And similarly, H of plus is zero and H of minus is one. Now, if you 76 00:09:15,066 --> 00:09:25,029 look at this a little more closely when you apply H to zero, well, you get an 77 00:09:25,029 --> 00:09:30,077 equal superposition of zero and one. So, if you were to measure after applying H to 78 00:09:30,077 --> 00:09:36,043 zero, you would see zero and one with equal probability. And similarly if you 79 00:09:36,043 --> 00:09:42,062 applied H to one, and then measure, you'd see zero and one with equal probability. 80 00:09:42,062 --> 00:09:48,082 So, it seems as though the information about whether you started with zero or one 81 00:09:48,082 --> 00:09:53,095 is lost, when you, when you, when you apply the Hadamard transform. But 82 00:09:53,095 --> 00:09:59,036 actually, it's not. The information is all put into the sine here, whether the phase 83 00:09:59,036 --> 00:10:06,033 is plus or minus. And in fact, the way we know that the information is not lost is 84 00:10:06,033 --> 00:10:13,028 because when we apply the Hadamard gate twice, we get back to the, the, the bit 85 00:10:13,028 --> 00:10:19,082 that we started from. Okay. So, you know, we saw how, how to think about the, 86 00:10:19,082 --> 00:10:26,076 geometrically think about the bit flip, the gate, the X gate and the Z gate. Now, 87 00:10:26,076 --> 00:10:32,055 let's look at the Hadamard gate and try to understand what it looks like 88 00:10:32,055 --> 00:10:38,033 geometrically. Well, so, remember, what the, what the Hadamard gate does is it, it 89 00:10:38,033 --> 00:10:44,094 swaps between zero and plus, and it swaps one and minus. And so, one way you can 90 00:10:44,094 --> 00:10:52,071 understand it is, if you take this axis which bisects zero and plus, so this angle 91 00:10:52,071 --> 00:11:03,033 will now be pi by eight. Then what, what the Hadamard gate, you can think of it as 92 00:11:03,033 --> 00:11:11,087 is a, is a reflection about this axis, the pi by eight axis. But again, the right way 93 00:11:11,087 --> 00:11:18,048 to think about it in the complex 2-dimensional space is as a rotation 94 00:11:18,048 --> 00:11:24,042 through pi by eight, through 180 degrees of pi, about this pi by eight axis. So, 95 00:11:24,042 --> 00:11:31,013 it's a rotation about this axis where, where everything is rotating by pi. Okay, 96 00:11:31,013 --> 00:11:38,045 so finally, let's think about the following question. So, suppose that you 97 00:11:38,045 --> 00:11:46,061 wanted to implement a phase flip gate. So, suppose I wanted to implement the phase 98 00:11:46,061 --> 00:11:53,029 gate or Z. But suppose that I happen to have no phase flip gates around. But I had 99 00:11:53,029 --> 00:12:00,017 a big flip gate and a Hadamard gate. Would I be able to implement a phase flip gate? 100 00:12:00,017 --> 00:12:06,014 Well, here's a way of doing it. So, remember what the phase flip does. So, if 101 00:12:06,014 --> 00:12:13,014 you, if you, if you write it out, what Z does is, if you give it as input, the plus 102 00:12:13,014 --> 00:12:20,091 state. Then it outputs minus, and if you give it as input minus, then it outputs 103 00:12:20,091 --> 00:12:28,057 plus. And if I can design some gate which, which transforms plus to minus, minus, and 104 00:12:28,057 --> 00:12:35,023 minus to plus, then it must be the phase gate. Okay, so how do we, how do we write 105 00:12:35,023 --> 00:12:42,034 out, how do we create a, a gate that transforms plus to minus and minus to plus 106 00:12:42,034 --> 00:12:49,081 which swaps plus and minus. Well, what we can do, if you are not given Z, is we can 107 00:12:49,081 --> 00:12:59,034 first start by transforming plus 2,0 and -2,1. We can do that by applying a 108 00:12:59,034 --> 00:13:09,022 Hadamard gate. Okay. Now that we've done a Hadamard gate, we can, of course, apply an 109 00:13:09,022 --> 00:13:15,045 x gate, and swap zero with one, and one with zero, alright? So if, if you now 110 00:13:15,045 --> 00:13:20,073 apply an x gate, then zero gets transformed to one and one gets 111 00:13:20,073 --> 00:13:29,001 transformed to zero. And now, if we apply Hadamard again, what, what happens? Well 112 00:13:29,001 --> 00:13:38,050 if you apply Hadamard again, we transform one to minus, and zero to plus. Okay. So, 113 00:13:38,050 --> 00:13:45,059 what, what, what is, what is this sequence doing for us? It's transforming, if you 114 00:13:45,059 --> 00:13:52,041 start with a plus state, then our output is a minor state. And if you start with a 115 00:13:52,041 --> 00:13:59,047 minor state, output is a plus state, which is exactly what we wanted. So, what we can 116 00:13:59,047 --> 00:14:07,062 say is that Z = HXH. Okay? In fact, here's another way to, to picture it. Okay. So 117 00:14:07,062 --> 00:14:14,099 what, what this is, you know, what this diagram is showing you is that, what the 118 00:14:14,099 --> 00:14:21,082 Hadamard does is it swaps zero and plus. It swaps one and minus. X swaps between 119 00:14:21,082 --> 00:14:28,050 zero and one. Z swaps between plus and minus. And so, if you wanted to perform Z, 120 00:14:28,050 --> 00:14:36,025 where you want to swap these two, another way you can do that is perform HXH. If you 121 00:14:36,025 --> 00:14:42,069 want to perform X, another way to achieve that is you, you do HZH. Okay, what does 122 00:14:42,069 --> 00:14:50,032 this correspond to in terms of linear algebra? Well, what you're really doing is 123 00:14:50,032 --> 00:15:00,053 we are saying that Z, the transformation Z is the same transformation as X if you, if 124 00:15:00,053 --> 00:15:05,068 you, if you do the transformation in the Hadamard basis. So, this is really basis 125 00:15:05,068 --> 00:15:12,054 stage. What we're really saying is that if we perform the Hadamard transform, then we 126 00:15:12,054 --> 00:15:18,072 perform X and now we perform the inverse of the Hadamard transform to move back to 127 00:15:18,072 --> 00:15:28,000 our original basis then we get, that's, that's the Z transformation, But of 128 00:15:28,000 --> 00:15:39,030 course, remember that H inverse = H. And so, so, of course, we can write this as Z 129 00:15:39,030 --> 00:15:40,004 = HXH.