Q# Quantum Computing
Q# Quantum Computing
Course Overview
[Autogenerated] hi and welcome to this module on getting started with the Microsoft Want
um, development kit. This is Chuck, and I'm excited to show you how to get started in this
exciting and cutting edge field in this module. You'll first get a brief refresher on what makes
a quantum computer. Well, quantum. This is not meant as an exhaustive overview of
quantum computing, but rather as a reminder of the oddities of quantum computers. He'll also
be reminded of some of the high profile potential applications of a viable quantum computer.
You'll then discover what the current bleeding edge of quantum computing looks like right
now, who the major players are and what their offerings and hardware look like. Finally,
you'll be introduced to Microsoft's offering in the quantum space, the Microsoft Quantum
Development Kit. And it's several components, including the Quantum Simulator. You'll see
how to download and install the Q T K and create your first quantum project. This will be an
exciting module as you'll get to see first hand how a quantum computer algorithm might look.
Let's jump in and get started
Quantum Refresher
[Autogenerated] before we dive into the quantum development kit. Let's take a look back at
what makes quantum computing so exciting and special. It's always helpful in understanding
quantum computing to understand how classical computing works. At the heart of every
modern electronic device are trillions of little switches called transistors. Each little switch
can either be on or off at any given time, much like a light switch. Modern Tektronix get their
computing Power BI, combining trillions of these little switches to form the foundation of all
computer logic in computing. Each of these little switches with their state are often called
bits. In contrast, a quantum computer instead uses a cubit or quantum bit like a bit. A cubit
holds a given state at any one time, but unlike a bit, a cubic can hold multiple states
simultaneously. You could think of cubits like a dimmer light switch, sometimes off,
sometimes on sometimes somewhere in between. The consequences of this, in theory, is that
quantum computers require far fewer cubits, too quickly outpaced the computational power
of the bits of a classical computer. In other words, classical computers double and power if
you double the bits, but quantum computers increase exponentially empower Azure app
cubits. If this sounds un intuitive to you, you are not alone. I invite you to view some of the
other great resource is on Pluralsight to dive into this deeper. Trust me, it does get easier to
understand what time and practice. If you've heard anything about quantum computers, then
you've probably heard a great deal about some of the incredible things they will supposedly
be able to do once we have them. The funny thing about a technology that hasn't been fully
stabilized yet is that it's really hard to know what it will be good for. Quantum computing is
no different, but there are a few areas that might prove fruitful. The first and probably the
most widely circulated idea is the application of quantum computing in the field of
cryptography. These e idea is that a sufficiently large enough working quantum computer
would be able to quickly compromise much of the cryptographic security that protects things
like our passwords and our online transactions. This will certainly be the case for some forms
of cartography, but not for all of them. The second is new ____ research. Current ____
research is hard to do. As ____ reactions are inherently quantum in nature and anything,
quantum is really hard to actually simulate with traditional computers. If a large enough
working quantum computer was available, it's believed that it would be able to accurately
simulate very complex chemical reactions. The third is the financial markets. A lot of time
and money go into predicting future market trends, and the ones who accurately do, whether
intentionally or by luck, usually end up making a lot of money. Making those predictions
accurately is an almost intractable problem with today's computers. This is because of the
massive number of variables that need to be considered, as so many small and similarly
insignificant things can have large effects on the markets. A large enough working quantum
computer, though, could handle that many variables at once and make accurate predictions.
This is at least partially why large financial corporations are getting into the quantum race, a
question often asked when looking into quantum computing is what is currently out there.
While new quantum announcements error made frequently, the major players, as of this
course are Google, who just recently declared proof of quantum supremacy, currently has the
largest working quantum computer we know of at 72 cubits, Microsoft is currently working
on a different type of cubic, called atop a logical cubit is focusing on error correction
techniques and the Q t K. IBM, who very publicly refuted Google's claim to quantum
supremacy, currently has a quantum computer of size 53 cubits. They also have a website to
interact with. Try writing or programs on a real quantum computer. Righetti, who is a bit of a
mystery as they have yet to publicly announce anything big other than an online service
similar to IBMs. A lot of private investment money is going into this company, though. So
big things are suspected. And Amazon, which just launched the Brockett services in a W. S.
This is a service to begin experimenting with computers from multiple quantum hardware
providers in a single place. For example, you could run your quantum program on both IBM
and Google quantum computers and see how they perform. We'll spend the rest of this course
becoming very familiar with part of Microsoft's offering, but the other players have some
very exciting things to offer us well
Intro to QDK
[Autogenerated] Now that you've seen some of the other major players in the quantum
computing field, let's take a long look at the Microsoft Want UM development kit or GUID
Ikea. The Q t K can be broken into three parts. The first is the Q sharp programming
language. Que Sharp is a domain specific programming language built by Microsoft from the
ground up to interact with the current and future quantum hardware. If you're familiar with
either C# or F sharp, you will find Q sharp familiar to work with as it borrows heavily from
those and other languages you'll get pretty familiar with. Q. Sharpen the remainder of this
course. The second part is the quantum simulator. This is one of the most exciting parts of the
cutie K, as the simulator allows you to develop a test and run a quantum program in a local
death environment. The simulator accomplishes this by using our traditional computer
memory to simulate want to more cubits. This number is limited by your computer hardware,
but the very best computers wouldn't be able to simulate any more than about 50 cubits.
You'll get a closer look at the simulator later, when you build and run quantum programs.
The third part of the Q t K is the extensive documentation sample projects and Kolkata's that
Microsoft has provided to help new users get up to speed quickly. All of these resources can
be found on Microsoft's GitHub account in our great resource to spend some time to become
familiar with. You won't as part of this course, but I highly encourage you to do so. Now that
you're familiar with all the parts of the queue decay, let's get it installed. Congratulations.
You are finally ready to get your hands dirty In the world of quantum, this is exciting, as you
will be able to start to see how a potential quantum project might look in this demo. He will
first learn how to download and install the Q t. K. There are a few options on how to do this,
and I'll mention the most common ones. You will then learn how to create your first quantum
project. Creating a quantum project was a personal milestone I had several years ago, and I
hope you feel as accomplished as I did next. You will discover the two main parts of a
quantum project the Q Sharp Quantum code and the C# driver code. Finally, you'll run your
first quantum project using the quantum simulator. The simulator is a tremendous resource
for designing quantum algorithms without an actual quantum computer on hand, and I'm
excited for you to see it. Let's jump in and get to your first quantum project. The Q Decay is
available as either a physics extension for visual studio as a standalone for use with visual
studio code or several other options, like a python Jupyter notebook. All of the code
examples we do in this course could be done any of these ways, But I'll demonstrate the
install and use of the code K in visual studio if you want to use one of the other options, such
as visual studio code. Instead, the install instructions and requirements could be found at this
link for visual studio. You'll want version 16.3 or later and have the .NET core cross-platform
development workload enabled. The download for the cupcake can be found at this link.
You'll want to download and install the visits installer To get the Q T Kate integrated into
your visual studio. I would recommend closing all instances of visual studio before running
the installer. Go ahead and take a few minutes to get that installed.
[Autogenerated] now that you have the Q decay installed. If you open visual studio and create
a new project, you'll see that you now have a few more options available to you. Let's create a
default C# application project so we can See what we will have to work within the next
modules once you click next, you'll need to name your new project something simple, like the
classical Hello world. Then, after clicking, create visual studio, create your new quantum
application. If this is your first time creating a Q C# application, it might take visual Studio a
few more seconds as its setting up the quantum simulator. Congrats on creating your first
cache. Our project. It doesn't do much yet, but it will soon. Let's take a look at the different
parts of a K. C# project. There are two parts that you, the developer will work with. The first
part is the key sharp code. As you can see, this is a very simple example. But since it is Q
sharp, it is your first quantum program. Every que sharp code is structured generally the
same. You define a name space similar to other Microsoft anguish ____. You also define an
operation. This is analogous to a function or a method in this default key sharp application.
The operation simply, um, it's a short message. In the next few modules, you'll learn how to
make much more complex operations and start to see firsthand some of the weirdness that is
the world of quantum. The second is the driver code. This is written in a traditional language
like C# or python, and is the code responsible for invoking of the queue. Sharp code for this
course will be using C# is our driver code. But you are welcome to experiment with any of
the other supported driver code languages. Notice the invocation of the quantum simulator.
Making use of the simulator really is as easy as one line of code making use of the columns
simulator. You statically invoke the C# operation Hello, que? And then wait for it to finish. If
any of these C# features like static, void main methods using blocks or waiting for an
asynchronous call or unfamiliar to you, there are quite a few very good resources here on
Pluralsight to dive into the C# language in this course will not spend any time explain the C#
driver code other than to explain the logical flow. If you are more familiar with python, the
transposition of all the driver code and this course supported driver languages is provided in
the resource is for the course, depending on your debug settings in your visual studio, you
might only see a brief glimpse of the output console to your quantum application once you
run it. If that's the case, a quick trick to force the console to remain open is to add a console
read key in your C# code. If you go ahead and run your default program, you'll see it only
says Hello, Quantum World. But it did this using the Quantum Simulator Congratulations
you've built and run your first quantum program. In the next module, you learn about your
first quantum phenomenon, XML
Summary
[Autogenerated] in this module, you've refreshed your quantum knowledge, including how
cubits and bits differ and some of the possibilities of quantum computing. You then took a
look at the current state of quantum competing and the major players in the field. You then
were able to set up the Microsoft, want, um, development, hit locally and create your first
quantum project. Congratulations on being a quantum death. I know it's not much yet, but up
next you'll learn about your first quantum phenomenon crucial to all quantum algorithms. I
hope you'll join me.
[Autogenerated] Hello and welcome to this module on your first quantum phenomena.
Superposition. This is Chuck, and I'm so excited to introduce you to superposition to be
upfront. Superposition is a bit hard to understand at first, but I'm confident that together we
can reason our way through it. I won't be showing any complex math or physics equations to
explain superposition, but rather using real examples. Let's jump right in and discover
superposition in this module. You'll first be introduced to what superposition is. You'll do this
by first exploring some real world examples that demonstrate superposition, including our
dimmer light switch example from the previous module. You'll then see how to translate
those examples to the quantum world. Looking at a quantum example. You will then explore
where superposition is used in quantum computing and why it's important. Finally, you'll
work through creating the Q sharp code, demonstrating superposition and see the results for
yourself.
[Autogenerated] a logical question now would be. What do waves have to do with the
quantum world? This is a great question, but the answer might surprise you. As you know,
the quantum world is the world of the very small, so small that even light can't _________ it.
We can't see quantum because the wave of light is often bigger than the quantum object itself
that we are after. When you're dealing with objects this small, something surprising happens.
The quantum objects sometimes act like particles like a small ball, as you would expect, but
sometimes the quantum objects act like waves themselves. This idea of acting like a particle
and like a wave is called unsurprisingly, particle wave duality and is a cornerstone of
quantum physics. We won't go any more into the specifics of particle wave duality in this
course, though, if you are wondering, though, how we know quantum objects act like
particles and waves, there is a famous experiment that I actually replicated myself in college.
It's called the Double Slit Experiment, and if you're curious, I would recommend starting
there. Suffice for this course to say, though, that quantum objects error often more wave than
particle. To help illustrate this, let's look at a quantum example. Let's consider an electron, the
small quantum object that orbits the nucleus of an atom. Electrons have several properties
that can be measured. The negative charge they're known for being example. Another
property that they have is called Spin. What causes spin is not important for this course and is
quite complex but for this example will make the assumption that electron spin can be one of
two states up or down. What's interesting about electrons and all quantum objects is that
when you want to measure a particular property until the measurement is made, the object is
actually in a superposition off all the possible states. Once measured, the superposition will
collapse to the base state with the highest probability. So if you consider our electron until we
look or measure, it's actually both up and down, just like how our sound waves were actually
smaller waves combined. The superposition of our electron is the combination of the possible
based states, and this new combination is in turn, a new quantum state. The reasons quantum
objects stay in a superposition until measured is beyond the scope of this course, and to be
honest is quite complicated. But if you would like to investigate further, there is a famous
principle and a famous experiment that will start you down that road. The Heisenberg
uncertainty principle is a key reason for superposition, and the famous experiment that led to
the coining of the term superposition is the stern Gerlach experiment. You might be
wondering. How do we know really know that super position in the quantum world is real?
Perhaps error process is wrong or instruments error too crude. That is a great question. And
what I can tell you is that the Stern Gerlach experiment is more than a lab experiment. It is a
very robust thought experiment that leads to a disturbing but logical conclusion. The Stern
Gerlach experiment is a real mind bending experiment you would probably both hate and
love like I do and has been replicated in the lab time and again, With quantum objects as
small as electrons and as large as buckyball molecules, superposition is real, no matter how
strange it may seem.
[Autogenerated] Now that you have a working understanding what superposition is, you
might be wondering, Why is superposition important superposition Izod, confusing and
complicated to mathematically explain. So why bother? The reason that superposition is
important is because of probability. As we learned in this module, when a quantum object is
measured and the superposition collapses to one of its base states, it collapses to the base
state with the highest probability. In our electron example, you know that the electron spin
can be either up or down, but while in superposition you do not yet know which one. If you
do measure the electron, the result would be the higher probability state. This probability is
based on external factors which we won't discuss in this course, as too much math is needed.
It's this idea of probability that gives a cubit and therefore a quantum computer. It's incredible
potential power if a cubit is in superposition and then you perform some series of operations
on it, or you could say a calculation and then measure the cubit, thus collapsing, it's
superposition. The result is the most probable answer. In fact, this is exactly what the
quantum algorithms discussed in this course do. Almost without exception, those algorithms
such as entanglement, teleportation and shores algorithm start with cubits in superposition. A
final word before you begin writing your own superposition code. If superposition still
sounds confusing, that's normal superposition. And almost any other phenomenon in the
quantum world is not only complex and confusing, they error counterintuitive. As the great
Neil's bore, one of the first physicists to begin reasoning through the quantum world once
said, anyone who is not shocked by quantum theory has not understood it. Seeing
superposition inaction will help. Let's go to the code.
Demo: Superposition
[Autogenerated] In this demo, you will learn to create and demonstrate the phenomena of
superposition. To do this, you will first learn how in Q sharp to simulate cubits using the
quantum simulator. You will then learn the Q sharp operation to put those cubits into a state
of superposition. You'll then make a few modifications to the C# driver code to capture the
output of collapsing the superposition of the cubits and see the result. This is exciting as you
will finally be able to see a quantum phenomenon effect for yourself. Let's jump in for this
demo. You could either modify the example project we created in the previous module, or
you could create a new one called Superposition. This is what I did. But either way you'll
start with the default Hello World Quantum Project. The first thing you'll want to do is
rename the C# operation. This is not strictly necessary, but I suggested to avoid confusion
with the code you will write in later modules I renamed mine to just superposition. Next,
you'll want to change the return type of this acute your app operation from the default of unit
to result. This is so we can. Get the result of our super position to the C# driver code. Now
you're ready to create your first cubit. To do this, you'll make use of a using block just like
you wouldn't C#. The using block just cleans up any resource is initialized. Once out of scope
to create the simulated cubit, the C# library provides an easy to use simple constructor. When
you do create a simulated Cuba this way, it always starts in the base state of zero. Now you're
ready to learn your first Q sharp operation. Since the Cubit is in a default state of zero, we
want to put into a superposition of both zero and one. To do this, you'll use the Hatem Art or
H operator. This operator does some fancy linear algebra under the hood, but for our
purposes, we can just say that it moves it from zero to halfway between zero and one. This is
our superposition now that you have a cubit in superposition. The next step, of course, is to
collapse the superposition and see what happens. To do this, you'll use the Q Sharp Operation
M to measure the cubit. This will collapse the cubit to one of its base states, Either zero or
one. You want to capture that state into a variable appropriately called state. Now that you're
done with your cubit as it's collapsed, you'll want to call the reset method to restore that Cuba
to its default state. If you don't do this, you're Q sharp code will throw an exception at
runtime, as all cubits are required to be reset before being disposed. In this case, at the end of
our using block, you've created a Cuban superposition and measured its state. But nothing is
done with that state yet. To do that, you'll need to capture that state outside of the using block
by creating immutable variable and initializing it to zero now that the state will default to
zero and be overridden once you measure your cubit, all that is left is to return the captured
state at the end of the superposition operation. That's it for the Q Sharp code. Pretty simple to
achieve something so complex. Let's now look at the C# driver code in the C# driver code.
You already have the quantum simulator spun up as that code is included in the default
project, the first thing that you will need to do, though, is get rid of the old call to the default
C# operation and replace it with a good old fashioned for loop. We do this because we want
to create and collapse a cubit superposition not just once, but lots of times to see if collapsing
that superposition really does show a probabilistic trend. 1000 iterations of the loop should be
sufficient for this example. Next, you will need to call the superposition que sharp operation
you just created and capture its returned value. Remember, this is the state of the collapse
Cubit as a side note, if your visual studio complains about superposition run like minded, this
is because you're code has not been compiled yet since reworking the Q sharp code. As long
as the spelling is correct, the compiler will find it correctly. When you run the program in just
a minute now, you just need to keep track of when the result of the cubic collapses a zero or a
one. Go ahead and add a simple if block to check the result inside that. If block you can
increment a counter simply called ones, of course, you want to define that counter outside
your simulator using block. Finally, the last step is to output the results of creating and
collapsing a cubit 1000 times. You conform on your output in any way. But I did. As a
simple comparison like this. All that is left is to run your quantum program and see the
results. Here you can see the results that I found when I ran the program. Your numbers will
likely be close, but slightly different. This difference is expected if you run your program
several times, you'll see that the numbers vary, but generally stay close to a 50 50 split. This
is probability at work, as the cubits we're working with here only have to base states of zero
in one. We expect true superposition to haven't even probability for each of those states.
Congratulations. Not only have you written your first truthy quantum algorithm that
manipulates a cubit, but you've also seen the results of your first quantum phenomena.
Superposition is weird, but the next quantum phenomena you will learn about is downright
spooky.
Summary
[Autogenerated] in this module you discovered quite a bit. You first learned what is
superposition and how weird it really is. You did this not by math equations, error dry theory,
but by real examples. Then you learned why superposition is important as superposition is
what gives a cubit. It's real Power BI. Finally, you learned how to create simulated
superposition in U Q sharp code and to see the results of collapsing the superposition. I hope
you found superposition to be as frustrating and fascinating to learn as I did when I was first
introduced to it. Remember that superposition is the building block for bigger and better
things. And that's exactly what you learn about next. A slightly more complex but just as
shocking quantum phenomena. Thanks for watching, and I hope you'll join me there.
[Autogenerated] Hi. Welcome to this module and to learning about the next quantum
phenomena. Entanglement. This is Chuck, and I'm excited you're here to build upon
superposition and be introduced to entanglement. Super position in the last module was a lot
of fun. To learn about an entanglement is building upon what you learned. As you can
probably guess, You cannot have entanglement without superposition, so I encourage you to
review the previous module if needed before proceeding like in the previous module. I won't
be using any complex math equations to explain entanglement, but simple examples. Let's
jump in and get started with entanglement. In this module, you will be introduced to the
weirdness that is entanglement. First, you will learn just what entanglement is at a basic level.
You'll do this by exploring a simple example that really exposes the UN intuitive behavior of
entanglement, you know, then explore entanglement in the quantum realm by looking at a
simple two cubits system and the strange behavior that can happen, including possibly
breaking the unbreakable math of Einstein. You will then learn how entanglement is
important in the world of quantum computing by looking at an example of scaling
computational resources. Finally, you work through creating the Q sharp code, demonstrate
entanglement and experience the phenomena yourself
[Autogenerated] Now that you've seen an example of what entanglement might look like in
the larger world, let's take a look at how entanglement works in the quantum world. In the
simplest entanglement, you start with two quantum particles like the dials. In the previous
example, the to quantum particles start out independent of each other. Measurement or any
other action upon one does not affect the other to entangle the to quantum particles and
remove that independence. The to quantum particles will first need to enter. A superposition
state, in this example will consider are two quantum particles to have color be the property
that can be in superposition with the two quantum particles in superposition, We do not know
the color of either want. This is fine and really the thought experiment from last module just
duplicated to entangle the to quantum particles. Though you perform an operation on them,
an operation that does not collapse the superposition like we've seen with measurement but in
operation that can change the state of one or both. This is where it can get tricky as you
would be right to ask, How can you change the state if you don't know the state. Turns out in
the quantum world, you can to be more precise. You can perform the operation to make the
change, but you indeed still did not know what it is. When this happens, something incredible
occurs as a to quantum particles were previously in a state of superposition, and now the state
of each depends on the state of the other. Thanks to that operation that was performed, you
cannot describe the state of one without including the state of the other. In other words, one
cannot be without the other. Therefore, they are the same. This is the formal definition of
entanglement when two or more quantum particles cannot have their states described
independently. This is like the to dial example we previously considered and can be realized
by making a measurement of both quantum particles, thus collapsing there superposition and
comparing the results. If one measures to be blue, then the other must also be blue. If the
quantum particles were still independent and not entangled, then what would the
measurement of each be as we've seen, each would have a 50 50 probability for either color
of orange or blue, but when entangled, they always match I mentioned previously that shared
state is only part of the weirdness of entanglement. The other part is even more mind
bending, considering are two entangled quantum particles. While they do need to be in close
proximity during the entanglement operations afterwards, they do not. So let's entangle the
particles and label them A and B. Once entangled, you take particle A and I'll take particle be
and we'll travel light years in opposite directions and then make our measurements. This is
where this gets really weird. Even at such large distances, the entanglement still holds. If you
measure quantum bed and it is orange, then mine must be orange. Also, the key here is that
the measured state could have just as easily been blue. There's still a 50 50 probability of
getting either color, but the entangled quantum particle light years away is guaranteed to
match and order doesn't matter. Quantum particle be could have been measured first, or both
could have been measured at nearly the same time across vast distances and still have the
same result. Somehow, through entanglement, the to quantum particles error, letting each
other know across any distance what state they should be when they're measured. This allows
us to added to our formal definition of entanglement. We can now say that entanglement is
when two or more quantum particles cannot have their states described independently,
regardless of distance. This instantaneous transfer is state across large distances is what
bothered Einstein. He had proven that nothing could travel faster than the speed of light, and
somehow these two quantum particles were communicating much faster. This led Einstein to
call entanglement spooky action at a distance. And, in fact, he and other prominent physicists
at the time refuted the idea and insisted that we just didn't have precise enough methods for
finding that hidden wire that connects the two. Turns out that hidden wire or hidden variable
in the math equations doesn't exist. Explaining that is a bit beyond this course. But if you're
curious, you can look into Bell's three room What you say. What about Einstein in his speed
of light speed limit? Well, it turns out that the speed of light as the ultimate speed still holds
true. But why, that is, we won't explore until the next module a quick note. If you've looked
into entanglement before, even just through a casual web search, you've likely come across
many examples and descriptions that say that measured, entangled quantum particles must
have opposite values rather than identical values. In our to quantum particle example, that
would mean that if one was blue, the other must be orange. Both are valid entanglements.
This is a concept in quantum mechanics that we will not get into called parody. For the
context of this course, you can think of it just as. Having odd parody means opposite values,
and having even parody means having identical values. Both parodies, error, possible and
entanglement, but almost all examples you can find online use the example of odd parody. I
used even parody here because, as you'll soon see, that is the way que sharp works in its
simplest form.
Demo: Entanglement
[Autogenerated] In this demo, you will learn how to create and demonstrate the odd effects of
entanglement. To do this, you will first learn how in q sharp to build upon what you learnt
previously to simulate multiple cubits using the quantum simulator. You will then learn the Q
sharp operations needed to create entanglement between two cubits. You'll then make the
modifications to the C# driver code to capture the effective entanglement and see the result of
instantaneous state transfer. While you're not equipped to send entangle cubits across the
galaxy, like in the previous thought example, you will be able to see the results of that
invisible wires somehow connecting the two cubits. Let's jump in for this demo. You could
choose to either create a new visual studio solution and project like we did in the previous
module. Or you could make use of the solution from the superposition module. This is what I
did, but you are welcome to create an entanglement project wherever you choose. If you
choose to repurpose the superposition solution first, you will want to rename that solution so
it's not to be labeled just for the previous module I renamed mine to Q sharp getting started.
We'll leave the superposition project from the previous module alone and instead at a new
project to the solution, Go ahead and add a new Q sharp application and name it
entanglement. Your new entanglement project will be the hello world example we've seen
previously. Let's go ahead and rename the C# source file from operation to Entanglement.
You'll then want to make a few changes to the entanglement que sharp code. Go ahead and
rename the operation from hello to entanglement like in the previous module. You'll want to
change the return type to return a result instead of the default of unit. This time, though, you
will want to return to results as well. Be curious about the state of both cubits. Go ahead and
get rid of the default Hello message and replace that with a using block to initializer two
cubits. This will be near identical to how you initialized to keep it for superposition rather
than needing two instead of one. Recall that to create entanglement, you first need
superposition. Just like previously. You could do that by using the Hatem art or H operator on
the first cubit. Now you might think that we will need to likewise put the second cubit in
superposition using the H operator. But as you will see momentarily, that won't be needed.
Recall that to entangle two cubits, you need to first have superposition and then perform
some operation that does not collapse the superposition. In this case, the easiest way to do
that is to use the C not operator. This operate is pretty simple to understand And if you are
familiar with low level classical computing, it will probably already be known to you as
Synot is short for controlled. Not what it does is this. If the first cubit passed to it has a state
of one and flip the second Cuba to have the opposite ST it had previously. This operator is
very common in classical computing as remember bits error always either zero or one. But
what about here? Our first cubit is in superposition, so it's both zero and one. So what
happens to the second Cubit? Well, without going too much into the nitty gritty of this enum
operator as a acts upon a cubit, think of it like this when the Senate operator executes it
cannot determine the state of the first Cuban as it's in superposition. So the only option left is
to put the second cubit into the same state a superposition again. This gets back to we know
the math, but we don't understand exactly the how so under the hood, since these error
simulated cubits que sharp nose to entangle the two when this sequence of operations are
applied, there are other ways of entangling two cubits in Q sharp. But this is the simplest. I'd
like to pause real quick and point out how independent the two cubits are until the active
entanglement. Yes, they're both initializer in the same line as part of the using block. But you
could have just as easily, manually initialized both separately on different lines. The result of
entanglement would be the same. In fact, the only point in which the two cubits error together
is the Sena operator, showing that indeed, entanglement does need to start with two cubits in
close proximity. But it need not be after that thinking back to the thought experiment. We
have no way of transporting these cubits physically away from each other as their only
simulations, but real physical cubits have, in fact, had that done in the lab to prove
entanglement. Now that you think you're two cubits are entangled, the best way to make sure
is to collapse them both, like in our previous thought experiment and see what the result is to
do that you'll first seem to make a few mutable variables to store the states. Then do the
measurements of the entangled cubits. Be sure to reset the cubits before exiting. The using
block finally returned the two cubits states to the driver code for evaluation. That's it for the
Q Sharp code. Let's make some C# driver code changes so we can see the result of our
entanglement here in your C# driver code. The changes will be similar to the superposition
code, but with an added twist. First, you'll want to get rid of the default Hello, command and,
like before, create a for loop so you can see the results of entanglement not once but 1000
times. Then, inside your for loop, you'll want to capture the result of an invoking the Q sharp
entanglement operation and store the results in two separate variables as the state for Cuba. It
one in Cuba too like before. You'll want to count the number of times the result of the first
Cuba is one. So you will want to create a bar outside the using block to capture that. Since
we're really concerned with entanglement, consider what you learned earlier that Q sharp
entanglement in its simplest form like this has even parody. We will then expect
entanglement to result in both cubits having the same state. He will want to capture that as
well in a bar outside the using block. Now that you have a way to count up the results inside
the for loop, you want to first check if the first Cuban has a state of one and increment the
ones counter appropriately. Likewise, you will want to also check the state of both to see if
there are equal as we expect an increment that equals counter. Finally, you will want to
output the results of the 1000 integrations of creating and measuring entanglement. You
conform at the output as you like, But I did mine. Is this a simple way to show how many
ones zeros and the percent of the match is found now for the moment of truth. Before we run
the program, though, what do you expect to happen? Are we really somehow creating an
invisible wire connecting two cubits across any distance? Let's find out by running a program
success. We have 100% agreement. Let's talk for a minute on what this means, though, Like
before you have a near 50 50 split on states of zero and one. This again shows the
indeterminant result of cubits in superposition until the actual measurement is made. This
also helps prove the entanglement, as the measurement is not made until after the two cubits
error entangled. The equality result is the real exciting part. Recall that we measured directly
the state of both cubits after entanglement. You can then see that of the 1000 entanglements.
The second cubit always had the same state as the first, regardless of whether was zero or
one. Think for a second about what we're saying. Two cubits in superposition, then whacked
with a special hammer, are now agreeing on the result of a coin flip every time. To say this is
astounding and perplexing is putting it mildly. Congratulations. This is entanglement, a
simple operation on two cubits can produce such astounding results. I encourage you to play
with this code to try and better solidify. The idea of entanglement as entanglement is one of
the hardest concepts not just in quantum computing, but in all of quantum mechanics. I hope
now you can see why Einstein was so bothered by this. But don't be surprised if you find it
spooky yourself.
Summary
[Autogenerated] in this module, you've learned quite a bit. You might even have been
spooked. First you learned what entanglement is and how it's odd effects can be understood.
He did this again not by complex math but by looking at both a larger world example in a
quantum example. Then you learn why entanglement is important, at least partially, as it's
been proven to provide large speed apps in at least some quantum algorithms. Finally, you
learned how to build upon superposition from the previous module and create an entangled
pair of cubits in Q sharp and see the spooky behavior just like superposition. Entanglement
can be frustrating and fascinating to try and understand, but I hope you find yourself curious
to learn more. Entanglement is another building block to be used by complex quantum
algorithms, and the next phenomena you will learn takes entanglement to a whole new level.
I hope you'll join me there
[Autogenerated] Hello. Welcome to this module on the final quantum phenomena of this
course teleportation. This is check. And I'm excited to show you possibly the weirdest
phenomena that you may ever encounter. Superposition and entanglement were odd, for sure,
but teleportation is a phenomenon that will truly amaze you. Teleportation is heavily
dependent on entanglement. So if you need to, I recommend going back to the previous
module to refresh your memory Like before. I will not use any complex math equations, but
the concepts error getting more more abstract as we move along. So a solid understanding is
key. If you're already so, um, I let's jump in. In this module, you will first be introduced to
Alice and Bob and their desire to communicate across large distances. You will get to
understand their situation and how teleportation can help next. And before Alice sends the
message to Bob, you will learn the mechanics of how teleportation works, the cubits and
operations involved and what exactly is teleported? You will then see what happens when
Alice tries to send the message to Bob. Well, Bob, get the message. And more importantly,
will it make sense after understanding teleportation? You will learn why teleportation is
important and what one possible application is. Finally, you will work through creating the Q
sharp code to demonstrate teleportation and experience the phenomena yourself.
[Autogenerated] to start out. Let me be clear when we talk about teleportation in the quantum
world, we're not talking about futuristic technology like on Star Trek. Rather, we're talking
about a naturally occurring phenomenon that happens in the quantum world, which means
that it's on such a small scale that for millenia humanity did not know was even possible.
While is probably happening all around us to understand the teleportation that we are talking
about, we will consider Alice and Bob. Alice and Bob are about to do an experiment where
they will be separated by large distances, but they still want to communicate. Distance is
large enough that traditional communication would be too slow to be effective. So Alice gets
on one rocket ship and Bob gets on the other, and they go to opposite sides of the solar
system to conduct important research using traditional communications. This would require
communications that would take about 27 hours. One way to send the research. Alison
Bobber conducting is more time sensitive than this. So what can they do? Well, we learned in
the last module about quantum entanglement and how two cubits consumption transmit their
state across vast distances instantaneously. Why don't Alyssa Bob use entanglement to
communicate? To start with Alice and Bob will entangle two cubits before they leave and
each take one with, um once they're on opposite sides of the solar system and ready to
communicate, Alice performs a few operations on her entangled cubit. We know from
entanglement that entangled cubit that Bob has will be instantly affected by Alice is actions.
Lets say that Alice does a few operations that encode a message into the Cubit. Then, in
theory, Bob should be able to decode that message on the other side. Right? Let's take a
closer look at the hurdles facing Bob. Let's start with a problem of timing. Remember that
when you measure Cubit or decoding in Bob's case, you destroyed not only the entanglement
that is connecting the two cubits, but also the superposition of the cubit. Measurement is
generally a one way street, so in Bob's case, you only get one shot at it to get the message
from Alice. How does Bob know when to make the measurement? If he measures too soon,
the message would not. You have been transmitted, but if you measure is too late, he runs the
risk of interference collapsing. The entanglement, Alice and Bob could agree on a preset time
to make the measurement. But with such a large distance between them, clock drift is a real
concern beyond timing. How is about to know how to measure his cubit? So far in this course
we have always measured are cubits in the same way. But there are actually many different
ways to measure a cubit. Which one should Bob Jews? Before we answer these questions,
let's take a few minutes to more clearly define the operations and measurements that make up
teleportation.
What Is Teleportation?
[Autogenerated] to understand teleportation. Let's look at a simple example, using not two
cubits but three to start, you would entangle two cubits like we've done previously.
Remember that? Once entangled, the two cubits can be separated by any distance. Once
separated and entangled, a third cubit is introduced at one side of the Quantum Channel
formed by the entangled cubits. This third cubit is the message that we want to transmit. Or,
more precisely, we want to transmit the state of that third cubit. Since the state of the Third
Cubit does not matter directly, it could be any state that we choose. The state of the third
Cuba is encoded onto one of the entangled cubits by performing some of the simple quantum
operations that we've seen previously. Well, look more closely at those operations when we
write our key sharp code to do this. Once the state of the third, Cuba is encoded onto one side
of the entangled cubits. We know that the information is instantaneously transferred to the
other side of the entanglement. To get it out or to read it, we perform some operations to
decode the state from this other end of the entanglement this transforms the state of the initial
message cubit onto this far away Cubit. It is important to point out that the state only has
been teleported. No actual matter. Anything physical has been instantaneously transferred.
Just information. There is one more thing to point out, and this is the big caveat that shows
that Einstein is still right when we discuss entanglement. Previously, one thing that we did
not mention is that once entangled, two cubits can actually be in one of four possible
entanglements. States these error called Bell States. This means that when you entangle two
cubits, entanglement is one of the four possible entanglements states. It's like flipping a four
sided coin. The reason this is a caveat is because in order to properly transfer your message
through the entanglement or to decode the message, you have to know which bell state or
basis it is in. If not, you have a one in four chance of getting it right and a three and four
chance of not getting it right. So the caveat is this. How do you also transmit the Bell State to
measure in? It's not part of the state transfer that moved instantaneously, so it must be
transmitted via classical means or below the speed of light. Let's think about this clearly for a
minute. Yes, you can transmit state or any message faster than the speed of light using
entanglement in teleportation. But you can't reliably read that message unless you have
information that could only be transmitted via more classical or slower means. Einstein was
right yet again. Now that we understand teleportation, let's get back to Alice and Bob. Alice
and Bob have their quantum channel established across the solar system by the use of to
entangle cubits. Alice wants to send Baba message, so she encodes a message onto the
channel to send a bob. But Alice must also send Baba message via radio or light. Or some
classical means the Tell Bob Which of the four ways to try and make the measurement on his
side. Alice and Bob will be unable to use teleportation to quicken their communication across
the solar system, unfortunately, but this is not to say teleportation is not without a valid use.
Let's look at that next
[Autogenerated] you've learned that teleportation will never allow us to communicate faster
than the speed of light. Which is disappointing, to say the least. But that doesn't mean
teleportation is useless. Not many quantum algorithms used teleportation that I am aware of.
But that's not to say future. More complex algorithms could not. Possibly future algorithms
created by you. There is one application that is currently being heavily researched and that is
quantum communication. Quantum communication is the transmission of information via
secure means using quantum phenomena like teleportation. While tell a petition can be used
for faster than light communication, it can be used for secure communications slower than the
speed of light. Communicating across the globe may seem far, but in terms of the speed of
light is not far at all. Lots of research is being done to see if teleportation can be used to
provide completely secure global communication, since only the method to decode the
message is transmitted via classical, possibly unsecure means the actual messages transmitted
securely instantaneously through the power of quantum teleportation. This research is
ongoing and not done, so time will tell if it'll work, but there is promising potential
Demo: Teleportation
[Autogenerated] In this demo, you will first learn the correct C# operations and the correct
order to use them to demonstrate teleportation. You will then create the C# driver code to
view the effects of teleportation. This demo will be similar in a lot of ways to the demo for
the entanglement module. But I hope you still fall along as teleportation is an exciting and
confusing part of the quantum world. Let's jump into the code for this demo. I chose to add
an additional que sharp project to my existing que sharp getting started solution. But again,
you can create your own teleportation project wherever you like. Just like before, adding a
new Q Sharp application project will add the default Hello World Project we've seen several
times. Go ahead and clear that default project to an empty project called teleportation. To
start, let's implement our teleportation que sharp code. By changing the default empty
operation to one called teleportation. This operation will have to do something that we've yet
to do in Q Sharp. Accept an input to the operation to do this is simple. Just specify the name
of the input and the type just after the operation name here we will take an input of sent
message of a Boolean type. The return type of this operation will also be a bully in which can
be either true or false. Since we are returning a Boolean, let's go ahead and define immutable
variable called received message to return at the end of the operation and set it to a default of
falsy. We know that we will need three cubits to perform teleportation. Go ahead and
initializer register or a list of cubits by using a using statement like we've done previously.
Next we need to encode or change her input message sent message into a cubit. This will be
our message cubit from the previous example. To do this, you will want to first get one of the
three cubits initialized and then flip the cubit if sent messages. Truthy remember that all
cubits in Q sharp start in a state of zero. So if our message we want to teleport is falsy, then
we need not do anything. But if the message is true, then we need to flip the message cubit
from 0 to 1. Now that we have our message to Cuba ready. We need the other two cubits
involved in teleportation. First, go ahead and get the remaining two cubits from the register
and named them appropriately. Alison Bob, We know that teleportation depends on
entanglement. So next you should entangle Alice and Bob just like we've done previously
using the H and C, not operators. At this point, we have to entangle cubits Alison, Bob and a
third message cubit that has these encoded state that we want to teleport thinking back to are
thought experiment. This is the point that the two entangled cubits could be separated by
some vast distance to make use of the instantaneous state transfer of teleportation. But as you
can guess, we have no way to do that. In this simulation, we will. Still, they'll be able to see
the effects of teleportation. Now that we're ready, we need to perform the operations to
transfer the state of the message cubit onto one side of the entangled pair. In this case, Al is to
do this you first before Messina operation, just like we've done many times before. But on the
message Cubit and Alice remember, Sena is a flip on the second cubit if the first is one. The
second operation that we performed transfer The message on to the entangled pair is these H
operation that we've also used many times before. It's this combination in this order of C, not
an H that transfer the state of the message cubit on to Al is you might be wondering to
yourself that this looks a lot like entanglement in reverse and you're mostly right. We don't
have the time or scope to dive in to why those two operations in that order do this. But
instead think of it as Alice and Bob are already entangled pair and by performing actions on a
third message, Cubit and Alice, you're affecting Bob as well. Now that our message is
transferred onto the entangled pair, we need to find out which with a four possible Bell states
or basis was used so that a proper measurement on the other side of entanglement can be
made to do this measure and thus collapse the state of both the message cubit and the Al is
cubit and store those as variables. This is the classical information that has to be transferred
via some means other than teleportation and thus restricted to the speed of light. Once that
classical information is transmitted, which, of course here in a simulation is immediately we
can use it to set up the Bob Cuba to be in the correct basis for measurement. Remember that
there are four possible basis for which to measure Bob. So we can determine the correct one
by creating, too, if blocks the first. We'll see if the state of the message cubit that was
measured previously was one and flip the Bob Cubit in the Z basis. Accordingly, the second
we'll see if the state of the AL is cubit was one and flip the Bob Cuba in the X bases. I hope
you can see how we're using two bits of classical information determined one of the four
possible quantum basis for the Bob Cubit to be measured in. Finally, with that set up, using
the classical information done we can make our measurement of the Bob Cubit and get the
teleported state we need to take that state and transform more Dakota back to the Boolean is
that the driver code expects, and that could be done by adding an if block to make the
measurement of Bob and said are returned mutable. Variable accordingly. Don't forget to
reset all of our allocated cubits. Since we used a register, though we can easily reset all of
them at the same time. Using the reset all method. The last thing to do is to simply return the
result. That's it for the Q Sharp code. Let's get the C# driver code set up So we can see error.
Teleportation work in our default and empty C# driver code file. We all want to do a lot of
the same things that we just did in the entanglement module. First set up a few variables for
counting. The number of message is set to true and to keep track of how maney teleported
messages match the original, you will also want to create a random variable from the random
class. This will be used shortly for generating random messages to be teleported like before.
Go ahead and create a using blocks. Set up the quantum simulator and within that using
block, create a 1000 iteration for loop. We want to test our teleportation just as extensively,
as we did for superposition and entanglement within the for loop. We want to first generate a
random message to be teleported. Since our messages error Boolean that could only have two
possible values. We will want to use our random variable to help us go ahead and create a
variable called sent message and use the random dot next method to generate either a one or a
zero by checking the equality of this random number 20 we can get a random, true or false
Boolean. Now that we have our message to teleport, go ahead and invoke our teleportation
que sharp operation just like we've done previously. Be sure to capture the result of that
operation and assign it to a variable called received message. Remember, this is the message
retreat from Bob after teleportation. All that is left now is a checker received message and
output the results First check if the received message is true. An increment The truthy counter
if needed next to the all important check to make sure that the sent message that was
randomly generated is the same as the received message. If they are indeed the same then
Anchorman, these equals counter finally output the results to the console. I use the same type
of console output, as we did previously in the entanglement module. Just changing a few
labels, but you can output yours in any way you would like. The key is to see the distribution
of random, true messages to falsy messages and how often the sent and received messages
agreed with each other. We are now ready to run our code and see the results. Hooray! As
expected, we have a near 50 50 split of initial truthy falsy messages. But the teleport a
message always agrees. Congratulations. You've demonstrated quantum teleportation. Make
sure you take a moment to appreciate what has happened here. We use the quantum
phenomena of teleportation to transfer the state of one cubit across the entanglement of two
other cubits. This was only made possible because of two additional bits information that
were transferred via a different method other than entanglement. I hope you can now
appreciate the weirdness of this phenomena and how it might be leveraged
Summary
[Autogenerated] in this module, you've probably felt a bit of frustration. I know I did. When I
first learned about teleportation, you first looked at an example of Alice and Bob and their
quest to communicate across the solar system faster than light. We set up the situation and
looked at a few face value issues. You then learn concretely what teleportation is and how
reading the result of that teleportation is dependent upon the bell States. Next, you looked at
what teleportation could be used for and what a currently research application for it is.
Finally, you built upon superposition and entanglement to make your own teleportation code
and see the state transfer for yourself. If you're feeling frustrated after learning about
teleportation and realizing that can never be used for faster than light communication, don't
be too discouraged. There are still lots of possibilities with quantum computing up next, we
will briefly look at some of the more famous but much more complicated quantum
algorithms. I hope you'll join me. See you there
[Autogenerated] Hello. Welcome to the final model of this course. This is Chuck, and I'm
super excited to show you some of the more famous and slightly more complex quantum
algorithms. These algorithms are well known in the quantum space, and I hope that you will
enjoy seeing the phenomenon that you've already learned about working in action as a
reminder. If you need to solidify any of the previous phenomena, I highly encourage you to
revisit the previous modules to refresh your memory. Let's jump in in this module. You will
first explore the question of what is a real quantum algorithm, and how does it differ from the
quantum phenomena that we have explored thus far? Next, you look at generally how
quantum algorithms are designed and look at a specific example of a common but complex
chemical process. Finally, you will take a look at to the most famous quantum algorithms and
see them work using some of the concepts you've learned previously.
[Autogenerated] now that you've learned some of the building blocks of quantum computing,
things like superposition, teleportation and some of the common operations like H and C not
how do you take that knowledge and create functional quantum algorithms that provides
solutions to some real world problems? Well, as you have probably guessed from our
previous work, quantum algorithms are a combination of classical computing constructs and
quantum computing phenomena. Constructs like for loop is if statements, methods and
functions, and even using blocks like we've seen many times. These classical constructs have
been around for a long time and are quite good at providing logical flow. Even in a quantum
algorithm, logical flow is still very much important. If the classical parts error so good at
what they do that you might be wondering, where do the quantum parts fit in? Quantum
phenomena are used to perform the parts that they error suited for, like optimizing using the
power of superposition and entanglement. Considering this optimizing idea, roughly
speaking, to optimize classically is to try each solution to find the best one. Now I should
mention that there are many clever classical algorithms that get around trying every solution
in certain situations, but the concept is the same. You're limited in what you can try to get in
time. But using the quantum phenomena of superposition, we know that you could try many
solutions in a much faster way. It's this combination of the logical power of classical
computing with the performance power of quantum computing that enables someone like you
to create algorithms that Consol previously unsolvable problems algorithms that could
possibly change the world.
[Autogenerated] you have the quantum computing knowledge you need and you know how
to make use of the logical power of classical computing. Now you're ready to make that
incredible quantum algorithm, but where do you start? Well, just like with traditional
classical algorithm design, you start with a problem. More specifically, you start with a
problem that is far as, you know has never been solved before. Typically, a problem takes the
form of having some input. This could be just a few data points or many millions. Usually
you would feed this and put into an algorithm and get an answer back almost like a black
box. Well, you don't know what goes on inside. Only that you get a reasonable answer back,
creating an algorithm. Whether classical or quantum is designing that black box, it could be
some of the most challenging work, but also some of the most satisfying. Let's look at a
specific example of a problem that in nature is so common but so complex to solve. Let's say
that you wanted to solve the problem of nitrogen fixation. Well, let's first define what that
problem is. Nitrogen fixation is the process of converting the pure molecular nitrogen in the
atmosphere into ammonia or other related nitrogenous compounds in soil. This is a critical
process that is part of the nitrogen cycle and is essential for agriculture. This is also how
almost all soil fertilizers error made. The process of nitrogen fixation occurs naturally, almost
entirely by microorganisms that error literally everywhere. Nitrogen fixation is also well
known manufacturing process for the production of fertilizers. So what is the problem? The
problem is efficiency. Nitrogen fixation occurs almost effortlessly by these microorganisms
in nature to replicate that process. In the manufacturing plant, though, we expend tremendous
effort and energy as our processes crude, inefficient and basically no more than a brute force
way of forcing the correct sequence of atoms together. So the problem is, what is the
chemical process that microorganisms do naturally to perform nitrogen fixation? We think we
know the inputs and the outputs, but haven't been able to properly do the math, even with the
fastest supercomputers. Classically, you could not model this process completely, but with
the power of quantum computing, you could using quantum phenomena like superposition
and entanglement. You could actually model the chemical reactions and possibly change the
world by drastically changing the energy needed to make common fertilizers. Now that you
know the problem, let's look at how you would build a quantum algorithm to solve this
problem. You would use classical constructs to build up the problem and do the things that
classical computing is really good at things like processing and validating input, transforming
input data and to correct formats and interpreting and out putting results. But the actual
computation the heart of the algorithm, would be a quantum process, a calculation using
quantum phenomena, much like all the phenomenal you have created in this course. Such a
quantum algorithm would look like a set of quantum operations wrapped inside a classical
operation. This is how quantum algorithms are designed by making use of the best of both
worlds. By the way, if you are curious, solving the nitrogen fixation problem will be a result
of quantum computing long before other, more popular applications, like breaking
cryptography and have far more far reaching implications, literally providing a means to
solve world hunger by enabling dirt cheap fertilizer. It is estimated that a quantum computer
with the size of a few 100 cubits is all that will be required with the current top quantum
computers in the 50 to 70 cubit range. That threshold might be closer than we think. Now let's
take a look at some real quantum algorithms.
[Autogenerated] In this demo, you will take a look at two famous quantum algorithms. First,
you will take a look at Grover's algorithm, which is an algorithm designed to showcase the
computational increase of quantum computing over classical by performing a database search
faster than any classical computer ever could. Secondly, you will take a look at Shores
algorithm, which is the famous algorithm designed to break cryptography or specifically find
the energy factors of large numbers. For both of these algorithms will not go through line by
line but rather point out the major constructs and quantum phenomena used. I hope you are
just as amazed by these real world algorithms as I am. Let's jump to the code. This demo will
be a little different than the previous demos and other modules. Rather than walking through
every line of code line by line, I will only point out a few key places to recognize the
quantum nature. And, as you can see, the completed code has already written. This is for two
reasons. One is we could easily spend hours building up these two famous algorithms line by
line, and the others is simply pique your curiosity and give you the Docker, to dive deeper to
understand how they work. One more thing I want to mention before we get started. The code
you see here, which is included in exercise files, is directly from Microsoft. In their quantum
examples, this preserves the helpful explanations and comments to guide you through the
algorithms. The first question about Grover's algorithm probably is. What does Grover's
algorithm do? Simply? It is a list searching algorithm, but amazingly, one that could
guarantee to be faster than any classical algorithm. Imagine. You need to search a list of
names for your own. Classically speaking, you know that you could potentially have to check
every single name to get your answer using Grover's, though you could determine if your
name is in the list in fewer steps in the total number of names. Amazing. Let's take a look at
how Grover's does this. Rather than starting with the Q sharp code, like in previous modules,
we'll start with the C# driver code, as that will help you understand the flow of the algorithm.
As you can see, the driver code is pretty simple, like normal. Stand up the quantum simulator
and then pass it and it into your parameter, representing how many cubits to use to the key
sharp operation. And then I'll put the results pretty simple. We'll look more closely. I want the
output means Once we run the code jumping over to the key sharp code, you might notice
that there are actually two key sharp code files. This is just to separate some of the logic for
easier readability. I think that, I want to point out, is the quantum phenomena that Grover's
uses to outperform classical computers. And based on the description of the algorithm earlier,
you might not be surprised to know that it's the phenomena of superposition. The first thing
that Grover's does is make a superposition of all the cubits. Remember, we accomplish that in
Q shop using the H operator, and this is exactly what they prepare. Uniformed operation
does. Once the algorithm has a set of cubits and superposition to work with, it does. It's actual
magic. By reflecting over the cubits and increasing their amplitude, I won't go into how it
does this. I'll leave that to you to explore, but the result is the correct answer or the one being
searched for will have the highest amplitude of probability in this example. The thing being
searched for us to find for you. Let's run it anyways and see what the results are. Interesting.
You can see by the logs that the Reflection operations, which is the heart of the algorithm,
was only called four times, but it found the answer of 01010 What's remarkable is with five
digits of zero or one that's 32 possibilities to consider the only four steps were needed. I hope
you can see how powerful Grover's can do be. Even with such small numbers of items to
search, imagine the speed benefits of searching list with millions or billions of entries. The
nice thing about this algorithm is this only limited by the number of cubits you can give it to
work with. So as quantum computers grow in size, so does the power of this algorithm. I'll
leave the rest of this key sharp code for you to play with. Let's take a look at shores. Sure, its
algorithm might be the only quantum algorithm you would have heard of before taking this
course. It is famous because catchy news headlines like to use it as the basis of the idea that
quantum computers will break the internet. This is actually only partially true shores
Algorithm will break some forms of cryptography once a big enough quantum computer is
available. But not all, and certainly not the whole internet. I won't go into the detail of how it
would break some cryptography, but if you're curious, I do cover this in my previous course
on quantum computing. What sure actually does, though, is find the factors of large integers.
Looking at the driver C# code, you can see that it does define the number two factor. It also
does some argument checking if you wanted to define your own criteria. And, as expected, it
spins up a quantum simulator and invokes the Q sharp operation. Let's take a look there and
see briefly how Shores works here in the queue. Sharp code. There are a few things I wanted
to point out. Shores is that more complex algorithm than Grovers, and we won't be looking at
all of it. But it's important to point out what quantum phenomena uses and its nature. Shores
is a probabilistic algorithm, which just means that tries many different steps to see which one
works. You can see that here in the code, as cascading checks and operations to see what
quantum phenomenon this algorithm uses. Notice that one of the first operations to be
performed is to estimate the period. Let's jump to that code below. Hopefully, code like this
looks familiar to you. By now, you can see that this operation uses a using block to initialize
some cubits to then perform operations on them. Turns out that for this algorithm, it is using
superposition. In fact, this is only one of several places where superposition is used. It does
this, though, using an operation built into the queue sharp library that we didn't cover in this
course. Now that we've seen how the C# in Q sharp code generally looks, let's run it with the
defaults and see what happens. Amazing. As you can see, it is trying to find the factors of 15,
but it is trying many different ways of accomplishing it, some of which even throw errors.
The key here is scale. This algorithm is believed to perform reasonably for large numbers to
factor, too, like numbers that are hundreds of digits long which classical computers just
cannot do. Now that you've seen to quantum algorithms run and have a basic understanding
of how they work, I highly encourage you to further your key sharp learning by diving into
these two algorithms. Further, there are lots of operations in Q sharp features use that we just
didn't have time to cover but are essential to know.
Summary
[Autogenerated] in this module, you had the chance to explore the world of quantum further.
First, you took a look at what our quantum algorithms and learned generally the various
quantum and classical parts of a quantum algorithm. Then you explore generally how
quantum algorithms error designed by starting with a problem and designing a black box to
take inputs and compute an answer. You even saw how this could be applied to a real world
problem. Finally, you were briefly introduced to two of the more famous quantum
algorithms, Grovers and Shores. To get a better understanding of how quantum algorithms
look, including the phenomena used. That's it for this course. I hope you had as much fun
learning about quantum phenomena and the Q sharp as I did teaching you. This is just the
beginning, though. I hope you can see that with the tools you now have. The knowledge
you've gained and with the help of the amazing resource, is that Microsoft has provided you
can start experimenting now on the quantum algorithms of tomorrow. No need to wait for a
real quantum computer to come to you. You have everything you need to possibly change the
world. Thanks for watching go forth and create something truly amazing