 Okay, so this is going to be an introduction to some project called qubit Which I hope none of you will ever ever heard of because it's a bit weird Which is why I'm gonna start with the reason I wrote it rather than what it actually does step one coding is simple It's very very easy. Okay. We're still getting wrong, but it's easy This is what typically you get given to do someone comes up and says this is the way it needs to run And we'll write a piece of code that does it Yeah hardly rocket science is it This is very very simple coding and that is actually rocket science by the way That equation is how rockets get up into orbit a Russian guy invented that many many years ago So coding obviously bit simple getting a bit bored by it So let's do something hard for a change. Let's make a library that purposely makes coding more difficult and It's a lot harder the rocket science. It's actually quantum mechanics Qubit uses the quantum superposition principle of the Heisenberg uncertainty principle those that have heard stories about cats in boxes Will be moderately aware of this Basically the quantum superposition says we'll have a variable and instead of the variable having a value inside it This variable will have lots of values inside it at the same time If you perform an operation on this variable you perform that operation on all the values inside the variable At the same time Anyone completely confused yet? You should be so Practical example and some code this makes things much more real. So we'll create a qubit You'll be seeing it's a C++ thing, but don't let that scare you We'll create a qubit with all the values between 10 and 25 in five increments. That's those values there Q now contains all of these values at the same time so If I take this variable with all the values at the same time and I say is it less than 20 what it's actually saying is Look at any of those values Within that and if they're less than 20 will have a result and Just like these Schrodinger's cat experiment You don't actually get an answer When you perform the operation you only get an answer when you look at it This is the really freaky thing about quantum mechanics The answers only happen when you look at it, which means you then destroy The quantum superposition the state collapses to use the geek vernacular So this performs the less than 20 operation on everything in here at the same time And then when you say actually I want you to copy that into answer It does it gives you an answer if any of those numbers is less than 20 But in doing so destroys Q and there's nothing left in Q anymore The code kind of makes some sort of sense, but the mechanics on why? Bit weird, and that's why it's quite hard to do anything with this The uncertainty principle is a very old physicsy thing since 1923 or something Copenhagen conjecture Someone will correct me, but you know as I say quantum mechanics is easy. That's just an equation like any other Also coding gets a bit dull I would probably forgo an entire year of pizza if I never had to maintain a piece of old crap buggy code If I had to refactor something else's piece of junk go hunting for bugs if I could just write new code all day every day That would be great Unfortunately, you're not doing that you're lumbered with junk and you end up coding for edge cases like this This is the day-to-day bread and butter the sort of rubbish a lot of us have to put up with So wouldn't it be great if we could write with an API? That's a little bit more interesting where variables disappear and have lots of values at the same time Have a guess. Yeah, keep its interesting as well as complex. So Same sort of thing again We'll create a Q bit is this time is going to be integer base, but who cares? And we're gonna add a whole load of numbers between two and the square root of some other arbitrary number Floating point inaccuracies of the reason we add this point one plus one bit at the end So say take number a hundred We're gonna look at a Q bit with the values of two three four all the way up to say ten or eleven It's gonna have all of those values at the same time We'll then do the module operation on everything and the calculation of everything at the same time So that's and I think I probably even got a slide say yes so effectively this performs the operation of Ten module to where the remainder is zero at the same time It does it with three and four and five and so on and so on and so on and you can see that the remainders are actually the same so Before I hit next can anyone guess what happens now? I've got all my numbers between two and ten I'm finding out which ones have a zero remainder and which ones have a non zero remainder non zero remainder Which means in the one line of code I have then asked for every single prime number or every point within this set is this number prime with one line Anyone else got a library that can do prime numbers with one line. That's that interesting that isn't called the prime number library It's quite interesting. You can do funky things with this so um Now in completely uncommon to other talks. What is it other than doing weird dull and interesting clever stuff See bit is a C++ template which means there's one header file Which you can just include from your C code it does funky things. It's gpl Of course, otherwise, they wouldn't let me in and Damian Conway who's a very smart chap. I think he's Australian University someone will probably know um, yeah My memory is getting better in this old age So he come up with a poem module that did this sort of thing and I thought I don't program pearl Willy enough to be able to use this but I can do C++ so I had to go myself and There's a website, which is badly formatted as is usual for my sites So the sound bite the bit that I shall read and pretend it's very intelligent Qubit is a library to support quantum superpositions in C++ This allows each Qubit variable to hold a number of different valuable at variables values Values at the same time memories fine eyesight's going Normal mathematical operations can be performed on a Qubit, but they affect every value in the Qubit at the same time By any operations on two Qubits cause a result based on every possible outcome Yes Verbal's have everything in them at the same time, which means any operation is sort of the multiplier folks. There's a lot of possibilities So whoops, let's go back possibly Yes So if you've got a Qubit with all the values between one to five and you then add 12 you then have all the values Between 13 and 17 if you multiply it by two then you have all the values between 26 and 34 in multiple two Which means if your hotel runs out of rooms and you have a hotel with an infinite number of rooms You just move everyone to the double and there's lots of space in between That's also a weird problem if you get bored right, so Is there an easy way of doing all this interesting clever stuff? Yes It's just a set really if you kind of want to break it down You've got a set of numbers, so you perform an operation on a set you perform it to the whole set The all operation that we saw if all of the numbers are less than 20, that's the union if it's any then that's you know an intersection of We have a state however, that's what differentiates sets to quantum superposition states. What state is it in? And we have clever words for those as well to stop the lay people getting involved so Disjunctive states that's that's the any so if any of the numbers within a particular set are less than 20 Then at least one of these numbers is less than 20 We don't know which one because by the time we have a look at the answer is disappeared But we know at least one of them was less than 20 and that might be good enough Conjunctive that's our geeky term for all of them So all of these numbers will have to be less than 20 in order for the result to be true The collapse state is when we actually go to look at the answer That's the bit where it gets actually quite interesting So as soon as we look at that answer the state collapses We can get nothing out of that qubit anymore except was it true or false? Now obviously that's not completely useful if you say oh, yeah, give me what numbers were prime. It goes yes I'm sorry The answer is yes, some of those numbers were prime Well, I'd kind of like to know what numbers were prime because that's why I'm doing a calculation So to do that we have eigen states again another clever geeky term to stop ordinary people muscling in on our fun That basically says just before I collapse the state I'm gonna make a note of everything that returned true in that last operation and they're gonna go into the eigen state of That qubit So you can then query it if you want to So we've had a look at various qubit things in use I've used the same numbers again just because it makes it my copy and paste job on the slides easier so Any is less than or equal to all Looks a bit strange. It's not what you expect So what it actually means is are any of these numbers less than or equal to all of these numbers That's every combination and obviously there's gonna be one case and one case only where this is true What is the case where any of those numbers is gonna be less than all of the others? It's gonna be the smallest And if you use the eigen states you can get out which number was the smallest and not just yes a number was the smallest There will always be not one number and it will always be the smallest and that's how you can do min It's an interesting way of doing min and not the way I was taught but as I said, it's more interesting than just normal stuff Here's another one. I this is also in the samples in the in the guitar All the numbers between two and five two five four for some reason I don't remember why I picked that so now let's divide That larger number two five five By any of the other numbers Anyone want to start hazarding guesses at what's coming up? We've divided them they're existing We'll then do the floor which is sort of rounding off knocking off any decimal points afterwards and seeing if it's the same as the number before So now we've got all these numbers we've divided it by any of the others that happen to be there and Said is it actually a whole number? So those actually return all the factors of two five five Without actually any code at all. I mean two lines to find out multiple factors Sives are you know annoying and boring to program. Anyway, this is slightly interesting two lines to do full And I've got funny brackets as well. Yes So in practical use this project has lots of applications and we want lots of developers to Know there's absolutely no practical use as far as I can see currently For modifying any numbers like this using quantum superpositions But how else can you talk about quantum superpositions on a Sunday afternoon and not sound pretentious? So I'm sure you'll come up with some good practical uses at some point for this I certainly haven't But it's nice and hard. It's a difficult problem You can find really funky solutions defining prime numbers factorials other mathy type things Interesting ways of combining sets subsets of sets subsets of subsets of sets other things like that It forces you to think a little bit differently about how you'd normally use a library You just say pump in day-to-day to comes out It almost Makes you realize why you enjoy programming in the first place Is that fun problem-solving element and because it does it in such a different way you have to solve problems in a different way One practical use of quantum mechanics is those who are reading ahead will know is that if you've got all of these things They're at the same time Then actually you can't encode anything anymore. You can't encrypt anything Because you just say well, here's a qubit with all of the possible Decode instructions approaches keys algorithms and just apply them all at the same time and It will do that and when we have a proper physical working quantum computer It will break every single encryption we've ever seen which is going to be quite interesting for governments More interesting for those of us said haha told you But it's gonna be quite interesting time So if anyone has a quantum computer, they want to lend to the project so we can start porting it Or a time machine that will go back to when they're possible. That'll be great so It'll come sometime. I'm sure So I did lie about one thing. It does have a couple practical uses. There is an algorithm called shores algorithm It does some interfactorization things. So it is practical. It can solve some problems But we actually have other methods for doing this other than using a quantum state, but it's there and it's possible And I'll now like for the mathematicians in the room to get the last reference Okay, never mind wasn't funny anyway But if there are actually any questions that I could possibly answer all questions will be answered with the words yes And no at the same time Go ahead and ask them now because I think we've still got a minute and a half Like you I was on time. That's unusual. I waffle Do I actually get everything right? So, yes, careful Potentially, yes. Yeah, the question is if you're doing lots of these operations with lots of any's and all's Will question is if you're running a Query such as these any's and all's will it actually complete will it finish? Will could it go on forever is the sort of crux of the question the answer is yes It could you know that it won't because you're going to be having a data set Which is finite limited by your memory, so It will eventually finish, but whether it's within your lifetime or anybody else's is another matter, but You have a question at the front on the real quantum computer the other question being The first part of the question was can you work out how long it would take and the answer is yes You can work out how long it would take for all certain problem domains Some of them you won't be able to but if you're implementing that sort of algorithm Your and they're quite complex algorithms. You should be smart enough to know how long they're going to take When you come to run it? Again, the full discussion is too long for these slides but it's also and I was going to tell you the real practical use for this application unfortunately we can't You