[{"data":1,"prerenderedAt":3143},["ShallowReactive",2],{"blog-post-quantum-interference":3,"sibling-dives-quantum-interference":3141,"learn-track-quantum-interference":3142},{"id":4,"title":5,"authors":6,"body":8,"breadcrumb":3099,"builders":3103,"byline":3116,"category":3117,"categoryName":3117,"challenge":3117,"courseAuthor":3117,"courseLead":3117,"dek":3118,"description":3119,"draft":3120,"extension":3121,"eyebrow":3117,"featured":3120,"finish":3117,"fork":3122,"hero":3117,"heroAlt":3117,"heroCta":3117,"heroImage":3117,"homepageFeatured":3120,"kind":3124,"lessonCount":3117,"meta":3125,"navigation":3126,"newsItems":3117,"next":3117,"ogImage":3127,"order":3117,"outcomes":3117,"path":3128,"publishDate":3129,"readingTime":3130,"related":3131,"relatedProjects":3117,"seo":3132,"stem":3135,"tags":3136,"track":3117,"trackName":3117,"__hash__":3140},"blog\u002Fblog\u002Flearn\u002Fquantum-interference.md","Understanding Quantum Interference",[7],"nico",{"type":9,"value":10,"toc":3083},"minimark",[11,30,33,38,47,51,54,69,72,75,78,81,84,88,91,94,97,100,104,111,558,619,627,633,641,644,648,651,669,689,721,746,759,763,766,769,1194,1197,1203,1207,1216,1528,1531,1537,1581,1584,1589,1592,1684,1687,1701,1708,1712,1715,1722,1725,1924,1927,2098,2101,2104,2112,2116,2119,2122,2270,2273,2276,2527,2530,2536,2540,2543,2548,2551,2796,2799,2805,2808,2815,2819,2822,2825,2828,3044,3047,3050,3053,3057,3063,3069,3079],[12,13,14,15,20,21,25,26,29],"p",{},"A qubit in ",[16,17,19],"a",{"href":18},"\u002Flearn\u002Fquantum-superposition","superposition",", measured, gives you ",[22,23,24],"code",{},"0"," or ",[22,27,28],{},"1"," at random. Run the circuit a thousand times and you get roughly five hundred of each. One line of Python does the same thing on a laptop, faster, with no queue in front of it.",[12,31,32],{},"So the reasonable question after meeting superposition is what the rest of the machine is for.",[34,35,37],"h2",{"id":36},"what-is-quantum-interference","What is quantum interference?",[39,40,41,44],"quick-answer",{},[12,42,43],{},"Quantum interference happens when a circuit can reach the same outcome by more than one route. Every route carries an amplitude, a number with a size and a direction, and the simplest useful case is an amplitude that is just positive or negative. The routes leading to one outcome are added together, and the probability comes from the size of that sum. Routes pointing the same way reinforce each other. Routes pointing opposite ways cancel.",[12,45,46],{},"Without cancellation a quantum computer is only a random number generator. Superposition on its own hands you every outcome with some probability, spread flat. Interference lets an algorithm strip probability off the answers it does not want, and every share it removes turns up on the answers it does. Grover's search below takes a one-in-eight guess to a 94.5% hit rate that way, with nothing in play but signs adding and subtracting.",[34,48,50],{"id":49},"where-interference-came-from","Where interference came from",[12,52,53],{},"Interference turned up in light long before anyone built a qubit, and it has been demonstrated in bigger and bigger things ever since.",[55,56],"timeline",{"l1":57,"l2":58,"l3":59,"l4":60,"l5":61,"l6":62,"w1":63,"w2":64,"w3":65,"w4":66,"w5":67,"w6":68},"Thomas Young splits a narrow beam of sunlight with a thin card and observes bright and dark interference fringes.","G. I. Taylor gets the same fringes from light as faint as a candle a mile away, after a three-month exposure.","Davisson and Germer diffract electrons off a nickel crystal, showing matter does it too.","Claus Jönsson builds an actual double slit for electrons.","Tonomura's team uses an electron biprism and films single electrons landing one dot at a time and assembling the pattern.","Markus Arndt and colleagues in Anton Zeilinger's group get interference from molecules of sixty carbon atoms.","1803","1909","1927","1961","1989","1999",[12,70,71],{},"At Young's bright fringes the light from the two slits arrives in step, and the two contributions add.",[12,73,74],{},"The dark bands are the ones that need explaining. Each is a place light can reach through either slit and does not arrive at all, and blocking one of the two slits makes it brighter. The second route subtracts from the first instead of adding to it.",[12,76,77],{},"The apparatus changes down that list, from a card to a needle to a crystal to a biprism. Every one of them produces interference from routes that could have been taken.",[12,79,80],{},"Taylor dimmed his source to the equivalent of a candle a mile off and left a plate exposed for three months. The fringes came out as sharp as with a bright lamp, so the pattern does not need a crowd of photons pushing against each other. Tonomura's electrons arrived on the screen as separate dots, and the pattern assembled itself out of them over about twenty minutes.",[12,82,83],{},"Feynman used the two-slit experiment to introduce the rule the next section is about: add the amplitudes first, and work out the probability from the sum.",[34,85,87],{"id":86},"adding-before-squaring","Adding before squaring",[12,89,90],{},"Probabilities only ever pile up. Two routes to the same outcome, each with a one-in-four chance, give a one-in-two chance of getting there. Two positive numbers do not add to zero, so Young's dark bands cannot come out of arithmetic like this.",[12,92,93],{},"A quantum state carries an amplitude for each outcome. Squaring an amplitude's size gives the probability of that outcome, so a negative amplitude and a positive one of the same size are equally likely to be measured. When two routes lead to the same outcome their amplitudes are added first, and the squaring happens to the sum. Amplitudes are complex numbers in general, and the sign is the part of that which this article needs.",[12,95,96],{},"Take two routes with amplitudes of +0.5 and −0.5. Add them and the sum is 0, and 0 squared is 0, so the outcome never happens. Square them first and each route gives 0.25, and 0.25 plus 0.25 is 0.5, so the outcome happens half the time. Same two routes, and only the first order produces a dark band.",[12,98,99],{},"Cancelling in one place does not lose the probability from the pattern as a whole, which always totals one. Where routes cancel the probability goes down, and where they reinforce it goes up, which is why a bright band is brighter than either slit produces alone. An algorithm arranges this deliberately: cancel the answers you do not want, and what is left concentrates on the ones you do.",[34,101,103],{"id":102},"the-smallest-cancellation-you-can-make","The smallest cancellation you can make",[12,105,106,107,110],{},"Young's experiment is three lines of Python. A Hadamard opens two routes the way the two slits do, and an ",[22,108,109],{},"rz"," sets how far out of step they are. A second Hadamard brings them back together at the screen.",[112,113,117],"code-block",{"name":114,"tag":115,"run-href":116},"one_phase.py","Python · Playground version","\u002Fu\u002Fqollab\u002Fgrovers-search",[118,119,124],"pre",{"className":120,"code":121,"language":122,"meta":123,"style":123},"language-python shiki shiki-themes one-dark-pro","# 'backend' is pre-created for you in the Qollab Playground.\nfrom math import pi\nfrom qiskit import QuantumCircuit\n\ndef zeros(theta):\n    qc = QuantumCircuit(1, 1)\n    qc.h(0)\n    qc.rz(theta, 0)\n    qc.h(0)\n    qc.measure(0, 0)\n    counts = backend.run(qc, shots=1000).result().get_counts()\n    return counts.get('0', 0)\n\nfor name, theta in [(\"0\", 0), (\"pi\u002F4\", pi \u002F 4), (\"pi\u002F2\", pi \u002F 2), (\"3pi\u002F4\", 3 * pi \u002F 4), (\"pi\", pi)]:\n    print(f\"rz({name:>5}) -> {zeros(theta)} zeros out of 1000\")\n","python","",[22,125,126,140,159,174,182,204,232,250,267,283,303,346,373,380,458,505],{"__ignoreMap":123},[127,128,131,136],"span",{"class":129,"line":130},"line",1,[127,132,135],{"class":133,"aria-hidden":134},"qg-cue qg-cue--empty","true","​",[127,137,139],{"class":138},"sV9Aq","# 'backend' is pre-created for you in the Qollab Playground.\n",[127,141,143,145,149,153,156],{"class":129,"line":142},2,[127,144,135],{"class":133,"aria-hidden":134},[127,146,148],{"class":147},"seHd6","from",[127,150,152],{"class":151},"sn6KH"," math ",[127,154,155],{"class":147},"import",[127,157,158],{"class":151}," pi\n",[127,160,162,164,166,169,171],{"class":129,"line":161},3,[127,163,135],{"class":133,"aria-hidden":134},[127,165,148],{"class":147},[127,167,168],{"class":151}," qiskit ",[127,170,155],{"class":147},[127,172,173],{"class":151}," QuantumCircuit\n",[127,175,177,179],{"class":129,"line":176},4,[127,178,135],{"class":133,"aria-hidden":134},[127,180,181],{},"​\n",[127,183,185,187,190,194,197,201],{"class":129,"line":184},5,[127,186,135],{"class":133,"aria-hidden":134},[127,188,189],{"class":147},"def",[127,191,193],{"class":192},"sVbv2"," zeros",[127,195,196],{"class":151},"(",[127,198,200],{"class":199},"sb9H8","theta",[127,202,203],{"class":151},"):\n",[127,205,207,209,212,216,219,221,224,227,229],{"class":129,"line":206},6,[127,208,135],{"class":133,"aria-hidden":134},[127,210,211],{"class":151},"    qc ",[127,213,215],{"class":214},"sjrmR","=",[127,217,218],{"class":192}," QuantumCircuit",[127,220,196],{"class":151},[127,222,28],{"class":223},"sVC51",[127,225,226],{"class":151},", ",[127,228,28],{"class":223},[127,230,231],{"class":151},")\n",[127,233,235,238,241,244,246,248],{"class":129,"data-cue":28,"line":234},7,[127,236,28],{"class":237},"qg-cue",[127,239,240],{"class":151},"    qc.",[127,242,243],{"class":192},"h",[127,245,196],{"class":151},[127,247,24],{"class":223},[127,249,231],{"class":151},[127,251,254,256,258,260,263,265],{"class":129,"data-cue":252,"line":253},"2",8,[127,255,252],{"class":237},[127,257,240],{"class":151},[127,259,109],{"class":192},[127,261,262],{"class":151},"(theta, ",[127,264,24],{"class":223},[127,266,231],{"class":151},[127,268,271,273,275,277,279,281],{"class":129,"data-cue":269,"line":270},"3",9,[127,272,269],{"class":237},[127,274,240],{"class":151},[127,276,243],{"class":192},[127,278,196],{"class":151},[127,280,24],{"class":223},[127,282,231],{"class":151},[127,284,286,288,290,293,295,297,299,301],{"class":129,"line":285},10,[127,287,135],{"class":133,"aria-hidden":134},[127,289,240],{"class":151},[127,291,292],{"class":192},"measure",[127,294,196],{"class":151},[127,296,24],{"class":223},[127,298,226],{"class":151},[127,300,24],{"class":223},[127,302,231],{"class":151},[127,304,306,308,311,313,316,319,322,326,328,331,334,337,340,343],{"class":129,"line":305},11,[127,307,135],{"class":133,"aria-hidden":134},[127,309,310],{"class":151},"    counts ",[127,312,215],{"class":214},[127,314,315],{"class":151}," backend.",[127,317,318],{"class":192},"run",[127,320,321],{"class":151},"(qc, ",[127,323,325],{"class":324},"s_ZVi","shots",[127,327,215],{"class":214},[127,329,330],{"class":223},"1000",[127,332,333],{"class":151},").",[127,335,336],{"class":192},"result",[127,338,339],{"class":151},"().",[127,341,342],{"class":192},"get_counts",[127,344,345],{"class":151},"()\n",[127,347,350,352,355,358,361,363,367,369,371],{"class":129,"data-cue":348,"line":349},"4",12,[127,351,348],{"class":237},[127,353,354],{"class":147},"    return",[127,356,357],{"class":151}," counts.",[127,359,360],{"class":192},"get",[127,362,196],{"class":151},[127,364,366],{"class":365},"subq3","'0'",[127,368,226],{"class":151},[127,370,24],{"class":223},[127,372,231],{"class":151},[127,374,376,378],{"class":129,"line":375},13,[127,377,135],{"class":133,"aria-hidden":134},[127,379,181],{},[127,381,383,385,388,391,394,397,400,402,404,407,410,413,416,419,421,424,426,428,431,433,436,438,440,443,446,448,450,452,455],{"class":129,"line":382},14,[127,384,135],{"class":133,"aria-hidden":134},[127,386,387],{"class":147},"for",[127,389,390],{"class":151}," name, theta ",[127,392,393],{"class":147},"in",[127,395,396],{"class":151}," [(",[127,398,399],{"class":365},"\"0\"",[127,401,226],{"class":151},[127,403,24],{"class":223},[127,405,406],{"class":151},"), (",[127,408,409],{"class":365},"\"pi\u002F4\"",[127,411,412],{"class":151},", pi ",[127,414,415],{"class":214},"\u002F",[127,417,418],{"class":223}," 4",[127,420,406],{"class":151},[127,422,423],{"class":365},"\"pi\u002F2\"",[127,425,412],{"class":151},[127,427,415],{"class":214},[127,429,430],{"class":223}," 2",[127,432,406],{"class":151},[127,434,435],{"class":365},"\"3pi\u002F4\"",[127,437,226],{"class":151},[127,439,269],{"class":223},[127,441,442],{"class":214}," *",[127,444,445],{"class":151}," pi ",[127,447,415],{"class":214},[127,449,418],{"class":223},[127,451,406],{"class":151},[127,453,454],{"class":365},"\"pi\"",[127,456,457],{"class":151},", pi)]:\n",[127,459,462,464,467,469,472,475,478,481,484,487,490,492,495,498,500,503],{"class":129,"data-cue":460,"line":461},"5",15,[127,463,460],{"class":237},[127,465,466],{"class":214},"    print",[127,468,196],{"class":151},[127,470,471],{"class":147},"f",[127,473,474],{"class":365},"\"rz(",[127,476,477],{"class":223},"{",[127,479,480],{"class":151},"name",[127,482,483],{"class":147},":>5",[127,485,486],{"class":223},"}",[127,488,489],{"class":365},") -> ",[127,491,477],{"class":223},[127,493,494],{"class":192},"zeros",[127,496,497],{"class":151},"(theta)",[127,499,486],{"class":223},[127,501,502],{"class":365}," zeros out of 1000\"",[127,504,231],{"class":151},[506,507,509,524,534,541,551],"ol",{"class":508},"qg-cues",[510,511,512,514],"li",{"data-cue":28},[127,513,28],{"class":237},[127,515,517,518,520,521,523],{"class":516},"qg-cues__text","One Hadamard. The qubit now has two routes open, the ",[22,519,24],{}," route and the ",[22,522,28],{}," route, and measuring here gives roughly 500 of each.",[510,525,526,528],{"data-cue":252},[127,527,252],{"class":237},[127,529,530,531,533],{"class":516},"Turn a phase on the ",[22,532,28],{}," route. This moves no probability whatsoever: measure straight after this line and the tally is still about 500 each, whatever angle you passed in.",[510,535,536,538],{"data-cue":269},[127,537,269],{"class":237},[127,539,540],{"class":516},"A second Hadamard. Both routes now lead to both answers, so each answer is arrived at twice over, and the two arrivals add or cancel according to the angle above.",[510,542,543,545],{"data-cue":348},[127,544,348],{"class":237},[127,546,547,548,550],{"class":516},"How many of the thousand shots read ",[22,549,24],{},".",[510,552,553,555],{"data-cue":460},[127,554,460],{"class":237},[127,556,557],{"class":516},"Five runs at five angles. The tally walks from 1000 down to 0 and the only thing changing is a phase.",[559,560,561,578],"table",{},[562,563,564],"thead",{},[565,566,567,573],"tr",{},[568,569,570,572],"th",{},[22,571,109],{}," angle",[568,574,575,576],{},"shots reading ",[22,577,24],{},[579,580,581,588,596,604,612],"tbody",{},[565,582,583,586],{},[584,585,24],"td",{},[584,587,330],{},[565,589,590,593],{},[584,591,592],{},"π\u002F4",[584,594,595],{},"~854",[565,597,598,601],{},[584,599,600],{},"π\u002F2",[584,602,603],{},"~500",[565,605,606,609],{},[584,607,608],{},"3π\u002F4",[584,610,611],{},"~146",[565,613,614,617],{},[584,615,616],{},"π",[584,618,24],{},[12,620,621,622,624,625,550],{},"The exact figure is cos²(θ\u002F2) out of a thousand. Read the top and bottom rows together: same three gates, same measurement, and one is a certainty of ",[22,623,24],{}," while the other is a certainty of ",[22,626,28],{},[12,628,629,632],{},[22,630,631],{},"random.randint(0, 1)"," gives you the middle row and nothing else. No parameter on it turns 500 into 1000, because a probability has no sign to flip.",[12,634,635,636,638,639,550],{},"Line three is the screen. The qubit reaches ",[22,637,24],{}," along both routes, the two amplitudes are added there, and θ decides whether they reinforce or cancel. At θ = π they cancel exactly, and all thousand shots land on ",[22,640,28],{},[12,642,643],{},"Every algorithm below is that arrangement at more qubits. One gate writes signs that no measurement can see, and a later gate turns those signs into where the shots land.",[34,645,647],{"id":646},"the-gates-in-these-circuits","The gates in these circuits",[12,649,650],{},"Five gates cover every excerpt on this page.",[652,653,655,666],"gate",{"token":243,"name":654},"Hadamard",[12,656,657,658,660,661,25,663,665],{},"Takes a qubit sitting at ",[22,659,24],{}," and leaves it with no fixed value: measure it and you get ",[22,662,24],{},[22,664,28],{}," with equal probability.",[12,667,668],{},"The Hadamard is also its own undo, so it bookends every circuit here. One opens the routes and a second closes them, and whatever happened in between decides where the shots land.",[652,670,671,680],{"token":109},[12,672,673,674,676,677,679],{},"A phase rotation. The angle comes before the qubit, and it shifts the ",[22,675,28],{}," half of the state out of step with the ",[22,678,24],{}," half by that much. At π that comes out as a flipped sign, and smaller angles land part of the way there.",[12,681,682,683,685,686,688],{},"An ",[22,684,109],{}," changes no probability at all on its own. The counts are identical whether the angle is ",[22,687,24],{}," or π, and the difference only surfaces once another gate brings the two halves back onto each other.",[652,690,693,702],{"token":691,"name":692},"cz","Controlled-Z",[12,694,695,696,698,699,701],{},"Flips the sign of one outcome, the one where both qubits read ",[22,697,28],{},", and leaves the other three alone. Like ",[22,700,109],{}," it moves no probability by itself.",[12,703,704,705,707,708,711,712,714,715,717,718,550],{},"For more than two qubits the same job is written as ",[22,706,243],{},", a multi-controlled ",[22,709,710],{},"x",", then ",[22,713,243],{}," again on the last qubit. Both Grover circuits below spell it out that way, and Qiskit calls the three-qubit version of that ",[22,716,710],{}," a ",[22,719,720],{},"ccx",[652,722,723,732],{"token":710},[12,724,725,726,728,729,731],{},"Swaps ",[22,727,24],{}," and ",[22,730,28],{}," on a single qubit, the ordinary NOT.",[12,733,734,735,728,737,739,740,742,743,745],{},"On ",[22,736,24],{},[22,738,28],{}," it does exactly what a classical NOT does. Its use here is aiming: wrap a ",[22,741,691],{}," in ",[22,744,710],{}," gates and you choose which outcome gets the sign flip.",[652,747,748,756],{"token":292},[12,749,750,751,25,753,755],{},"Reads a qubit into an ordinary bit and forces it to a definite ",[22,752,24],{},[22,754,28],{},". It is the one irreversible step, and it reports probabilities only.",[12,757,758],{},"A sign is never in the output, so every circuit here has to turn its signs into probabilities before this line.",[34,760,762],{"id":761},"a-mark-that-changes-none-of-the-odds","A mark that changes none of the odds",[12,764,765],{},"Qollab ships a runnable Grover's search. Three qubits give eight possible answers, one of them is the one you want, and a Hadamard on each qubit starts all eight at 12.5%.",[12,767,768],{},"The first half of the algorithm is an oracle whose only job is to mark the right answer.",[112,770,772],{"name":771,"tag":115,"run-href":116},"grovers_search.py",[118,773,775],{"className":120,"code":774,"language":122,"meta":123,"style":123},"target = \"101\"\n\n# ── Oracle: phase-flip the target state ──────────────────────────────\ndef build_oracle(target):\n    n = len(target)\n    oracle = QuantumCircuit(n, name=\"Oracle\")\n    for i, bit in enumerate(reversed(target)):\n        if bit == \"0\":\n            oracle.x(i)\n    if n == 2:\n        oracle.cz(0, 1)\n    elif n == 3:\n        oracle.h(2)\n        oracle.ccx(0, 1, 2)\n        oracle.h(2)\n    else:\n        oracle.h(n - 1)\n        oracle.mcx(list(range(n - 1)), n - 1)\n        oracle.h(n - 1)\n    for i, bit in enumerate(reversed(target)):\n        if bit == \"0\":\n            oracle.x(i)\n    return oracle\n",[22,776,777,789,795,802,818,833,856,879,898,910,926,945,961,975,997,1011,1021,1041,1076,1093,1112,1127,1138,1148],{"__ignoreMap":123},[127,778,779,781,784,786],{"class":129,"line":130},[127,780,135],{"class":133,"aria-hidden":134},[127,782,783],{"class":151},"target ",[127,785,215],{"class":214},[127,787,788],{"class":365}," \"101\"\n",[127,790,791,793],{"class":129,"line":142},[127,792,135],{"class":133,"aria-hidden":134},[127,794,181],{},[127,796,797,799],{"class":129,"line":161},[127,798,135],{"class":133,"aria-hidden":134},[127,800,801],{"class":138},"# ── Oracle: phase-flip the target state ──────────────────────────────\n",[127,803,804,806,808,811,813,816],{"class":129,"line":176},[127,805,135],{"class":133,"aria-hidden":134},[127,807,189],{"class":147},[127,809,810],{"class":192}," build_oracle",[127,812,196],{"class":151},[127,814,815],{"class":199},"target",[127,817,203],{"class":151},[127,819,820,822,825,827,830],{"class":129,"line":184},[127,821,135],{"class":133,"aria-hidden":134},[127,823,824],{"class":151},"    n ",[127,826,215],{"class":214},[127,828,829],{"class":214}," len",[127,831,832],{"class":151},"(target)\n",[127,834,835,837,840,842,844,847,849,851,854],{"class":129,"line":206},[127,836,135],{"class":133,"aria-hidden":134},[127,838,839],{"class":151},"    oracle ",[127,841,215],{"class":214},[127,843,218],{"class":192},[127,845,846],{"class":151},"(n, ",[127,848,480],{"class":324},[127,850,215],{"class":214},[127,852,853],{"class":365},"\"Oracle\"",[127,855,231],{"class":151},[127,857,858,860,863,866,868,871,873,876],{"class":129,"line":234},[127,859,135],{"class":133,"aria-hidden":134},[127,861,862],{"class":147},"    for",[127,864,865],{"class":151}," i, bit ",[127,867,393],{"class":147},[127,869,870],{"class":214}," enumerate",[127,872,196],{"class":151},[127,874,875],{"class":214},"reversed",[127,877,878],{"class":151},"(target)):\n",[127,880,881,883,886,889,892,895],{"class":129,"line":253},[127,882,135],{"class":133,"aria-hidden":134},[127,884,885],{"class":147},"        if",[127,887,888],{"class":151}," bit ",[127,890,891],{"class":214},"==",[127,893,894],{"class":365}," \"0\"",[127,896,897],{"class":151},":\n",[127,899,900,902,905,907],{"class":129,"data-cue":28,"line":270},[127,901,28],{"class":237},[127,903,904],{"class":151},"            oracle.",[127,906,710],{"class":192},[127,908,909],{"class":151},"(i)\n",[127,911,912,914,917,920,922,924],{"class":129,"line":285},[127,913,135],{"class":133,"aria-hidden":134},[127,915,916],{"class":147},"    if",[127,918,919],{"class":151}," n ",[127,921,891],{"class":214},[127,923,430],{"class":223},[127,925,897],{"class":151},[127,927,928,930,933,935,937,939,941,943],{"class":129,"line":305},[127,929,135],{"class":133,"aria-hidden":134},[127,931,932],{"class":151},"        oracle.",[127,934,691],{"class":192},[127,936,196],{"class":151},[127,938,24],{"class":223},[127,940,226],{"class":151},[127,942,28],{"class":223},[127,944,231],{"class":151},[127,946,947,949,952,954,956,959],{"class":129,"line":349},[127,948,135],{"class":133,"aria-hidden":134},[127,950,951],{"class":147},"    elif",[127,953,919],{"class":151},[127,955,891],{"class":214},[127,957,958],{"class":223}," 3",[127,960,897],{"class":151},[127,962,963,965,967,969,971,973],{"class":129,"line":375},[127,964,135],{"class":133,"aria-hidden":134},[127,966,932],{"class":151},[127,968,243],{"class":192},[127,970,196],{"class":151},[127,972,252],{"class":223},[127,974,231],{"class":151},[127,976,977,979,981,983,985,987,989,991,993,995],{"class":129,"data-cue":252,"line":382},[127,978,252],{"class":237},[127,980,932],{"class":151},[127,982,720],{"class":192},[127,984,196],{"class":151},[127,986,24],{"class":223},[127,988,226],{"class":151},[127,990,28],{"class":223},[127,992,226],{"class":151},[127,994,252],{"class":223},[127,996,231],{"class":151},[127,998,999,1001,1003,1005,1007,1009],{"class":129,"line":461},[127,1000,135],{"class":133,"aria-hidden":134},[127,1002,932],{"class":151},[127,1004,243],{"class":192},[127,1006,196],{"class":151},[127,1008,252],{"class":223},[127,1010,231],{"class":151},[127,1012,1014,1016,1019],{"class":129,"line":1013},16,[127,1015,135],{"class":133,"aria-hidden":134},[127,1017,1018],{"class":147},"    else",[127,1020,897],{"class":151},[127,1022,1024,1026,1028,1030,1033,1036,1039],{"class":129,"line":1023},17,[127,1025,135],{"class":133,"aria-hidden":134},[127,1027,932],{"class":151},[127,1029,243],{"class":192},[127,1031,1032],{"class":151},"(n ",[127,1034,1035],{"class":214},"-",[127,1037,1038],{"class":223}," 1",[127,1040,231],{"class":151},[127,1042,1044,1046,1048,1051,1053,1056,1058,1061,1063,1065,1067,1070,1072,1074],{"class":129,"line":1043},18,[127,1045,135],{"class":133,"aria-hidden":134},[127,1047,932],{"class":151},[127,1049,1050],{"class":192},"mcx",[127,1052,196],{"class":151},[127,1054,1055],{"class":214},"list",[127,1057,196],{"class":151},[127,1059,1060],{"class":214},"range",[127,1062,1032],{"class":151},[127,1064,1035],{"class":214},[127,1066,1038],{"class":223},[127,1068,1069],{"class":151},")), n ",[127,1071,1035],{"class":214},[127,1073,1038],{"class":223},[127,1075,231],{"class":151},[127,1077,1079,1081,1083,1085,1087,1089,1091],{"class":129,"line":1078},19,[127,1080,135],{"class":133,"aria-hidden":134},[127,1082,932],{"class":151},[127,1084,243],{"class":192},[127,1086,1032],{"class":151},[127,1088,1035],{"class":214},[127,1090,1038],{"class":223},[127,1092,231],{"class":151},[127,1094,1096,1098,1100,1102,1104,1106,1108,1110],{"class":129,"line":1095},20,[127,1097,135],{"class":133,"aria-hidden":134},[127,1099,862],{"class":147},[127,1101,865],{"class":151},[127,1103,393],{"class":147},[127,1105,870],{"class":214},[127,1107,196],{"class":151},[127,1109,875],{"class":214},[127,1111,878],{"class":151},[127,1113,1115,1117,1119,1121,1123,1125],{"class":129,"line":1114},21,[127,1116,135],{"class":133,"aria-hidden":134},[127,1118,885],{"class":147},[127,1120,888],{"class":151},[127,1122,891],{"class":214},[127,1124,894],{"class":365},[127,1126,897],{"class":151},[127,1128,1130,1132,1134,1136],{"class":129,"data-cue":269,"line":1129},22,[127,1131,269],{"class":237},[127,1133,904],{"class":151},[127,1135,710],{"class":192},[127,1137,909],{"class":151},[127,1139,1141,1143,1145],{"class":129,"line":1140},23,[127,1142,135],{"class":133,"aria-hidden":134},[127,1144,354],{"class":147},[127,1146,1147],{"class":151}," oracle\n",[506,1149,1150,1167,1184],{"class":508},[510,1151,1152,1154],{"data-cue":28},[127,1153,28],{"class":237},[127,1155,1156,1157,1160,1161,1163,1164,550],{"class":516},"Aim the gate below. ",[22,1158,1159],{},"101"," has a ",[22,1162,24],{}," in the middle, so the middle qubit gets flipped and the answer being marked temporarily becomes ",[22,1165,1166],{},"111",[510,1168,1169,1171],{"data-cue":252},[127,1170,252],{"class":237},[127,1172,1173,1174,226,1176,226,1178,1180,1181,1183],{"class":516},"The mark itself, written as ",[22,1175,243],{},[22,1177,720],{},[22,1179,243],{},", which together flip the sign of the one outcome where all three qubits read ",[22,1182,28],{},". One of eight amplitudes becomes negative and the other seven are untouched.",[510,1185,1186,1188],{"data-cue":269},[127,1187,269],{"class":237},[127,1189,1190,1191,1193],{"class":516},"Undo the aiming flips, so the sign now sits on ",[22,1192,1159],{}," where it was wanted.",[12,1195,1196],{},"Nothing in that function moves any probability. Run it on the eight-way superposition and all eight outcomes still sit at 12.5%, exactly as they did before the call.",[12,1198,1199,1200,1202],{},"The answer has been marked in the one way a measurement cannot report, which is the same problem the ",[22,1201,109],{}," had at the top of this page.",[34,1204,1206],{"id":1205},"turning-the-mark-into-probability","Turning the mark into probability",[12,1208,1209,1210,1212,1213,1215],{},"The second half is called the diffuser, and it is the same ",[22,1211,243],{},", phase, ",[22,1214,243],{}," arrangement at three qubits.",[112,1217,1218],{"name":771,"tag":115,"run-href":116},[118,1219,1221],{"className":120,"code":1220,"language":122,"meta":123,"style":123},"# ── Diffuser: amplify the marked state ───────────────────────────────\ndef build_diffuser(n):\n    diffuser = QuantumCircuit(n, name=\"Diffuser\")\n    diffuser.h(range(n))\n    diffuser.x(range(n))\n    if n == 2:\n        diffuser.cz(0, 1)\n    elif n == 3:\n        diffuser.h(2)\n        diffuser.ccx(0, 1, 2)\n        diffuser.h(2)\n    else:\n        diffuser.h(n - 1)\n        diffuser.mcx(list(range(n - 1)), n - 1)\n        diffuser.h(n - 1)\n    diffuser.x(range(n))\n    diffuser.h(range(n))\n    return diffuser\n",[22,1222,1223,1230,1246,1268,1284,1298,1312,1331,1345,1359,1381,1395,1403,1419,1449,1465,1479,1493,1502],{"__ignoreMap":123},[127,1224,1225,1227],{"class":129,"line":130},[127,1226,135],{"class":133,"aria-hidden":134},[127,1228,1229],{"class":138},"# ── Diffuser: amplify the marked state ───────────────────────────────\n",[127,1231,1232,1234,1236,1239,1241,1244],{"class":129,"line":142},[127,1233,135],{"class":133,"aria-hidden":134},[127,1235,189],{"class":147},[127,1237,1238],{"class":192}," build_diffuser",[127,1240,196],{"class":151},[127,1242,1243],{"class":199},"n",[127,1245,203],{"class":151},[127,1247,1248,1250,1253,1255,1257,1259,1261,1263,1266],{"class":129,"line":161},[127,1249,135],{"class":133,"aria-hidden":134},[127,1251,1252],{"class":151},"    diffuser ",[127,1254,215],{"class":214},[127,1256,218],{"class":192},[127,1258,846],{"class":151},[127,1260,480],{"class":324},[127,1262,215],{"class":214},[127,1264,1265],{"class":365},"\"Diffuser\"",[127,1267,231],{"class":151},[127,1269,1270,1272,1275,1277,1279,1281],{"class":129,"data-cue":28,"line":176},[127,1271,28],{"class":237},[127,1273,1274],{"class":151},"    diffuser.",[127,1276,243],{"class":192},[127,1278,196],{"class":151},[127,1280,1060],{"class":214},[127,1282,1283],{"class":151},"(n))\n",[127,1285,1286,1288,1290,1292,1294,1296],{"class":129,"line":184},[127,1287,135],{"class":133,"aria-hidden":134},[127,1289,1274],{"class":151},[127,1291,710],{"class":192},[127,1293,196],{"class":151},[127,1295,1060],{"class":214},[127,1297,1283],{"class":151},[127,1299,1300,1302,1304,1306,1308,1310],{"class":129,"line":206},[127,1301,135],{"class":133,"aria-hidden":134},[127,1303,916],{"class":147},[127,1305,919],{"class":151},[127,1307,891],{"class":214},[127,1309,430],{"class":223},[127,1311,897],{"class":151},[127,1313,1314,1316,1319,1321,1323,1325,1327,1329],{"class":129,"line":234},[127,1315,135],{"class":133,"aria-hidden":134},[127,1317,1318],{"class":151},"        diffuser.",[127,1320,691],{"class":192},[127,1322,196],{"class":151},[127,1324,24],{"class":223},[127,1326,226],{"class":151},[127,1328,28],{"class":223},[127,1330,231],{"class":151},[127,1332,1333,1335,1337,1339,1341,1343],{"class":129,"line":253},[127,1334,135],{"class":133,"aria-hidden":134},[127,1336,951],{"class":147},[127,1338,919],{"class":151},[127,1340,891],{"class":214},[127,1342,958],{"class":223},[127,1344,897],{"class":151},[127,1346,1347,1349,1351,1353,1355,1357],{"class":129,"line":270},[127,1348,135],{"class":133,"aria-hidden":134},[127,1350,1318],{"class":151},[127,1352,243],{"class":192},[127,1354,196],{"class":151},[127,1356,252],{"class":223},[127,1358,231],{"class":151},[127,1360,1361,1363,1365,1367,1369,1371,1373,1375,1377,1379],{"class":129,"data-cue":252,"line":285},[127,1362,252],{"class":237},[127,1364,1318],{"class":151},[127,1366,720],{"class":192},[127,1368,196],{"class":151},[127,1370,24],{"class":223},[127,1372,226],{"class":151},[127,1374,28],{"class":223},[127,1376,226],{"class":151},[127,1378,252],{"class":223},[127,1380,231],{"class":151},[127,1382,1383,1385,1387,1389,1391,1393],{"class":129,"line":305},[127,1384,135],{"class":133,"aria-hidden":134},[127,1386,1318],{"class":151},[127,1388,243],{"class":192},[127,1390,196],{"class":151},[127,1392,252],{"class":223},[127,1394,231],{"class":151},[127,1396,1397,1399,1401],{"class":129,"line":349},[127,1398,135],{"class":133,"aria-hidden":134},[127,1400,1018],{"class":147},[127,1402,897],{"class":151},[127,1404,1405,1407,1409,1411,1413,1415,1417],{"class":129,"line":375},[127,1406,135],{"class":133,"aria-hidden":134},[127,1408,1318],{"class":151},[127,1410,243],{"class":192},[127,1412,1032],{"class":151},[127,1414,1035],{"class":214},[127,1416,1038],{"class":223},[127,1418,231],{"class":151},[127,1420,1421,1423,1425,1427,1429,1431,1433,1435,1437,1439,1441,1443,1445,1447],{"class":129,"line":382},[127,1422,135],{"class":133,"aria-hidden":134},[127,1424,1318],{"class":151},[127,1426,1050],{"class":192},[127,1428,196],{"class":151},[127,1430,1055],{"class":214},[127,1432,196],{"class":151},[127,1434,1060],{"class":214},[127,1436,1032],{"class":151},[127,1438,1035],{"class":214},[127,1440,1038],{"class":223},[127,1442,1069],{"class":151},[127,1444,1035],{"class":214},[127,1446,1038],{"class":223},[127,1448,231],{"class":151},[127,1450,1451,1453,1455,1457,1459,1461,1463],{"class":129,"line":461},[127,1452,135],{"class":133,"aria-hidden":134},[127,1454,1318],{"class":151},[127,1456,243],{"class":192},[127,1458,1032],{"class":151},[127,1460,1035],{"class":214},[127,1462,1038],{"class":223},[127,1464,231],{"class":151},[127,1466,1467,1469,1471,1473,1475,1477],{"class":129,"line":1013},[127,1468,135],{"class":133,"aria-hidden":134},[127,1470,1274],{"class":151},[127,1472,710],{"class":192},[127,1474,196],{"class":151},[127,1476,1060],{"class":214},[127,1478,1283],{"class":151},[127,1480,1481,1483,1485,1487,1489,1491],{"class":129,"data-cue":269,"line":1023},[127,1482,269],{"class":237},[127,1484,1274],{"class":151},[127,1486,243],{"class":192},[127,1488,196],{"class":151},[127,1490,1060],{"class":214},[127,1492,1283],{"class":151},[127,1494,1495,1497,1499],{"class":129,"line":1043},[127,1496,135],{"class":133,"aria-hidden":134},[127,1498,354],{"class":147},[127,1500,1501],{"class":151}," diffuser\n",[506,1503,1504,1511,1521],{"class":508},[510,1505,1506,1508],{"data-cue":28},[127,1507,28],{"class":237},[127,1509,1510],{"class":516},"Open the routes onto each other, the same move as the second Hadamard in the one-qubit listing, run on all three qubits at once.",[510,1512,1513,1515],{"data-cue":252},[127,1514,252],{"class":237},[127,1516,1517,1518,1520],{"class":516},"The same sign flip as the oracle, aimed by the ",[22,1519,710],{}," layer at the all-zeros outcome this time. The diffuser is the same for every target; only the oracle knows which one.",[510,1522,1523,1525],{"data-cue":269},[127,1524,269],{"class":237},[127,1526,1527],{"class":516},"The closing Hadamard layer. Every amplitude is now the same distance from the average as it was, on the other side of it, so the one the oracle pushed below the average comes back furthest above it.",[12,1529,1530],{},"The standard name for those seven lines is inversion about the mean. Seven amplitudes are positive and one is negative, so the average sits just under the positive ones. Reflecting each amplitude through that average sends the negative one far up and barely moves the other seven.",[12,1532,1533,1534,1536],{},"Run the oracle and the diffuser as a pair and the chance of measuring ",[22,1535,1159],{}," moves like this.",[559,1538,1539,1551],{},[562,1540,1541],{},[565,1542,1543,1546],{},[568,1544,1545],{},"Grover iterations",[568,1547,1548,1549],{},"chance of reading ",[22,1550,1159],{},[579,1552,1553,1560,1567,1574],{},[565,1554,1555,1557],{},[584,1556,24],{},[584,1558,1559],{},"12.5%",[565,1561,1562,1564],{},[584,1563,28],{},[584,1565,1566],{},"78.1%",[565,1568,1569,1571],{},[584,1570,252],{},[584,1572,1573],{},"94.5%",[565,1575,1576,1578],{},[584,1577,269],{},[584,1579,1580],{},"33.0%",[12,1582,1583],{},"Two iterations take a one-in-eight guess to a 94.5% hit rate, and the only mechanism in play is amplitudes adding and subtracting. The oracle was consulted twice. Checking all eight items by hand takes eight looks, and a classical scan finds it after 4.5 on average.",[1585,1586,1588],"h3",{"id":1587},"too-many-iterations-undo-the-answer","Too many iterations undo the answer",[12,1590,1591],{},"After three iterations the target is back down to 33.0%. The project computes how many iterations to run instead of guessing.",[112,1593,1594],{"name":771,"tag":115,"run-href":116},[118,1595,1597],{"className":120,"code":1596,"language":122,"meta":123,"style":123},"target = \"101\"\nshots = 1000\nnum_qubits = len(target)\nnum_iterations = int(math.pi \u002F 4 * math.sqrt(2 ** num_qubits))\n",[22,1598,1599,1609,1621,1634,1671],{"__ignoreMap":123},[127,1600,1601,1603,1605,1607],{"class":129,"line":130},[127,1602,135],{"class":133,"aria-hidden":134},[127,1604,783],{"class":151},[127,1606,215],{"class":214},[127,1608,788],{"class":365},[127,1610,1611,1613,1616,1618],{"class":129,"line":142},[127,1612,135],{"class":133,"aria-hidden":134},[127,1614,1615],{"class":151},"shots ",[127,1617,215],{"class":214},[127,1619,1620],{"class":223}," 1000\n",[127,1622,1623,1625,1628,1630,1632],{"class":129,"line":161},[127,1624,135],{"class":133,"aria-hidden":134},[127,1626,1627],{"class":151},"num_qubits ",[127,1629,215],{"class":214},[127,1631,829],{"class":214},[127,1633,832],{"class":151},[127,1635,1636,1638,1641,1643,1646,1649,1651,1653,1655,1658,1661,1663,1665,1668],{"class":129,"data-cue":28,"line":176},[127,1637,28],{"class":237},[127,1639,1640],{"class":151},"num_iterations ",[127,1642,215],{"class":214},[127,1644,1645],{"class":214}," int",[127,1647,1648],{"class":151},"(math.pi ",[127,1650,415],{"class":214},[127,1652,418],{"class":223},[127,1654,442],{"class":214},[127,1656,1657],{"class":151}," math.",[127,1659,1660],{"class":192},"sqrt",[127,1662,196],{"class":151},[127,1664,252],{"class":223},[127,1666,1667],{"class":214}," **",[127,1669,1670],{"class":151}," num_qubits))\n",[506,1672,1673],{"class":508},[510,1674,1675,1677],{"data-cue":28},[127,1676,28],{"class":237},[127,1678,1679,1680,1683],{"class":516},"For three qubits this works out at 2.221, and ",[22,1681,1682],{},"int"," takes it down to 2. The formula is π\u002F4 times the square root of the search space, which is where Grover's quadratic speedup comes from.",[12,1685,1686],{},"Each iteration turns the state by a fixed angle toward the marked answer, and the turning does not stop on arrival. Go past the top and the same interference that concentrated the probability starts spreading it again.",[12,1688,1689,1693,1694,1697,1698,1700],{},[1690,1691,1692],"strong",{},"Try this when you fork it."," Replace ",[22,1695,1696],{},"num_iterations"," with ",[22,1699,269],{}," and run. The target falls from 94.5% to about a third, and a fourth iteration takes it to roughly 1%, worse than the 12.5% you started with. Grover's search is a rotation with a stopping point that has to be calculated in advance.",[1702,1703],"project-card",{"description":1704,"framework":1705,"owner":1706,"title":1707,"to":116},"Implements Grover's search algorithm on IonQ's trapped-ion simulator to find a marked item in an unsorted database. A 3-qubit example searches 8 items and finds the target with roughly 95% probability.","Python + Qiskit","qollab","Grover's Search",[34,1709,1711],{"id":1710},"the-walk-that-does-not-spread-like-a-random-one","The walk that does not spread like a random one",[12,1713,1714],{},"Grover concentrates probability on one answer. Quantum Advantage Lab's third race shows the same mechanism shaping a whole distribution, and its classical counterpart sits in the same repository.",[1716,1717],"blog-figure",{"alt":1718,"caption":1719,"no":123,"poster":1720,"video":1721},"Quantum Advantage Lab streaming a quantum algorithm beside its classical counterpart, step by step","A race streamed step by step, the quantum solver beside its classical baseline. Press play.","\u002F_content\u002Fimages\u002Fquantum-advantage-lab\u002Fhero.webp","https:\u002F\u002Fapi.cms.qollab.xyz\u002Fassets\u002Ff0f3f459-1f14-4785-aecc-7efda823d45c",[12,1723,1724],{},"A classical random walker starts at node 0 and picks a neighbour at each step. The Lab runs a thousand of them.",[112,1726,1729],{"name":1727,"tag":1728},"backend\u002Fclassical\u002Frandom_walk.py","Python · from the Quantum Advantage Lab repository",[118,1730,1732],{"className":120,"code":1731,"language":122,"meta":123,"style":123},"        # For each walker, pick next position based on transition probabilities\n        new_positions = np.empty(n_trials, dtype=int)\n        for trial_idx in range(n_trials):\n            current = positions[trial_idx]\n            new_positions[trial_idx] = rng.choice(\n                n_nodes, p=transition[current]\n            )\n        positions = new_positions\n\n        # Build empirical distribution\n        counts = np.bincount(positions, minlength=n_nodes)\n        distribution = (counts \u002F n_trials).tolist()\n",[22,1733,1734,1741,1767,1785,1797,1815,1829,1836,1848,1854,1861,1886,1908],{"__ignoreMap":123},[127,1735,1736,1738],{"class":129,"line":130},[127,1737,135],{"class":133,"aria-hidden":134},[127,1739,1740],{"class":138},"        # For each walker, pick next position based on transition probabilities\n",[127,1742,1743,1745,1748,1750,1753,1756,1759,1762,1765],{"class":129,"line":142},[127,1744,135],{"class":133,"aria-hidden":134},[127,1746,1747],{"class":151},"        new_positions ",[127,1749,215],{"class":214},[127,1751,1752],{"class":151}," np.",[127,1754,1755],{"class":192},"empty",[127,1757,1758],{"class":151},"(n_trials, ",[127,1760,1761],{"class":324},"dtype",[127,1763,1764],{"class":214},"=int",[127,1766,231],{"class":151},[127,1768,1769,1771,1774,1777,1779,1782],{"class":129,"line":161},[127,1770,135],{"class":133,"aria-hidden":134},[127,1772,1773],{"class":147},"        for",[127,1775,1776],{"class":151}," trial_idx ",[127,1778,393],{"class":147},[127,1780,1781],{"class":214}," range",[127,1783,1784],{"class":151},"(n_trials):\n",[127,1786,1787,1789,1792,1794],{"class":129,"line":176},[127,1788,135],{"class":133,"aria-hidden":134},[127,1790,1791],{"class":151},"            current ",[127,1793,215],{"class":214},[127,1795,1796],{"class":151}," positions[trial_idx]\n",[127,1798,1799,1801,1804,1806,1809,1812],{"class":129,"line":184},[127,1800,135],{"class":133,"aria-hidden":134},[127,1802,1803],{"class":151},"            new_positions[trial_idx] ",[127,1805,215],{"class":214},[127,1807,1808],{"class":151}," rng.",[127,1810,1811],{"class":192},"choice",[127,1813,1814],{"class":151},"(\n",[127,1816,1817,1819,1822,1824,1826],{"class":129,"line":206},[127,1818,135],{"class":133,"aria-hidden":134},[127,1820,1821],{"class":151},"                n_nodes, ",[127,1823,12],{"class":324},[127,1825,215],{"class":214},[127,1827,1828],{"class":151},"transition[current]\n",[127,1830,1831,1833],{"class":129,"data-cue":28,"line":234},[127,1832,28],{"class":237},[127,1834,1835],{"class":151},"            )\n",[127,1837,1838,1840,1843,1845],{"class":129,"line":253},[127,1839,135],{"class":133,"aria-hidden":134},[127,1841,1842],{"class":151},"        positions ",[127,1844,215],{"class":214},[127,1846,1847],{"class":151}," new_positions\n",[127,1849,1850,1852],{"class":129,"line":270},[127,1851,135],{"class":133,"aria-hidden":134},[127,1853,181],{},[127,1855,1856,1858],{"class":129,"line":285},[127,1857,135],{"class":133,"aria-hidden":134},[127,1859,1860],{"class":138},"        # Build empirical distribution\n",[127,1862,1863,1865,1868,1870,1872,1875,1878,1881,1883],{"class":129,"line":305},[127,1864,135],{"class":133,"aria-hidden":134},[127,1866,1867],{"class":151},"        counts ",[127,1869,215],{"class":214},[127,1871,1752],{"class":151},[127,1873,1874],{"class":192},"bincount",[127,1876,1877],{"class":151},"(positions, ",[127,1879,1880],{"class":324},"minlength",[127,1882,215],{"class":214},[127,1884,1885],{"class":151},"n_nodes)\n",[127,1887,1888,1890,1893,1895,1898,1900,1903,1906],{"class":129,"data-cue":252,"line":349},[127,1889,252],{"class":237},[127,1891,1892],{"class":151},"        distribution ",[127,1894,215],{"class":214},[127,1896,1897],{"class":151}," (counts ",[127,1899,415],{"class":214},[127,1901,1902],{"class":151}," n_trials).",[127,1904,1905],{"class":192},"tolist",[127,1907,345],{"class":151},[506,1909,1910,1917],{"class":508},[510,1911,1912,1914],{"data-cue":28},[127,1913,28],{"class":237},[127,1915,1916],{"class":516},"A fresh random draw for every walker on every step. A thousand walkers, six steps, six thousand draws, and each one is committed the moment it happens.",[510,1918,1919,1921],{"data-cue":252},[127,1920,252],{"class":237},[127,1922,1923],{"class":516},"Tally where the thousand walkers ended up. This comes out as a bell curve centred on the start, widening as the square root of the number of steps.",[12,1925,1926],{},"The quantum walk draws no random number at any step. It turns a coin qubit and shifts the walker by what the coin says, both as ordinary gates, and nothing is sampled until the finished circuit is measured.",[112,1928,1930],{"name":1929,"tag":1728},"backend\u002Fquantum\u002Fquantum_walks.py",[118,1931,1933],{"className":120,"code":1932,"language":122,"meta":123,"style":123},"    # Initial state: walker at position 0, coin in superposition\n    if graph_type == \"cycle\":\n        qc.h(coin_qubits[0])\n    # ...\n    for step in range(n_steps):\n        # Coin\n        if graph_type == \"cycle\":\n            _hadamard_coin(qc, coin_qubits[0])\n        # ...\n        # Shift\n        if graph_type == \"cycle\":\n            _cycle_shift(qc, coin_qubits[0], position_qubits)\n",[22,1934,1935,1942,1958,1975,1982,1998,2005,2019,2033,2040,2047,2061,2075],{"__ignoreMap":123},[127,1936,1937,1939],{"class":129,"line":130},[127,1938,135],{"class":133,"aria-hidden":134},[127,1940,1941],{"class":138},"    # Initial state: walker at position 0, coin in superposition\n",[127,1943,1944,1946,1948,1951,1953,1956],{"class":129,"line":142},[127,1945,135],{"class":133,"aria-hidden":134},[127,1947,916],{"class":147},[127,1949,1950],{"class":151}," graph_type ",[127,1952,891],{"class":214},[127,1954,1955],{"class":365}," \"cycle\"",[127,1957,897],{"class":151},[127,1959,1960,1962,1965,1967,1970,1972],{"class":129,"data-cue":28,"line":161},[127,1961,28],{"class":237},[127,1963,1964],{"class":151},"        qc.",[127,1966,243],{"class":192},[127,1968,1969],{"class":151},"(coin_qubits[",[127,1971,24],{"class":223},[127,1973,1974],{"class":151},"])\n",[127,1976,1977,1979],{"class":129,"line":176},[127,1978,135],{"class":133,"aria-hidden":134},[127,1980,1981],{"class":138},"    # ...\n",[127,1983,1984,1986,1988,1991,1993,1995],{"class":129,"line":184},[127,1985,135],{"class":133,"aria-hidden":134},[127,1987,862],{"class":147},[127,1989,1990],{"class":151}," step ",[127,1992,393],{"class":147},[127,1994,1781],{"class":214},[127,1996,1997],{"class":151},"(n_steps):\n",[127,1999,2000,2002],{"class":129,"line":206},[127,2001,135],{"class":133,"aria-hidden":134},[127,2003,2004],{"class":138},"        # Coin\n",[127,2006,2007,2009,2011,2013,2015,2017],{"class":129,"line":234},[127,2008,135],{"class":133,"aria-hidden":134},[127,2010,885],{"class":147},[127,2012,1950],{"class":151},[127,2014,891],{"class":214},[127,2016,1955],{"class":365},[127,2018,897],{"class":151},[127,2020,2021,2023,2026,2029,2031],{"class":129,"data-cue":252,"line":253},[127,2022,252],{"class":237},[127,2024,2025],{"class":192},"            _hadamard_coin",[127,2027,2028],{"class":151},"(qc, coin_qubits[",[127,2030,24],{"class":223},[127,2032,1974],{"class":151},[127,2034,2035,2037],{"class":129,"line":270},[127,2036,135],{"class":133,"aria-hidden":134},[127,2038,2039],{"class":138},"        # ...\n",[127,2041,2042,2044],{"class":129,"line":285},[127,2043,135],{"class":133,"aria-hidden":134},[127,2045,2046],{"class":138},"        # Shift\n",[127,2048,2049,2051,2053,2055,2057,2059],{"class":129,"line":305},[127,2050,135],{"class":133,"aria-hidden":134},[127,2052,885],{"class":147},[127,2054,1950],{"class":151},[127,2056,891],{"class":214},[127,2058,1955],{"class":365},[127,2060,897],{"class":151},[127,2062,2063,2065,2068,2070,2072],{"class":129,"data-cue":269,"line":349},[127,2064,269],{"class":237},[127,2066,2067],{"class":192},"            _cycle_shift",[127,2069,2028],{"class":151},[127,2071,24],{"class":223},[127,2073,2074],{"class":151},"], position_qubits)\n",[506,2076,2077,2084,2091],{"class":508},[510,2078,2079,2081],{"data-cue":28},[127,2080,28],{"class":237},[127,2082,2083],{"class":516},"The coin starts with no value. Nothing in the walk below ever reads it, so it never acquires one.",[510,2085,2086,2088],{"data-cue":252},[127,2087,252],{"class":237},[127,2089,2090],{"class":516},"Turn the coin again, with another Hadamard. Nothing reads it, so the coin stays undecided and the walk keeps every branch open.",[510,2092,2093,2095],{"data-cue":269},[127,2094,269],{"class":237},[127,2096,2097],{"class":516},"Move the walker by whatever the coin says, both ways at once. The position register is a superposition over every route the walker could have taken, held open until the final measurement.",[12,2099,2100],{},"Six steps in, the classical walker has taken one of sixty-four routes and the tally counts how often each endpoint came up. The quantum walk commits to none of them, and routes that reach the same node out of step cancel before anything is counted.",[12,2102,2103],{},"What comes out is not a bell curve. Routes that reach a node in step pile up there and routes that reach it out of step cancel, so the distribution comes out lopsided and ridged rather than smooth. On a big enough ring, before the walker has gone far enough round to meet itself, it also widens in proportion to the number of steps. The classical one widens with its square root.",[1702,2105],{"description":2106,"framework":1705,"owner":2107,"title":2108,"to":2109,"builder":2110,"thumb":2111},"Real-time interactive platform that races four foundational quantum algorithms against their classical counterparts, visualizing each solver's progress step by step.","hsadeghi","Quantum Advantage Lab","\u002Fu\u002Fhsadeghi\u002Fquantum-advantage-lab","Hossein Sadeghi Esfahani","\u002F_content\u002Fimages\u002Fquantum-advantage-lab\u002Fscreenshot.webp",[34,2113,2115],{"id":2114},"running-a-circuit-backwards-to-compare-two-states","Running a circuit backwards to compare two states",[12,2117,2118],{},"Quantum Regime Radar scores a live market window against five volatility regimes taken from real history, each one stored as a twelve-qubit state. Scoring means comparing two states, and neither state can be read.",[12,2120,2121],{},"The project's answer is to build one state, then run the other's circuit in reverse and see how much comes back.",[112,2123,2127],{"name":2124,"tag":2125,"run-href":2126},"regime_radar_cell.py","Python · excerpt","\u002Fu\u002Falireza\u002Fquantum-regime-radar",[118,2128,2130],{"className":120,"code":2129,"language":122,"meta":123,"style":123},"def _inversion(qc_live: QuantumCircuit, qc_ref: QuantumCircuit) -> QuantumCircuit:\n    n = qc_live.num_qubits\n    qc = QuantumCircuit(n, n)\n    qc.compose(qc_live, inplace=True)\n    qc.compose(qc_ref.inverse(), inplace=True)\n    qc.measure(range(n), range(n))\n    return qc\n",[22,2131,2132,2155,2166,2179,2201,2226,2245,2254],{"__ignoreMap":123},[127,2133,2134,2136,2138,2141,2143,2146,2149,2152],{"class":129,"line":130},[127,2135,135],{"class":133,"aria-hidden":134},[127,2137,189],{"class":147},[127,2139,2140],{"class":192}," _inversion",[127,2142,196],{"class":151},[127,2144,2145],{"class":199},"qc_live",[127,2147,2148],{"class":151},": QuantumCircuit, ",[127,2150,2151],{"class":199},"qc_ref",[127,2153,2154],{"class":151},": QuantumCircuit) -> QuantumCircuit:\n",[127,2156,2157,2159,2161,2163],{"class":129,"line":142},[127,2158,135],{"class":133,"aria-hidden":134},[127,2160,824],{"class":151},[127,2162,215],{"class":214},[127,2164,2165],{"class":151}," qc_live.num_qubits\n",[127,2167,2168,2170,2172,2174,2176],{"class":129,"line":161},[127,2169,135],{"class":133,"aria-hidden":134},[127,2171,211],{"class":151},[127,2173,215],{"class":214},[127,2175,218],{"class":192},[127,2177,2178],{"class":151},"(n, n)\n",[127,2180,2181,2183,2185,2188,2191,2194,2196,2199],{"class":129,"data-cue":28,"line":176},[127,2182,28],{"class":237},[127,2184,240],{"class":151},[127,2186,2187],{"class":192},"compose",[127,2189,2190],{"class":151},"(qc_live, ",[127,2192,2193],{"class":324},"inplace",[127,2195,215],{"class":214},[127,2197,2198],{"class":223},"True",[127,2200,231],{"class":151},[127,2202,2203,2205,2207,2209,2212,2215,2218,2220,2222,2224],{"class":129,"data-cue":252,"line":184},[127,2204,252],{"class":237},[127,2206,240],{"class":151},[127,2208,2187],{"class":192},[127,2210,2211],{"class":151},"(qc_ref.",[127,2213,2214],{"class":192},"inverse",[127,2216,2217],{"class":151},"(), ",[127,2219,2193],{"class":324},[127,2221,215],{"class":214},[127,2223,2198],{"class":223},[127,2225,231],{"class":151},[127,2227,2228,2230,2232,2234,2236,2238,2241,2243],{"class":129,"line":206},[127,2229,135],{"class":133,"aria-hidden":134},[127,2231,240],{"class":151},[127,2233,292],{"class":192},[127,2235,196],{"class":151},[127,2237,1060],{"class":214},[127,2239,2240],{"class":151},"(n), ",[127,2242,1060],{"class":214},[127,2244,1283],{"class":151},[127,2246,2247,2249,2251],{"class":129,"line":234},[127,2248,135],{"class":133,"aria-hidden":134},[127,2250,354],{"class":147},[127,2252,2253],{"class":151}," qc\n",[506,2255,2256,2263],{"class":508},[510,2257,2258,2260],{"data-cue":28},[127,2259,28],{"class":237},[127,2261,2262],{"class":516},"Prepare the live market's fingerprint on twelve qubits.",[510,2264,2265,2267],{"data-cue":252},[127,2266,252],{"class":237},[127,2268,2269],{"class":516},"Then the reference regime's circuit, inverted. Every gate in it runs backwards, so this undoes the preparation of the reference exactly.",[12,2271,2272],{},"Four thousand and ninety-six outcomes are possible on twelve qubits, and every one of them is reached by a great many routes through the two circuits. If the live state and the reference are the same, the inverse cancels the preparation and every route recombines on all-zeros. If they differ, the cancellation is partial and shots leak into the other bitstrings.",[12,2274,2275],{},"So the fraction of shots reading all zeros estimates the squared overlap between the two states, measured without either state being inspected.",[112,2277,2278],{"name":2124,"tag":2125,"run-href":2126},[118,2279,2281],{"className":120,"code":2280,"language":122,"meta":123,"style":123},"    live = _build(DEMO_PARAMS[ci][REF_FAM[target]])\n    ref = _build(REF_PARAMS[target])\n    circuit = transpile(_inversion(live, ref), backend=backend, optimization_level=0)\n    result = backend.run(circuit, shots=shots).result()\n    counts = result.get_counts()\n    if isinstance(counts, list):                # defensive; single circuit expected\n        counts = counts[0]\n    K_meas = _zero_frac(counts)\n    sigma = (K_meas * (1.0 - K_meas) \u002F max(shots, 1)) ** 0.5\n",[22,2282,2283,2309,2328,2365,2392,2407,2427,2443,2458,2504],{"__ignoreMap":123},[127,2284,2285,2287,2290,2292,2295,2297,2300,2303,2306],{"class":129,"line":130},[127,2286,135],{"class":133,"aria-hidden":134},[127,2288,2289],{"class":151},"    live ",[127,2291,215],{"class":214},[127,2293,2294],{"class":192}," _build",[127,2296,196],{"class":151},[127,2298,2299],{"class":223},"DEMO_PARAMS",[127,2301,2302],{"class":151},"[ci][",[127,2304,2305],{"class":223},"REF_FAM",[127,2307,2308],{"class":151},"[target]])\n",[127,2310,2311,2313,2316,2318,2320,2322,2325],{"class":129,"line":142},[127,2312,135],{"class":133,"aria-hidden":134},[127,2314,2315],{"class":151},"    ref ",[127,2317,215],{"class":214},[127,2319,2294],{"class":192},[127,2321,196],{"class":151},[127,2323,2324],{"class":223},"REF_PARAMS",[127,2326,2327],{"class":151},"[target])\n",[127,2329,2330,2332,2335,2337,2340,2342,2345,2348,2351,2353,2356,2359,2361,2363],{"class":129,"line":161},[127,2331,135],{"class":133,"aria-hidden":134},[127,2333,2334],{"class":151},"    circuit ",[127,2336,215],{"class":214},[127,2338,2339],{"class":192}," transpile",[127,2341,196],{"class":151},[127,2343,2344],{"class":192},"_inversion",[127,2346,2347],{"class":151},"(live, ref), ",[127,2349,2350],{"class":324},"backend",[127,2352,215],{"class":214},[127,2354,2355],{"class":151},"backend, ",[127,2357,2358],{"class":324},"optimization_level",[127,2360,215],{"class":214},[127,2362,24],{"class":223},[127,2364,231],{"class":151},[127,2366,2367,2369,2372,2374,2376,2378,2381,2383,2385,2388,2390],{"class":129,"data-cue":28,"line":176},[127,2368,28],{"class":237},[127,2370,2371],{"class":151},"    result ",[127,2373,215],{"class":214},[127,2375,315],{"class":151},[127,2377,318],{"class":192},[127,2379,2380],{"class":151},"(circuit, ",[127,2382,325],{"class":324},[127,2384,215],{"class":214},[127,2386,2387],{"class":151},"shots).",[127,2389,336],{"class":192},[127,2391,345],{"class":151},[127,2393,2394,2396,2398,2400,2403,2405],{"class":129,"line":184},[127,2395,135],{"class":133,"aria-hidden":134},[127,2397,310],{"class":151},[127,2399,215],{"class":214},[127,2401,2402],{"class":151}," result.",[127,2404,342],{"class":192},[127,2406,345],{"class":151},[127,2408,2409,2411,2413,2416,2419,2421,2424],{"class":129,"line":206},[127,2410,135],{"class":133,"aria-hidden":134},[127,2412,916],{"class":147},[127,2414,2415],{"class":214}," isinstance",[127,2417,2418],{"class":151},"(counts, ",[127,2420,1055],{"class":214},[127,2422,2423],{"class":151},"):                ",[127,2425,2426],{"class":138},"# defensive; single circuit expected\n",[127,2428,2429,2431,2433,2435,2438,2440],{"class":129,"line":234},[127,2430,135],{"class":133,"aria-hidden":134},[127,2432,1867],{"class":151},[127,2434,215],{"class":214},[127,2436,2437],{"class":151}," counts[",[127,2439,24],{"class":223},[127,2441,2442],{"class":151},"]\n",[127,2444,2445,2447,2450,2452,2455],{"class":129,"data-cue":252,"line":253},[127,2446,252],{"class":237},[127,2448,2449],{"class":151},"    K_meas ",[127,2451,215],{"class":214},[127,2453,2454],{"class":192}," _zero_frac",[127,2456,2457],{"class":151},"(counts)\n",[127,2459,2460,2462,2465,2467,2470,2473,2476,2479,2482,2485,2487,2490,2493,2495,2498,2501],{"class":129,"data-cue":269,"line":270},[127,2461,269],{"class":237},[127,2463,2464],{"class":151},"    sigma ",[127,2466,215],{"class":214},[127,2468,2469],{"class":151}," (K_meas ",[127,2471,2472],{"class":214},"*",[127,2474,2475],{"class":151}," (",[127,2477,2478],{"class":223},"1.0",[127,2480,2481],{"class":214}," -",[127,2483,2484],{"class":151}," K_meas) ",[127,2486,415],{"class":214},[127,2488,2489],{"class":214}," max",[127,2491,2492],{"class":151},"(shots, ",[127,2494,28],{"class":223},[127,2496,2497],{"class":151},")) ",[127,2499,2500],{"class":214},"**",[127,2502,2503],{"class":223}," 0.5\n",[506,2505,2506,2513,2520],{"class":508},[510,2507,2508,2510],{"data-cue":28},[127,2509,28],{"class":237},[127,2511,2512],{"class":516},"One job, one circuit. The playground allows a single hardware submission per run, so this cell spends it on one comparison.",[510,2514,2515,2517],{"data-cue":252},[127,2516,252],{"class":237},[127,2518,2519],{"class":516},"The kernel, read straight off the tally as the fraction of all-zero shots.",[510,2521,2522,2524],{"data-cue":269},[127,2523,269],{"class":237},[127,2525,2526],{"class":516},"And its error bar, because a fraction estimated from a finite pile of shots is an estimate.",[12,2528,2529],{},"The inversion test is the same shape as the circuit at the top of this page: prepare, then undo. What differs is that the undoing is done by a second circuit you choose, so how completely it returns to all-zeros measures how well the two agree.",[1702,2531],{"description":2532,"framework":1705,"owner":2533,"title":2534,"to":2126,"builder":2535},"Scores live equity returns against five volatility regimes taken from real market history, using quantum kernels on IonQ.","alireza","Quantum Regime Radar","Alireza Khodaei",[34,2537,2539],{"id":2538},"writing-a-phase-on-ten-qubits-at-once","Writing a phase on ten qubits at once",[12,2541,2542],{},"Musiq turns a circuit's output into sound, and one of the things it maps is the statevector's phase, onto oscillator phase.",[1716,2544],{"alt":2545,"caption":2546,"no":123,"src":2547},"Musiq, a browser-based quantum sonification platform","Phases mapped onto oscillators, so the cancellation in a circuit reaches the waveform.","\u002F_content\u002Fimages\u002Fmusiq\u002Fscreenshot.webp",[12,2549,2550],{},"Musiq's circuit library includes an IQP builder with the same shape as the Grover diffuser.",[112,2552,2555],{"name":2553,"tag":2554},"musiq\u002Fmodules\u002Fquantum_waveform_generator.py","Python · from the Musiq repository",[118,2556,2558],{"className":120,"code":2557,"language":122,"meta":123,"style":123},"        n = self.n_qubits\n        # n diagonal Rz params + (n-1)+(n-2) CZ layer = n + 2*n-3 for two CZ \"bands\"\n        num_rz = n\n        params = ParameterVector(\"λ\", num_rz)\n        qc = QuantumCircuit(n)\n        qc.h(range(n))\n        for qubit in range(n):\n            qc.rz(params[qubit], qubit)\n        # Fixed CZ pattern (nearest-neighbor style, no random choice)\n        for i in range(n):\n            for j in range(i + 1, min(i + 3, n)):\n                qc.cz(i, j)\n        qc.h(range(n))\n        qc.measure_all()\n",[22,2559,2560,2576,2583,2595,2615,2629,2643,2659,2671,2678,2693,2729,2741,2755,2766],{"__ignoreMap":123},[127,2561,2562,2564,2567,2569,2573],{"class":129,"line":130},[127,2563,135],{"class":133,"aria-hidden":134},[127,2565,2566],{"class":151},"        n ",[127,2568,215],{"class":214},[127,2570,2572],{"class":2571},"sU0A5"," self",[127,2574,2575],{"class":151},".n_qubits\n",[127,2577,2578,2580],{"class":129,"line":142},[127,2579,135],{"class":133,"aria-hidden":134},[127,2581,2582],{"class":138},"        # n diagonal Rz params + (n-1)+(n-2) CZ layer = n + 2*n-3 for two CZ \"bands\"\n",[127,2584,2585,2587,2590,2592],{"class":129,"line":161},[127,2586,135],{"class":133,"aria-hidden":134},[127,2588,2589],{"class":151},"        num_rz ",[127,2591,215],{"class":214},[127,2593,2594],{"class":151}," n\n",[127,2596,2597,2599,2602,2604,2607,2609,2612],{"class":129,"line":176},[127,2598,135],{"class":133,"aria-hidden":134},[127,2600,2601],{"class":151},"        params ",[127,2603,215],{"class":214},[127,2605,2606],{"class":192}," ParameterVector",[127,2608,196],{"class":151},[127,2610,2611],{"class":365},"\"λ\"",[127,2613,2614],{"class":151},", num_rz)\n",[127,2616,2617,2619,2622,2624,2626],{"class":129,"line":184},[127,2618,135],{"class":133,"aria-hidden":134},[127,2620,2621],{"class":151},"        qc ",[127,2623,215],{"class":214},[127,2625,218],{"class":192},[127,2627,2628],{"class":151},"(n)\n",[127,2630,2631,2633,2635,2637,2639,2641],{"class":129,"data-cue":28,"line":206},[127,2632,28],{"class":237},[127,2634,1964],{"class":151},[127,2636,243],{"class":192},[127,2638,196],{"class":151},[127,2640,1060],{"class":214},[127,2642,1283],{"class":151},[127,2644,2645,2647,2649,2652,2654,2656],{"class":129,"line":234},[127,2646,135],{"class":133,"aria-hidden":134},[127,2648,1773],{"class":147},[127,2650,2651],{"class":151}," qubit ",[127,2653,393],{"class":147},[127,2655,1781],{"class":214},[127,2657,2658],{"class":151},"(n):\n",[127,2660,2661,2663,2666,2668],{"class":129,"data-cue":252,"line":253},[127,2662,252],{"class":237},[127,2664,2665],{"class":151},"            qc.",[127,2667,109],{"class":192},[127,2669,2670],{"class":151},"(params[qubit], qubit)\n",[127,2672,2673,2675],{"class":129,"line":270},[127,2674,135],{"class":133,"aria-hidden":134},[127,2676,2677],{"class":138},"        # Fixed CZ pattern (nearest-neighbor style, no random choice)\n",[127,2679,2680,2682,2684,2687,2689,2691],{"class":129,"line":285},[127,2681,135],{"class":133,"aria-hidden":134},[127,2683,1773],{"class":147},[127,2685,2686],{"class":151}," i ",[127,2688,393],{"class":147},[127,2690,1781],{"class":214},[127,2692,2658],{"class":151},[127,2694,2695,2697,2700,2703,2705,2707,2710,2713,2715,2717,2720,2722,2724,2726],{"class":129,"line":305},[127,2696,135],{"class":133,"aria-hidden":134},[127,2698,2699],{"class":147},"            for",[127,2701,2702],{"class":151}," j ",[127,2704,393],{"class":147},[127,2706,1781],{"class":214},[127,2708,2709],{"class":151},"(i ",[127,2711,2712],{"class":214},"+",[127,2714,1038],{"class":223},[127,2716,226],{"class":151},[127,2718,2719],{"class":214},"min",[127,2721,2709],{"class":151},[127,2723,2712],{"class":214},[127,2725,958],{"class":223},[127,2727,2728],{"class":151},", n)):\n",[127,2730,2731,2733,2736,2738],{"class":129,"data-cue":269,"line":349},[127,2732,269],{"class":237},[127,2734,2735],{"class":151},"                qc.",[127,2737,691],{"class":192},[127,2739,2740],{"class":151},"(i, j)\n",[127,2742,2743,2745,2747,2749,2751,2753],{"class":129,"data-cue":348,"line":375},[127,2744,348],{"class":237},[127,2746,1964],{"class":151},[127,2748,243],{"class":192},[127,2750,196],{"class":151},[127,2752,1060],{"class":214},[127,2754,1283],{"class":151},[127,2756,2757,2759,2761,2764],{"class":129,"line":382},[127,2758,135],{"class":133,"aria-hidden":134},[127,2760,1964],{"class":151},[127,2762,2763],{"class":192},"measure_all",[127,2765,345],{"class":151},[506,2767,2768,2775,2782,2789],{"class":508},[510,2769,2770,2772],{"data-cue":28},[127,2771,28],{"class":237},[127,2773,2774],{"class":516},"Open every route at once. Ten qubits gives 1,024 outcomes, all equally likely at this line.",[510,2776,2777,2779],{"data-cue":252},[127,2778,252],{"class":237},[127,2780,2781],{"class":516},"One phase per qubit, and the parameters are named λ. Ten angles written into the state, none of which changes a single probability.",[510,2783,2784,2786],{"data-cue":269},[127,2785,269],{"class":237},[127,2787,2788],{"class":516},"Phases between pairs of qubits now, on top of the per-qubit ones. Still nothing has moved: every outcome is on 1\u002F1024 going into the next line.",[510,2790,2791,2793],{"data-cue":348},[127,2792,348],{"class":237},[127,2794,2795],{"class":516},"The closing Hadamard layer, and all of it arrives at once. Every phase written above decides where its routes reinforce and where they cancel, and the 1,024 flat probabilities become a distribution shaped by whatever those angles were.",[12,2797,2798],{},"IQP stands for instantaneous quantum polynomial time, and the name points at the middle of that circuit. Everything between the two Hadamard layers is diagonal, which means every gate in it only writes phases.",[12,2800,2801,2802,2804],{},"Measure after the ",[22,2803,691],{}," loop and the histogram is flat. The whole computation is sitting in the state, none of it is in the output, and the closing Hadamard layer converts it.",[12,2806,2807],{},"In Musiq that conversion has an audible result: the angles you bind into λ decide the spectrum you hear.",[1702,2809],{"description":2810,"framework":1705,"owner":2811,"title":2812,"to":2813,"builder":2814,"thumb":2547},"Musiq is a browser-based quantum sonification platform that transforms quantum-circuit outputs into generative audio.","doraking","Musiq","\u002Fu\u002Fdoraking\u002Fmusiq","Tomoya Hatanaka & Emmanuella Adams",[34,2816,2818],{"id":2817},"what-noise-takes-first","What noise takes first",[12,2820,2821],{},"Interference needs the relative phase between two routes to survive from the gate that wrote it to the gate that converts it. A real device does not hold phases that well.",[12,2823,2824],{},"Circuit depth is what that costs. One iteration is an oracle and a diffuser, each carrying a multi-controlled sign flip that hardware does not have as a single operation. Transpiled onto a real backend, each of those becomes a run of two-qubit gates, and the three-qubit search above is already tens of operations deep by its second iteration.",[12,2826,2827],{},"The playground project checks its own result at the end.",[112,2829,2830],{"name":771,"tag":115,"run-href":116},[118,2831,2833],{"className":120,"code":2832,"language":122,"meta":123,"style":123},"target_count = counts.get(target, 0)\nsuccess_rate = target_count \u002F shots\nprint(f\"\\nTarget |{target}⟩ found: {target_count}\u002F{shots} ({100*success_rate:.1f}%)\")\nprint(f\"Classical random guess would give: {100\u002F2**num_qubits:.1f}%\")\n\nif success_rate > 0.8:\n    print(\"✓ Grover's search successful!\")\nelse:\n    print(\"⚠ Lower than expected — noise may be affecting results\")\n",[22,2834,2835,2855,2872,2936,2969,2975,2993,3006,3015,3028],{"__ignoreMap":123},[127,2836,2837,2839,2842,2844,2846,2848,2851,2853],{"class":129,"line":130},[127,2838,135],{"class":133,"aria-hidden":134},[127,2840,2841],{"class":151},"target_count ",[127,2843,215],{"class":214},[127,2845,357],{"class":151},[127,2847,360],{"class":192},[127,2849,2850],{"class":151},"(target, ",[127,2852,24],{"class":223},[127,2854,231],{"class":151},[127,2856,2857,2859,2862,2864,2867,2869],{"class":129,"line":142},[127,2858,135],{"class":133,"aria-hidden":134},[127,2860,2861],{"class":151},"success_rate ",[127,2863,215],{"class":214},[127,2865,2866],{"class":151}," target_count ",[127,2868,415],{"class":214},[127,2870,2871],{"class":151}," shots\n",[127,2873,2874,2876,2879,2881,2883,2886,2889,2892,2894,2896,2898,2901,2903,2906,2908,2910,2912,2914,2916,2918,2921,2923,2926,2929,2931,2934],{"class":129,"line":161},[127,2875,135],{"class":133,"aria-hidden":134},[127,2877,2878],{"class":214},"print",[127,2880,196],{"class":151},[127,2882,471],{"class":147},[127,2884,2885],{"class":365},"\"",[127,2887,2888],{"class":214},"\\n",[127,2890,2891],{"class":365},"Target |",[127,2893,477],{"class":223},[127,2895,815],{"class":151},[127,2897,486],{"class":223},[127,2899,2900],{"class":365},"⟩ found: ",[127,2902,477],{"class":223},[127,2904,2905],{"class":151},"target_count",[127,2907,486],{"class":223},[127,2909,415],{"class":365},[127,2911,477],{"class":223},[127,2913,325],{"class":151},[127,2915,486],{"class":223},[127,2917,2475],{"class":365},[127,2919,2920],{"class":223},"{100",[127,2922,2472],{"class":214},[127,2924,2925],{"class":151},"success_rate",[127,2927,2928],{"class":147},":.1f",[127,2930,486],{"class":223},[127,2932,2933],{"class":365},"%)\"",[127,2935,231],{"class":151},[127,2937,2938,2940,2942,2944,2946,2949,2951,2953,2955,2957,2960,2962,2964,2967],{"class":129,"data-cue":28,"line":176},[127,2939,28],{"class":237},[127,2941,2878],{"class":214},[127,2943,196],{"class":151},[127,2945,471],{"class":147},[127,2947,2948],{"class":365},"\"Classical random guess would give: ",[127,2950,2920],{"class":223},[127,2952,415],{"class":214},[127,2954,252],{"class":223},[127,2956,2500],{"class":214},[127,2958,2959],{"class":151},"num_qubits",[127,2961,2928],{"class":147},[127,2963,486],{"class":223},[127,2965,2966],{"class":365},"%\"",[127,2968,231],{"class":151},[127,2970,2971,2973],{"class":129,"line":184},[127,2972,135],{"class":133,"aria-hidden":134},[127,2974,181],{},[127,2976,2977,2979,2982,2985,2988,2991],{"class":129,"data-cue":252,"line":206},[127,2978,252],{"class":237},[127,2980,2981],{"class":147},"if",[127,2983,2984],{"class":151}," success_rate ",[127,2986,2987],{"class":214},">",[127,2989,2990],{"class":223}," 0.8",[127,2992,897],{"class":151},[127,2994,2995,2997,2999,3001,3004],{"class":129,"line":234},[127,2996,135],{"class":133,"aria-hidden":134},[127,2998,466],{"class":214},[127,3000,196],{"class":151},[127,3002,3003],{"class":365},"\"✓ Grover's search successful!\"",[127,3005,231],{"class":151},[127,3007,3008,3010,3013],{"class":129,"line":253},[127,3009,135],{"class":133,"aria-hidden":134},[127,3011,3012],{"class":147},"else",[127,3014,897],{"class":151},[127,3016,3017,3019,3021,3023,3026],{"class":129,"line":270},[127,3018,135],{"class":133,"aria-hidden":134},[127,3020,466],{"class":214},[127,3022,196],{"class":151},[127,3024,3025],{"class":365},"\"⚠ Lower than expected — noise may be affecting results\"",[127,3027,231],{"class":151},[506,3029,3030,3037],{"class":508},[510,3031,3032,3034],{"data-cue":28},[127,3033,28],{"class":237},[127,3035,3036],{"class":516},"12.5%, what a uniform random guess would score. The circuit has to beat that for any of the interference to have reached the counts.",[510,3038,3039,3041],{"data-cue":252},[127,3040,252],{"class":237},[127,3042,3043],{"class":516},"A threshold picked by hand, sitting well below the 94.5% the maths predicts. The gap covers gate and readout error, compilation, and the ordinary scatter of a thousand shots.",[12,3045,3046],{},"None of these circuits is faster than a laptop. Eight items is a trivial search, and a classical computer checks all of them before an IonQ job has left the queue. Grover's advantage is quadratic and it needs a search space far larger than anything a current device can hold with its phases intact.",[12,3048,3049],{},"Which makes the reason to run these circuits on hardware a narrow one. A simulator gives you the arc every time, exactly as the arithmetic predicts. The one question it cannot answer is how much of the interference is left by the end of a real run. The gap between 94.5% and whatever comes back is that answer.",[12,3051,3052],{},"Quantum Advantage Lab handles this by storing hardware runs and replaying them rather than re-queuing, which keeps the comparison honest without paying for the queue twice.",[34,3054,3056],{"id":3055},"start-with-grover","Start with Grover",[12,3058,3059,3060,3062],{},"Every circuit on this page writes a sign or a phase that moves no probability. A later gate opens the routes back onto each other, and those signs decide where the shots land. Finding both halves is most of reading a quantum algorithm: in Grover they are the oracle's ",[22,3061,720],{}," and the diffuser's closing Hadamards.",[12,3064,3065,3066,3068],{},"Fork Grover's search first. The circuit runs in the Playground with no setup, and the oracle and the diffuser are under forty lines together. Change ",[22,3067,815],{}," to any of the eight bitstrings and the same two functions concentrate on whichever one you name.",[3070,3071,3073],"make-it-yours",{"fork-href":116,"title":3072},"Run it, then overshoot it.",[12,3074,3075,3076],{},"Fork Grover's search, run it as shipped, then raise the iteration count by one and watch the answer come apart. Then open any project above and find the line where its phases turn back into counts. ",[1690,3077,3078],{},"Everything here is open and yours to build on.",[3080,3081,3082],"style",{},"html pre.shiki code .sV9Aq, html code.shiki .sV9Aq{--shiki-default:#7F848E;--shiki-default-font-style:italic}html pre.shiki code .seHd6, html code.shiki .seHd6{--shiki-default:#C678DD}html pre.shiki code .sn6KH, html code.shiki .sn6KH{--shiki-default:#ABB2BF}html pre.shiki code .sVbv2, html code.shiki .sVbv2{--shiki-default:#61AFEF}html pre.shiki code .sb9H8, html code.shiki .sb9H8{--shiki-default:#D19A66;--shiki-default-font-style:italic}html pre.shiki code .sjrmR, html code.shiki .sjrmR{--shiki-default:#56B6C2}html pre.shiki code .sVC51, html code.shiki .sVC51{--shiki-default:#D19A66}html pre.shiki code .s_ZVi, html code.shiki .s_ZVi{--shiki-default:#E06C75;--shiki-default-font-style:italic}html pre.shiki code .subq3, html code.shiki .subq3{--shiki-default:#98C379}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sU0A5, html code.shiki .sU0A5{--shiki-default:#E5C07B}",{"title":123,"searchDepth":142,"depth":142,"links":3084},[3085,3086,3087,3088,3089,3090,3091,3094,3095,3096,3097,3098],{"id":36,"depth":142,"text":37},{"id":49,"depth":142,"text":50},{"id":86,"depth":142,"text":87},{"id":102,"depth":142,"text":103},{"id":646,"depth":142,"text":647},{"id":761,"depth":142,"text":762},{"id":1205,"depth":142,"text":1206,"children":3092},[3093],{"id":1587,"depth":161,"text":1588},{"id":1710,"depth":142,"text":1711},{"id":2114,"depth":142,"text":2115},{"id":2538,"depth":142,"text":2539},{"id":2817,"depth":142,"text":2818},{"id":3055,"depth":142,"text":3056},[3100,3101,3102],"Qollab","Learn","Quantum interference",[3104],{"username":7,"name":3105,"role":3106,"avatar":3107,"bio":3108,"links":3109},"Nicolaas Spijker","Community manager, Qollab","\u002F_content\u002Fimages\u002Fbuilders\u002Fnicolaas-spijker.webp","Nico runs the builder community at Qollab. These concept articles come out of that work: forking the projects people publish and running them. And talking with authors to learn more about their projects.",[3110,3113],{"label":3111,"href":3112},"Qollab ↗","https:\u002F\u002Fqollab.xyz\u002Fu\u002Fnico",{"label":3114,"href":3115},"GitHub ↗","https:\u002F\u002Fgithub.com\u002Fnicolaasspijker",{"username":7,"name":3105,"role":3106,"avatar":3107},null,"Superposition on its own is indistinguishable from a coin. Amplitudes are signed, they cancel, and that cancellation is the only reason an algorithm lands on the answer you want.","Superposition alone gives you random bits. Interference is what concentrates probability on one answer, in code from real projects you can run and fork.",false,"md",{"href":116,"label":3123},"Fork Grover's search","article",{},true,"\u002F_content\u002Fimages\u002Finterference\u002Fog.png","\u002Fblog\u002Flearn\u002Fquantum-interference","2026-09-09","14 min read",[],{"title":3133,"description":3134},"Quantum Interference, Explained with Code You Can Run","Why a quantum computer is not a slow random number generator: signed amplitudes cancel, and the cancellation concentrates probability on an answer. With real projects to run and fork.","blog\u002Flearn\u002Fquantum-interference",[3137,3138,3139],"interference","education","quantum","w2Z96rKFfVzSsYyUDe1nsVBsBJ4Tvxu_VQYjk8NxWMk",[],[],1788994898131]