610 likes | 628 Views
Quantum Computing for Programmers. Paul E. Black paul.black@nist.gov http://hissa.nist.gov/~black/. An Experience in Torpor. Steps in reading a computer chip design Add gates to “not done” list Process gates from top to bottom Remove gate from “not done” list Big designs were very slow
E N D
Quantum Computing for Programmers Paul E. Black paul.black@nist.gov http://hissa.nist.gov/~black/
An Experience in Torpor • Steps in reading a computer chip design • Add gates to “not done” list • Process gates from top to bottom • Remove gate from “not done” list • Big designs were very slow Why??? Note: gates added to head of list Paul Black
Computing the Execution • How long does it take to delete gates? • Total time is about n2/2 n • n-1 • n-2 • n-3 • • • • • 3 2 1 Paul Black
How Long to Search an Array? • Code for linear search: while (a[++i].key != value …); • Average number of steps for linear search is n/2 n Paul Black
How Long for Random Search? • Code for random search: while (a[rand(0,a.size)].key != value); • Expected number of steps for random search is n Paul Black
How Long for Binary Search? • Expected number of steps for binary search is log2 n Paul Black
Compare Performance • Type #Loops Time for n=1,000,000 Random: n 1,000,000xcR Linear: n/2 500,000xcL Binary: log2 n ~20xcB where c is time for 1 loop • Ignoring constant multiples, we say random search is O(n) linear search is O(n) binary search is O(log n) Paul Black
Definition of O(m) • Informally, saying f(n) = O(g(n)) means f(n) is less than a constant times g(n) • Formally: there exist positive constants c and k such that 0 f(n) cg(n) for all n k. • Big-O notation can also express memory use, messages sent, average time, worst case, etc. cg(n) f(n) k Paul Black
Definition of θ(m) • Informally, saying f(n) = θ(g(n)) means f(n) equals, or grows as fast as, g(n) • Formally: there exist positive constants c1, c2,k such that c1g(n) f(n) c2g(n) for all n k. • There are also notations for “greater than”, “less than or equal to”, etc. c2g(n) f(n) c1g(n) k Paul Black
Example: Sort Algorithms • Comparison of some sort algorithms Sort Typical Worst Case Bubble sort Θ(n2) same Quicksort O(n log n) O(n2) Heap sort O(n log n) same • Bubble sort: repeatedly pass through the list swapping items until all are in order • Improvements(?) • Bidirectional bubble sort: go both directions • Don’t go beyond last swap Paul Black
Polynomial vs. Exponential • Traveling Salesman: find shortest route to visit every city on a list and return home. • Best exact algorithm is Θ(n!)≈Θ((n/e)n) where n is the number of cities. • Algorithms tend to fall into two classes: polynomial, Θ(np), and exponential, Θ(bn). • These classes are distinct: • Polynomials of polynomials are polynomials • Any exponential eventually exceeds any polynomial Paul Black
Factoring, orWhat good is a quantum computer? 3 eD(log D)2 • RSA, a good encryption scheme, is secure because factoring large numbers is hard • After centuries of work, the best factoring algorithm is the Number Field Sieve • Factor a D-digit number in steps • A key 8 times longer • Takes 64 times longer to multiply, but • Squares the time to factor Paul Black
Shor’s Quantum Algorithm • Using quantum computing, numbers can be factored in D2 log D log log D steps • Classical factoring is exponential, but quantum factoring is polynomial! Paul Black
Quantum Mechanics DEAD or ALIVE Schrödinger’s cat
What Math Should We Use? = ? 10 L 5 L 15 ºC 21 ºC Water Alcohol Paul E. Black
Polarization is really a measurement • A filter yields only photons with the same alignment. • A second filter at right angles blocks all photons. • A third filter in between those two allows some photons to pass. Paul Black
What Really Happens? • Polarization is a vector. Paul Black
What Really Happens? Y X • Polarization is a vector. • Measurement projects the vector onto a new basis. Paul Black
What Really Happens? Y X • Polarization is a vector. • Measurement projects the vector onto a new basis. Paul Black
What Really Happens? • Polarization is a vector. • Measurement projects the vector onto a new basis. • Polarizer passes one basis. Paul Black
What Really Happens? Y X • Polarization is a vector. • Measurement projects the vector onto a new basis. • Polarizer passes one basis. • Next polarizer measures “backinto” original basis. Paul Black
What Really Happens? • Polarization is a vector. • Measurement projects the vector onto a new basis. • Polarizer passes one basis. • Next polarizer measures “backinto” original basis. Paul Black
Superposition • Single slit makes a normal distribution Paul Black
Superposition • Single slit makes a normal distribution • Two slits make interference patterns, even with only one photon at a time Paul Black
Superposition • A quantum system’s state may be several potential places, spins, etc. at once. • Quantum algorithms often start with qubits in a superposition of 1s and 0s. Paul Black
Entanglement • Measuring the polarization of A changes the result of measuring B and vice versa. A A Entangle B B Paul Black
Fakey Entanglement Demonstration Heads are “entangled”: there is a 100% correlation between getting one head and getting the other. We don’t know when we will get heads, but we know we will always get them together. We get an even number of heads from any number of coin tosses. How? ? Paul Black
How Do We Represent a State? Classical (binary) Example for 2 variables: a = {00, 01, 10, 11} Use 1 bit per variable Limitation: Can’t represent superposition or entanglement 1 0 Paul Black
Dirac or “ket” notation • Quantum bit or qubit: … a quantum system with two discrete states.1 • States are expressed in ket notation: • Multiple states are combined using a tensor product in some fixed order: • Tensor product may be implicit and is associative, but not commutative: Paul Black
What is a Tensor Product? Paul Black
How do kets represent superposition? • Superpositions are sums of states, each with “amplitude”: a complex number • Probability is norm squared amplitude, e.g. above is found in state |0> with probability 1/2 • Complex numbers needed for interference • A general 2 qubit system is in state Paul Black
Can We Copy an Unknown State? • We might measure exactly by copying an unknown state onto many other particles. • Formally, assume there is U such that • Is there a consistent definition for U? In other words, what is the value of Paul Black
Proof of the No-Cloning Theorem Paul Black
Quantum Gates Paul Black
Basic Gate: Controlled-Not (CNOT) • If control qubit ψ is 1, data qubit φ is flipped. • Here is CNOT in ket notation Paul Black
CNOT if input is in superposition • If control qubit ψ is 1, data qubit φ is flipped. • What happens if input is a superposition? • The output is entangled! Paul Black
CCNOT: A More Useful Gate • Controlled-Controlled Not or Toffolli • If both control qubits ψ1and ψ2 are 1, the data qubit φ is flipped. • This is the quantum computing version of AND gate Paul Black
Basic Gate: Hadamard • Rotate 90° or “square root of not” 1 H 0 Paul Black
Dirac or “ket” Notation • Equivalent to a vector on the surface of a 3-dimensional Bloch sphere You have reached an imaginary number. Rotate your phone 90° and try again. Paul Black
BB84: DetectableEavesdropping Paul Black
Basic BB84 • Alice chooses random bases and polarizations to send photons Alice’s Basis:Alice Sends: • Bob then chooses random bases to measure the photons Bob’s Basis:Bob Receives: • Photons are discarded when Alice and Bob choose a different basis. Key Value: - 0 - 1 1 • Alice and Bob wish to generate a shared secure private key • If Bases differ, Bob measures randomly polarized photon • If Bases match, Bob measures same polarization as Alice sent Paul Black
BB84 With Eavesdropping • An eavesdropper (Eve) measures the photons sent by Alice in her own random basis and then forwards them to Bob: Alice’s Basis: Alice Sends: Eve’s Basis: Eve Sends: = Bob’s Basis: Bob Receives: Key Value: - 0 - 1 Error! • Eve’s measurement creates a 25% error rate in the key generation Paul Black
The Quantum Processor Checklist • Well-defined quantum states for qubits • State preparation or initialization • Scalable • Pure states • High-fidelity operations “on demand” • Entangling operations and quantum gates • Controlled-Not Gate • Phase Gate • Efficient readout • Little “noise” (decoherence) per operation Paul Black
More information • Paul E. Black, D. Richard Kuhn, and Carl J. Williams, “Quantum Computing and Communication”, Advances in Computers, Marvin Zelkowitz, ed., vol 56, pp 189-244. http://hissa.nist.gov/~black/Papers/quantumCom.html • QCSim quantum simulator available at http://hissa.nist.gov/~black/Source/qcsim.tar.gz Paul Black
More resources • Complexity – Big O notation http://en.wikipedia.org/wiki/Big_O_notation • Summary of quantum algorithms http://www.its.caltech.edu/~sjordan/zoo.html • Known quantum algorithms offering speedup over the best known classical algorithms. It has links to pedagogical (noncomprehensive) surveys of quantum algorithms and an overview at a semipopular level. Paul Black
Density Matrix Paul Black
What is a Density Matrix? a2 - - - - b2 - - - - g2 - - - - d2 |abñ ába| = (a*b*g*d*) = abgd • Sum of probability of pure states • Diagonals are probabilities • Off-diagonals are correlations • Operations are “two-sided”: r’ = |yi’ñáyi’|= U|yiñ(U|yiñ)†= U|yiñáyi|U† = UrU† r = Si pi|yiñ áyi| Paul Black
Density Matrix • Equivalent to a Vector within the Body of a 3-dimensional Bloch Sphere Paul Black
QCSIM Paul Black
Simulation Taxonomy Mixed State QCSim Detail Pure State Classical Discrete Continuous Time • Detail • Classical • Dirac ket (pure states) • Density matrix (mixed states) • Time • Discrete • Continuous • State • Discrete (n-level) • Continuous (finite) • Infinite Paul Black