字幕表 動画を再生する 英語字幕をプリント what is going on? Everybody and welcome to the future. Welcome to part three of the quantum computer programming tutorials. In this tutorial, we're gonna be getting into our very first algorithm, which is the Deutsche Gyoza algorithm. Now. This algorithm is relatively pointless in what its actual outcome is, but instead what it what? It's good for his 22 things. Really. One is it really is an algorithm that is provably faster than a quantum computer in terms of how many like, say, cycles through the circuit are required to get the answer, but also the reason it's more so. It's not just the speed, it's why is it faster? So this is the first time you should get a riel, uh, idea and feeling for how is this working? And then and why is this working? Because the reason why it works is the circuit is able to consider all of the possible inputs that could have come into the circuit, and it can immediately respond with the with the output. So in the output is not output based on input, its output based on the nature of the circuit. And so that's what's cool about this algorithm. It's not the it's not the actual result of the outer rhythm. And I think that point gets lost on a lot of people. Least when I'm looking around at explanations and stuff of the Deutsche shows algorithm as well as some of the others, like the Bernstein boss Ronnie, and even shores out rhythm. Although we I think most people will understand Oh, it breaks encryption. Cool. Okay, but the Deutsche Rosa out rhythm is the inspiration behind Bernstein vase Ronnie Shores out rhythm, and I'm sure many others because it shows. And this was kind of the 1st 1 that shows Ah, you could do this. Stuff like this is these are things that you just can't do with the regular a classical circuit. So let me just formulate really quickly. I don't want to spend too much time explaining some problem, but it would probably be useful to explain the problem. So with the Deutsche Cosa algorithm, you've got a function right. So the function is your black box, and let's say you're gonna passed a two bit string to this box. And the question that we want to answer is is this black box going thio output a constant output, or will the output be a balanced outputs? So will this box always output all zeroes or all ones? Or will it output zeros and ones in a balanced manner? So uneven number of zeros and ones. So with a classical circuit, the only way that you could find this out is it is that minimum to you would need to outputs from the machine. So if we got a two bit string, um, it's going to take it leased to queries, because on the second query, you could find that there's, ah, let's say, on the first query. The result is a 00 The second query. You got a 01 right, and when I say query, I mean, like, passed through the circuit. So to find out if a circuit is balanced or constant on a two bit string, it's going to take it least two passes. As we increase the number of bits in the string that we want to pass through this function, it's going to take longer and longer and longer for a classical circuit to be able to make this determination a quantum circuit. On the other hand, can make this determination regardless of how long that bit string is in one pass. And this is what shows the power of quantum circuits. And again, the problem itself is not useful. It's just this is the most basic representation that we can come up with that shows the attributes that quantum circuits have that classic circuits do not have. So don't get hung up on the problem. Um, get hung up on why this solves this problem. So with that out of the way, let's go ahead and get into it. So to begin, uh, this all rests on a term that I'm gonna coin as had a mard sandwiches. So again, like I said in part one, I'm not a quantum physics expert, okay? I'm not even a physics expert. I'm really not an expert of anything. So But remember, you're just watching the dude on YouTube. So? So I'm gonna use words here that I feel describe what's going on, but they're probably the wrong word. So, um, so, yeah, just just bear with me there. If you're like an actual you know, PhD person, um, feel free to correct me and tell me that the word is correct. And if I've somehow stolen had a mard sandwiches, I apologize. I'm pretty confident. Never seen that anywhere. But that's what it looks like. It's just had words on another on all the sides. So you're just squishing something between Hatem Arts. It's You had a marked sandwich. So anyway, if there's an official term for it, let me know. Uh, so to begin. Well, we're probably need some some of our initial imports, huh? Um, I don't really want to take this out. Everyone should have these. So I'm not gonna do that again. It's a waste of time. So we will have kiss kit. We'll have her. I did check this, by the way. I'm sure by the time this video's coming out after a part too, but I'm sure people will correct me, but I don't know which one is that the new one? But this happens all the time in libraries. I'm gonna go with the shorter one. Uh, but you can import both of these from the shorter one. So cool. So, um yeah, All this stuff is stuff. You seem so the first thing I want to do is show you um, this Hatem art sandwich on, um, What I'm also going to call uncertain cubits. And when I say an uncertain Cuba, this is a cubit that will collapse. Not always to the same, um, to the same answer. So to begin, let's say we've got a circuit and that's going to be a quantum circuit, and we'll give it will make it a 22 and two so two cubits to classical bits. Uh, and then we'll say rotation on the why, and we'll go with math, not pi divided by four on Cuba zero. And then we're just going to do the same thing to Cuba at Index one. So that's our two cubits are done. And then what we're gonna say is I'm gonna call this a Ridge state back, and that's going to be equal to q dot Exe cute. And we're gonna execute the circuit on the back end of this state vex simulator. So just remember, you need if you want to get the state vector's have to do it before you actually take the measurement. Otherwise the circuit will have collapsed and you state vector won't work. I mean, work. It just won't give you what you hoped. So ST Maxim, uh and then we're going to say, die result don't get state vector. So now we have the actual state beck. Uh, and then we will see dot measure. And then we're just gonna measure both cubits to both classical bits and then we'll do a c dot draw. Um oh, que dot Quantum circuit. I see q quantum circuit that I screwed over and and get anything else up. Uh, get state vector. Why not results? Oh, we didn't call results. It's early in the morning. Coffee's still setting in. Cool. Okay, so we have our rotation or measurements. Great. So the first thing I would want to do is let's plot block multi vector, And then we will do the original state Vek. Cool run that. All right, so that's how the original state vector appears. Uh, tow us before we've done anything for any Hatem ARDS or anything. So it's just a quantum circuit. We do a couple rotations on the why, that's what it looks like. Okay, so now let's do Ridge counts equals Q dot execute and we will execute that circuit were going to say back end back and equals the chasm. Underscore Sim shots will be 10. 24. I'm gonna make this, Pepe, and then we will do dot results dot Get underscore counts. And then we will plot hist o gram or Ridge, uh, Ridge under scorer accounts. And then legend equals I don't even need a legend here. Honestly, But I'll put it in. So this is our distribution. So it's going to be important, because first, we're going to, um, trying thio getting above here first. What we want to dio is, um, uncertain cubits. Let's say so. This is for uncertain cubits, just naturally. This is what they look like now. What we're going to do is we're gonna do Unser Ting cubits. Hatem ARDS at front. Okay, um So what we're gonna do is we're gonna take this copy paste, and now we're just gonna add to Hatem our gates to the to the beginning. So how to murder on zero? Had a mark on one. That's our circuit. Cool. Um, we don't actually want to say a Ridge state vector that should be reserved for the original, uh, and then we're gonna do the counts as well. So we've got ST Vek Draw, huh? I guess we'll first Will do Will do everything in the same order. I don't wantto make it confusing as I'm scrolling through here a Ridge State back urn. Actually, state, do we not run? No, we didn't run this. I think I just bring it before I made the change. So, as you can see, the single Hatem aren't actually made kind of a significant difference. Right? So there's that. And then let's go ahead and plot. So, like, Okay, that's how impacted thing. Actual block, multi vector. But, um, how does it impact the actual distribution? So let's do this. So, like, how do these actually collapse? What would it actually end up looking like, so accounts, and then I'll just paste counts. So if we look at this and in fact, let me just just to make it easy, I'll get rid of this after we're done. But so this was the original. It looks as though probably 01 and 10 are unchanged. Um, but really what happened is everything just flipped, right? So now 00 is is frequent as 11 waas. These air stayed the same because they flipped and then 11 it, you know, flip basically, with 00 from the original, So applying the Hatter marred Did something kind of funky here because instead of, um, you know, they were already uncertain. So then you applied the Hatem art, and then it flips them around right? And also change that multi vector pretty significantly. But that's a handy mart in front. Now, what about the, um let's say I had a MARD sandwich on uncertain cubits. Um, all we're gonna do is take this paste. And now we're going Just gonna wrap Hatem ARDS on the other side. So now you can see how Damar had a mark had a mark had emerged. So it's just squishing in these cubits around Hatem our gates. Hence the head of Marc Sandwich s o. Now let's take this. Let's look at the state vector that this produces. And, um, let's go back up to the original just because I think scrolling around it's kind of confusing. In fact, I'm going to just gonna delete this because I don't want to look at it. Um, come down here. I didn't want that to be confusing. Now, when we look at these. Isn't that interesting? So this is the had a morte sandwich. This is your original know Hatem arts. Now this is on again uncertain cubits That starts to look like Wow, it's almost the same. It's just kind of flipped, right? But doesn't it look like if you were to guess where these were gonna collapse? Would you not guess that, like, if I was to guess, I would have guessed that this whole, like flipped output would be what happens? Actually, at this point, right? Like, because they're these air, they look like they're opposite. All right, so I would expect that kind of flip there, but instead, spoiler, spoiler alert. Uh, here's the had a MARD sandwich distribution, right counts regular counts, Just the circuit. We just ran. That's what that looks like. Now let's go up to our original distribution. I'm just gonna copy it. Scroll down here, Hatem Art sandwich on top. Original on bottom, it turns out 1/3 of the same. They give us the exact same output on the distribution. But so what happened though? What happened for us is, even though the output is the same so the circuit outputs the same. What? What we got was the possibility to look at this point. With these cubits here, we could have done something interesting at this stage in the circuit. We could have had another cube, it that does something else that works off of this state here before we get to the final Hatem ARDS and then take our measurements. So So if we had one more cubit, we could do some something based on this superposition state that is basically querying all of the possibilities of input into the circuit without impacting the actual output, which is very interesting. So so that's with an uncertain, uh, uncertain cubits. The next question is, how does this look in front of certain cubits? So imagine, um, let's go with Ah, I guess we'll just do the same thing and then we'll do maybe a knot or something. So that was uncertain cubits. So that's just come down here and let's say certain cubits. And just for the record, all of this that I'm showing is completely act applicability to the Deutsche shows algorithm as well as all of the other fancy ones that everyone's ever heard of. it's it's This is the concept that is important. So not just wasting your time, I promise. So now let's look att Had Amar, Let's look at certain cubits again. I don't know if that's the right word. I just That's that's what I'm thinking of. When I look at these, I'm like, Okay, this is always going to collapse in such such a way. So rotation on why is uncertain. But we could either do nothing or just to do something. Let's just do a not gate, OK, so we'll just a c x and then see x here. So that's our what we've got now, uh, and then we'll just do it. We'll just take this multi air the state vector here. So now what we do is let's apply ahead a mard on so had a mard in front of certain cubits rips and then I'm gonna make some space. We're not constantly dealing on the bottom. Here s so now what we're gonna say, si dot h zero and then we will do the one draw. We don't want to call this original state back anymore. Um oh, I kind of want to do the, uh I'd like to do the original counts as well. Let's go ahead. Let's get that done as well. So I mean, let me just pop that in here, so just be for bottom. Well, give us that. So there's there because we'll be the vector, and then we'll do this. I should give it to us. Let me just make sure. Haven't made some sort of silly error here. We should just get one, though, right? So So we always get a 11 Okay, so then we throw a, uh, Hatem art in front of everything and then change this to be state vector.