[{"data":1,"prerenderedAt":8189},["ShallowReactive",2],{"blog-post-using-quantum-in-a-real-application\u002Fwhat-to-build":3,"sibling-dives-using-quantum-in-a-real-application\u002Fwhat-to-build":1341,"learn-track-using-quantum-in-a-real-application\u002Fwhat-to-build":1342,"learn-prereq-using-quantum-in-a-real-application\u002Fwhat-to-build":8188},{"id":4,"title":5,"authors":6,"body":8,"breadcrumb":1311,"builders":1315,"byline":1316,"category":1320,"categoryName":1320,"challenge":1320,"courseAuthor":1320,"courseLead":1320,"dek":1321,"description":1322,"draft":1323,"extension":1324,"eyebrow":1320,"featured":1323,"finish":1325,"fork":1320,"group":1320,"groupName":1320,"hero":1320,"heroAlt":1320,"heroCta":1320,"heroImage":1320,"homepageFeatured":1323,"kind":1326,"lessonCount":280,"meta":1327,"navigation":1328,"newsItems":1320,"next":1329,"ogImage":1320,"order":280,"outcomes":1320,"path":1333,"prerequisite":1320,"prerequisiteLinks":1320,"publishDate":1334,"readingTime":1320,"related":1335,"relatedProjects":1320,"section":1320,"seo":1336,"stem":1337,"tags":1338,"track":1339,"trackName":1314,"__hash__":1340},"blog\u002Fblog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fwhat-to-build.md","What to build",[7],"nico",{"type":9,"value":10,"toc":1302},"minimark",[11,15,22,27,34,52,63,84,87,108,129,132,136,139,145,151,157,163,166,170,173,176,179,183,186,189,1029,1032,1053,1074,1088,1098,1106,1109,1222,1291,1295,1298],[12,13,14],"p",{},"Choose a quantum project by the output your application needs. A circuit gives your program exactly one thing, a distribution over bitstrings, and every application built on one consumes that distribution in one of five ways. An idea that fits none of the five does not need a circuit. Picking a famous algorithm first and then looking for a place to use it often turns up nothing that fits.",[16,17],"blog-figure",{"alt":18,"caption":19,"no":20,"src":21},"A decision tree. It starts by asking what the application must consume. One answer quickly means the baseline wins and there is no circuit. Amplitudes or phases means a simulator-only path with a two-to-the-n ceiling. Samples or a distribution reaches the five shapes. Survivors then pass four gates: latency budget, reproducibility, input size, and whether a mature classical answer exists. Failing any gate returns the idea to the baseline.","The output shape gives a circuit a possible role; whether that role is worth building depends on the four gates and the classical baseline.","Fig. 1","\u002F_content\u002Fimages\u002Freal-app\u002Fdecision-tree.svg",[23,24,26],"h2",{"id":25},"five-things-you-can-do-with-a-distribution","Five things you can do with a distribution",[12,28,29,33],{},[30,31,32],"strong",{},"Sample from it."," You want draws, and you use the spread of outcomes directly. The picker you built takes this shape, and so does most generative work, where any given draw is as valid as another.",[12,35,36,41,42,46,47,51],{},[37,38,40],"a",{"href":39},"\u002Fexplore\u002Fquantum-garden","Quantum Garden"," maps five qubits' thirty-two outcomes to a plant's traits. ",[37,43,45],{"href":44},"\u002Fexplore\u002Fsuperposition-sequencer","Superposition Sequencer",", by Francisco Estivallet, turns every note in a music sequencer into a draw from a circuit you designed. ",[37,48,50],{"href":49},"\u002Fexplore\u002Fquantum-patterns","Quantum Patterns",", by Peter Thomas and Paulo Itaboraí, uses partitioned quantum cellular automata to make musical material you can live-code against.",[12,53,54,57,58,62],{},[30,55,56],{},"Compare two of them."," You have a live state and a reference state, and you want a similarity score between them. ",[37,59,61],{"href":60},"\u002Fexplore\u002Fquantum-regime-radar","Regime Radar"," prepares a fingerprint of current market conditions, runs a stored regime backwards over it, and reads the fraction of shots landing on all zeros as the overlap: when the two states match, the shots concentrate there.",[12,64,65,68,69,73,74,78,79,83],{},[30,66,67],{},"Read structure inside it."," You care less about which outcomes appear than about how the bits relate: which qubits agree, which are correlated, how that changes layer by layer. ",[37,70,72],{"href":71},"\u002Fexplore\u002Fquantum-butterfly-field","Butterfly Field"," turns pairwise entanglement into the threads between its butterflies. ",[37,75,77],{"href":76},"\u002Fexplore\u002Fqcflows","QCFlows"," renders the same structure as a live graph. ",[37,80,82],{"href":81},"\u002Fexplore\u002Fentangled-body","Entangled Body",", by Chanhyuk Park and Luke Shim, builds a point-cloud figure whose parts, per its write-up, respond to each other across distance.",[12,85,86],{},"Classical simulations of many entangled qubits get expensive quickly, so this shape has the least obvious classical shortcut.",[12,88,89,92,93,97,98,102,103,107],{},[30,90,91],{},"Reduce it to one number."," You want a score, and the distribution is only an intermediate. ",[37,94,96],{"href":95},"\u002Fexplore\u002Fquantum-systemic-oracle","The Quantum Systemic Oracle"," reduces an optimization result to a single risk index. ",[37,99,101],{"href":100},"\u002Fexplore\u002Fqorbital","qOrbital",", by Aryan Bawa and Arnav Singh, runs a chemistry calculation and reads out a molecule's energy. ",[37,104,106],{"href":105},"\u002Fexplore\u002Fquantum-market-game","Quantum Market Game",", by Aadarsh Venkat Ramanan, models two traders as two entangled qubits and reads their payoffs out of the tally.",[12,109,110,113,114,118,119,123,124,128],{},[30,111,112],{},"Watch it change."," This shape reads the statevector rather than a tally, so per lesson 2 it only exists on a simulator, which is enough for a tool that shows someone what a circuit is doing. ",[37,115,117],{"href":116},"\u002Fexplore\u002Fqave","QAVE",", by Inho Choi, makes an algorithm visible gate by gate. ",[37,120,122],{"href":121},"\u002Fexplore\u002Fquantum-advantage-lab","Quantum Advantage Lab",", by Hossein Sadeghi, streams four algorithms' intermediate state beside their classical counterparts. ",[37,125,127],{"href":126},"\u002Fexplore\u002Fquantum-canvas","Quantum Canvas",", by Shivani Mayekar, lets you drag operations into a circuit and watch the result move.",[12,130,131],{},"Watching it change is also the easiest of the five shapes to ship, because nothing queues.",[23,133,135],{"id":134},"ideas-that-do-not-map","Ideas that do not map",[12,137,138],{},"Most ideas do not map, for one of four reasons.",[12,140,141,144],{},[30,142,143],{},"It needs one correct answer, quickly."," A distribution is not an answer, and lesson 5 measured what the round trip costs. If your feature can be written with a lookup or a solver that returns in milliseconds, it should be.",[12,146,147,150],{},[30,148,149],{},"It needs to process a lot of data."," Getting classical data into a quantum state costs roughly one operation per number, so loading a large dataset takes longer than reading it. Your laptop already solves the problems small enough to fit on today's machines, and solves them exactly.",[12,152,153,156],{},[30,154,155],{},"It needs the state itself, at scale."," The fifth shape, watch it change, is fine for a teaching tool on a handful of qubits, but simulating n qubits takes 2ⁿ numbers, so an application built on statevectors hits a qubit limit quickly.",[12,158,159,162],{},[30,160,161],{},"It needs to be reproducible."," Two presses of an unchanged circuit disagree, as lesson 2's two Garden runs did. If your feature must produce the same output twice, the circuit has to sit behind a cache, which is the precomputed-pool shape from lesson 4.",[12,164,165],{},"These four reasons do not stop you learning, prototyping or building something because it interests you; they apply to shipping a feature.",[23,167,169],{"id":168},"the-shape-of-a-good-first-idea","The shape of a good first idea",[12,171,172],{},"The projects in this course share three things: a small circuit, a decode step doing most of the visible work, and a stated reason for the quantum part to be there.",[12,174,175],{},"Garden needed a supply of unpredictable, structured variation, and a pool of measurement outcomes gave it one. Butterfly Field set out to make entanglement visible. Regime Radar needed a similarity measure and chose a kernel that a circuit computes directly.",[12,177,178],{},"None of the three needed to beat a classical computer, which lesson 5 showed is rare today.",[23,180,182],{"id":181},"from-one-probability-to-two-inputs-and-four-named-outcomes","From one probability to two inputs and four named outcomes",[12,184,185],{},"A probability is the smallest thing you can put through a circuit. An application has several, and it needs its results named before anything can branch on them.",[12,187,188],{},"The next step up has two independent inputs, one qubit for each, and four named outcomes.",[190,191,196],"code-block",{"name":192,"no-picker":193,"run-href":194,"tag":195},"slice.py","","\u002Fu\u002Fqollab\u002Flearn-app-slice","Python · Playground",[197,198,202],"pre",{"className":199,"code":200,"language":201,"meta":193,"style":193},"language-python shiki shiki-themes one-dark-pro","# 'backend' already exists when this runs: it is whatever you pick in the Run Experiment dialog.\nfrom math import asin, sqrt\nfrom qiskit import QuantumCircuit\nfrom qiskit.providers.jobstatus import JobStatus\nimport time\n\nshots = 1000\np_left = 0.2\np_right = 0.8\n\nNAMES = {\n    \"00\": \"neither\",\n    \"01\": \"left_only\",               #   key is c1 c0, so the RIGHT character is qubit 0\n    \"10\": \"right_only\",\n    \"11\": \"both\",\n}\n\n\ndef build_circuit(pl, pr):\n    qc = QuantumCircuit(2, 2)\n    qc.ry(2 * asin(sqrt(pl)), 0)\n    qc.ry(2 * asin(sqrt(pr)), 1)\n    qc.measure([0, 1], [0, 1])\n    return qc\n\n\ndef decode(counts, n):\n    return {NAMES[k]: v \u002F n for k, v in sorted(counts.items())}\n\n\njob = backend.run(build_circuit(p_left, p_right), shots=shots)\nwhile job.status() not in (JobStatus.DONE, JobStatus.ERROR, JobStatus.CANCELLED):\n    time.sleep(5)\n\ncounts = job.result().get_counts()\nprint(counts)\n\nfor name, share in sorted(decode(counts, shots).items()):\n    print(f\"{name:11s} {share:.3f}   {'#' * int(40 * share)}\")\nprint(f\"expected both = {p_left * p_right:.3f}, neither = {(1 - p_left) * (1 - p_right):.3f}\")\n","python",[203,204,205,219,238,253,268,278,286,302,317,331,338,353,371,390,405,420,428,435,442,471,495,529,557,588,599,606,613,636,678,685,692,725,767,784,791,815,826,833,860,925,988],"code",{"__ignoreMap":193},[206,207,210,215],"span",{"class":208,"line":209},"line",1,[206,211,214],{"class":212,"aria-hidden":213},"qg-cue qg-cue--empty","true","​",[206,216,218],{"class":217},"sV9Aq","# 'backend' already exists when this runs: it is whatever you pick in the Run Experiment dialog.\n",[206,220,222,224,228,232,235],{"class":208,"line":221},2,[206,223,214],{"class":212,"aria-hidden":213},[206,225,227],{"class":226},"seHd6","from",[206,229,231],{"class":230},"sn6KH"," math ",[206,233,234],{"class":226},"import",[206,236,237],{"class":230}," asin, sqrt\n",[206,239,241,243,245,248,250],{"class":208,"line":240},3,[206,242,214],{"class":212,"aria-hidden":213},[206,244,227],{"class":226},[206,246,247],{"class":230}," qiskit ",[206,249,234],{"class":226},[206,251,252],{"class":230}," QuantumCircuit\n",[206,254,256,258,260,263,265],{"class":208,"line":255},4,[206,257,214],{"class":212,"aria-hidden":213},[206,259,227],{"class":226},[206,261,262],{"class":230}," qiskit.providers.jobstatus ",[206,264,234],{"class":226},[206,266,267],{"class":230}," JobStatus\n",[206,269,271,273,275],{"class":208,"line":270},5,[206,272,214],{"class":212,"aria-hidden":213},[206,274,234],{"class":226},[206,276,277],{"class":230}," time\n",[206,279,281,283],{"class":208,"line":280},6,[206,282,214],{"class":212,"aria-hidden":213},[206,284,285],{},"​\n",[206,287,289,291,294,298],{"class":208,"line":288},7,[206,290,214],{"class":212,"aria-hidden":213},[206,292,293],{"class":230},"shots ",[206,295,297],{"class":296},"sjrmR","=",[206,299,301],{"class":300},"sVC51"," 1000\n",[206,303,306,309,312,314],{"class":208,"data-cue":304,"line":305},"1",8,[206,307,304],{"class":308},"qg-cue",[206,310,311],{"class":230},"p_left ",[206,313,297],{"class":296},[206,315,316],{"class":300}," 0.2\n",[206,318,321,323,326,328],{"class":208,"data-cue":319,"line":320},"2",9,[206,322,319],{"class":308},[206,324,325],{"class":230},"p_right ",[206,327,297],{"class":296},[206,329,330],{"class":300}," 0.8\n",[206,332,334,336],{"class":208,"line":333},10,[206,335,214],{"class":212,"aria-hidden":213},[206,337,285],{},[206,339,342,344,347,350],{"class":208,"data-cue":340,"line":341},"3",11,[206,343,340],{"class":308},[206,345,346],{"class":300},"NAMES",[206,348,349],{"class":296}," =",[206,351,352],{"class":230}," {\n",[206,354,356,358,362,365,368],{"class":208,"line":355},12,[206,357,214],{"class":212,"aria-hidden":213},[206,359,361],{"class":360},"subq3","    \"00\"",[206,363,364],{"class":230},": ",[206,366,367],{"class":360},"\"neither\"",[206,369,370],{"class":230},",\n",[206,372,374,376,379,381,384,387],{"class":208,"line":373},13,[206,375,214],{"class":212,"aria-hidden":213},[206,377,378],{"class":360},"    \"01\"",[206,380,364],{"class":230},[206,382,383],{"class":360},"\"left_only\"",[206,385,386],{"class":230},",               ",[206,388,389],{"class":217},"#   key is c1 c0, so the RIGHT character is qubit 0\n",[206,391,393,395,398,400,403],{"class":208,"line":392},14,[206,394,214],{"class":212,"aria-hidden":213},[206,396,397],{"class":360},"    \"10\"",[206,399,364],{"class":230},[206,401,402],{"class":360},"\"right_only\"",[206,404,370],{"class":230},[206,406,408,410,413,415,418],{"class":208,"line":407},15,[206,409,214],{"class":212,"aria-hidden":213},[206,411,412],{"class":360},"    \"11\"",[206,414,364],{"class":230},[206,416,417],{"class":360},"\"both\"",[206,419,370],{"class":230},[206,421,423,425],{"class":208,"line":422},16,[206,424,214],{"class":212,"aria-hidden":213},[206,426,427],{"class":230},"}\n",[206,429,431,433],{"class":208,"line":430},17,[206,432,214],{"class":212,"aria-hidden":213},[206,434,285],{},[206,436,438,440],{"class":208,"line":437},18,[206,439,214],{"class":212,"aria-hidden":213},[206,441,285],{},[206,443,446,448,451,455,458,462,465,468],{"class":208,"data-cue":444,"line":445},"4",19,[206,447,444],{"class":308},[206,449,450],{"class":226},"def",[206,452,454],{"class":453},"sVbv2"," build_circuit",[206,456,457],{"class":230},"(",[206,459,461],{"class":460},"sb9H8","pl",[206,463,464],{"class":230},", ",[206,466,467],{"class":460},"pr",[206,469,470],{"class":230},"):\n",[206,472,474,476,479,481,484,486,488,490,492],{"class":208,"line":473},20,[206,475,214],{"class":212,"aria-hidden":213},[206,477,478],{"class":230},"    qc ",[206,480,297],{"class":296},[206,482,483],{"class":453}," QuantumCircuit",[206,485,457],{"class":230},[206,487,319],{"class":300},[206,489,464],{"class":230},[206,491,319],{"class":300},[206,493,494],{"class":230},")\n",[206,496,498,500,503,506,508,510,513,516,518,521,524,527],{"class":208,"line":497},21,[206,499,214],{"class":212,"aria-hidden":213},[206,501,502],{"class":230},"    qc.",[206,504,505],{"class":453},"ry",[206,507,457],{"class":230},[206,509,319],{"class":300},[206,511,512],{"class":296}," *",[206,514,515],{"class":453}," asin",[206,517,457],{"class":230},[206,519,520],{"class":453},"sqrt",[206,522,523],{"class":230},"(pl)), ",[206,525,526],{"class":300},"0",[206,528,494],{"class":230},[206,530,532,534,536,538,540,542,544,546,548,550,553,555],{"class":208,"line":531},22,[206,533,214],{"class":212,"aria-hidden":213},[206,535,502],{"class":230},[206,537,505],{"class":453},[206,539,457],{"class":230},[206,541,319],{"class":300},[206,543,512],{"class":296},[206,545,515],{"class":453},[206,547,457],{"class":230},[206,549,520],{"class":453},[206,551,552],{"class":230},"(pr)), ",[206,554,304],{"class":300},[206,556,494],{"class":230},[206,558,560,562,564,567,570,572,574,576,579,581,583,585],{"class":208,"line":559},23,[206,561,214],{"class":212,"aria-hidden":213},[206,563,502],{"class":230},[206,565,566],{"class":453},"measure",[206,568,569],{"class":230},"([",[206,571,526],{"class":300},[206,573,464],{"class":230},[206,575,304],{"class":300},[206,577,578],{"class":230},"], [",[206,580,526],{"class":300},[206,582,464],{"class":230},[206,584,304],{"class":300},[206,586,587],{"class":230},"])\n",[206,589,591,593,596],{"class":208,"line":590},24,[206,592,214],{"class":212,"aria-hidden":213},[206,594,595],{"class":226},"    return",[206,597,598],{"class":230}," qc\n",[206,600,602,604],{"class":208,"line":601},25,[206,603,214],{"class":212,"aria-hidden":213},[206,605,285],{},[206,607,609,611],{"class":208,"line":608},26,[206,610,214],{"class":212,"aria-hidden":213},[206,612,285],{},[206,614,617,619,621,624,626,629,631,634],{"class":208,"data-cue":615,"line":616},"5",27,[206,618,615],{"class":308},[206,620,450],{"class":226},[206,622,623],{"class":453}," decode",[206,625,457],{"class":230},[206,627,628],{"class":460},"counts",[206,630,464],{"class":230},[206,632,633],{"class":460},"n",[206,635,470],{"class":230},[206,637,639,641,643,646,648,651,654,657,660,663,666,669,672,675],{"class":208,"line":638},28,[206,640,214],{"class":212,"aria-hidden":213},[206,642,595],{"class":226},[206,644,645],{"class":230}," {",[206,647,346],{"class":300},[206,649,650],{"class":230},"[k]: v ",[206,652,653],{"class":296},"\u002F",[206,655,656],{"class":230}," n ",[206,658,659],{"class":226},"for",[206,661,662],{"class":230}," k, v ",[206,664,665],{"class":226},"in",[206,667,668],{"class":296}," sorted",[206,670,671],{"class":230},"(counts.",[206,673,674],{"class":453},"items",[206,676,677],{"class":230},"())}\n",[206,679,681,683],{"class":208,"line":680},29,[206,682,214],{"class":212,"aria-hidden":213},[206,684,285],{},[206,686,688,690],{"class":208,"line":687},30,[206,689,214],{"class":212,"aria-hidden":213},[206,691,285],{},[206,693,695,697,700,702,705,708,710,713,716,720,722],{"class":208,"line":694},31,[206,696,214],{"class":212,"aria-hidden":213},[206,698,699],{"class":230},"job ",[206,701,297],{"class":296},[206,703,704],{"class":230}," backend.",[206,706,707],{"class":453},"run",[206,709,457],{"class":230},[206,711,712],{"class":453},"build_circuit",[206,714,715],{"class":230},"(p_left, p_right), ",[206,717,719],{"class":718},"s_ZVi","shots",[206,721,297],{"class":296},[206,723,724],{"class":230},"shots)\n",[206,726,728,730,733,736,739,742,745,748,751,754,757,760,762,765],{"class":208,"line":727},32,[206,729,214],{"class":212,"aria-hidden":213},[206,731,732],{"class":226},"while",[206,734,735],{"class":230}," job.",[206,737,738],{"class":453},"status",[206,740,741],{"class":230},"() ",[206,743,744],{"class":226},"not",[206,746,747],{"class":226}," in",[206,749,750],{"class":230}," (JobStatus.",[206,752,753],{"class":300},"DONE",[206,755,756],{"class":230},", JobStatus.",[206,758,759],{"class":300},"ERROR",[206,761,756],{"class":230},[206,763,764],{"class":300},"CANCELLED",[206,766,470],{"class":230},[206,768,770,772,775,778,780,782],{"class":208,"line":769},33,[206,771,214],{"class":212,"aria-hidden":213},[206,773,774],{"class":230},"    time.",[206,776,777],{"class":453},"sleep",[206,779,457],{"class":230},[206,781,615],{"class":300},[206,783,494],{"class":230},[206,785,787,789],{"class":208,"line":786},34,[206,788,214],{"class":212,"aria-hidden":213},[206,790,285],{},[206,792,794,796,799,801,803,806,809,812],{"class":208,"line":793},35,[206,795,214],{"class":212,"aria-hidden":213},[206,797,798],{"class":230},"counts ",[206,800,297],{"class":296},[206,802,735],{"class":230},[206,804,805],{"class":453},"result",[206,807,808],{"class":230},"().",[206,810,811],{"class":453},"get_counts",[206,813,814],{"class":230},"()\n",[206,816,818,820,823],{"class":208,"line":817},36,[206,819,214],{"class":212,"aria-hidden":213},[206,821,822],{"class":296},"print",[206,824,825],{"class":230},"(counts)\n",[206,827,829,831],{"class":208,"line":828},37,[206,830,214],{"class":212,"aria-hidden":213},[206,832,285],{},[206,834,836,838,840,843,845,847,849,852,855,857],{"class":208,"line":835},38,[206,837,214],{"class":212,"aria-hidden":213},[206,839,659],{"class":226},[206,841,842],{"class":230}," name, share ",[206,844,665],{"class":226},[206,846,668],{"class":296},[206,848,457],{"class":230},[206,850,851],{"class":453},"decode",[206,853,854],{"class":230},"(counts, shots).",[206,856,674],{"class":453},[206,858,859],{"class":230},"()):\n",[206,861,863,865,868,870,873,876,879,882,885,888,890,893,896,898,901,904,906,909,911,914,916,919,921,923],{"class":208,"line":862},39,[206,864,214],{"class":212,"aria-hidden":213},[206,866,867],{"class":296},"    print",[206,869,457],{"class":230},[206,871,872],{"class":226},"f",[206,874,875],{"class":360},"\"",[206,877,878],{"class":300},"{",[206,880,881],{"class":230},"name",[206,883,884],{"class":226},":11s",[206,886,887],{"class":300},"}",[206,889,645],{"class":300},[206,891,892],{"class":230},"share",[206,894,895],{"class":226},":.3f",[206,897,887],{"class":300},[206,899,900],{"class":300},"   {",[206,902,903],{"class":360},"'#'",[206,905,512],{"class":296},[206,907,908],{"class":296}," int",[206,910,457],{"class":230},[206,912,913],{"class":300},"40",[206,915,512],{"class":296},[206,917,918],{"class":230}," share)",[206,920,887],{"class":300},[206,922,875],{"class":360},[206,924,494],{"class":230},[206,926,928,930,932,934,936,939,941,943,946,949,951,953,956,958,960,962,965,968,970,973,975,977,980,982,984,986],{"class":208,"line":927},40,[206,929,214],{"class":212,"aria-hidden":213},[206,931,822],{"class":296},[206,933,457],{"class":230},[206,935,872],{"class":226},[206,937,938],{"class":360},"\"expected both = ",[206,940,878],{"class":300},[206,942,311],{"class":230},[206,944,945],{"class":296},"*",[206,947,948],{"class":230}," p_right",[206,950,895],{"class":226},[206,952,887],{"class":300},[206,954,955],{"class":360},", neither = ",[206,957,878],{"class":300},[206,959,457],{"class":230},[206,961,304],{"class":300},[206,963,964],{"class":296}," -",[206,966,967],{"class":230}," p_left) ",[206,969,945],{"class":296},[206,971,972],{"class":230}," (",[206,974,304],{"class":300},[206,976,964],{"class":296},[206,978,979],{"class":230}," p_right)",[206,981,895],{"class":226},[206,983,887],{"class":300},[206,985,875],{"class":360},[206,987,494],{"class":230},[989,990,992,1001,1008,1015,1022],"ol",{"class":991},"qg-cues",[993,994,995,997],"li",{"data-cue":304},[206,996,304],{"class":308},[206,998,1000],{"class":999},"qg-cues__text","one input per qubit: how often the left step fires",[993,1002,1003,1005],{"data-cue":319},[206,1004,319],{"class":308},[206,1006,1007],{"class":999},"and the right one",[993,1009,1010,1012],{"data-cue":340},[206,1011,340],{"class":308},[206,1013,1014],{"class":999},"the result schema the rest of the app codes against",[993,1016,1017,1019],{"data-cue":444},[206,1018,444],{"class":308},[206,1020,1021],{"class":999},"two app values in, one two-qubit circuit out",[993,1023,1024,1026],{"data-cue":615},[206,1025,615],{"class":308},[206,1027,1028],{"class":999},"counts in, named results out",[12,1030,1031],{},"Three things changed from the picker, and all three are the parts you would write for any application.",[12,1033,1034,1037,1038,1041,1042,1045,1046,1048,1049,1052],{},[30,1035,1036],{},"Two inputs, two qubits."," ",[203,1039,1040],{},"p_left"," and ",[203,1043,1044],{},"p_right"," each get their own ",[203,1047,505],{},". Nothing entangles the two qubits, so the four outcomes are the two probabilities multiplied out, and calling ",[203,1050,1051],{},"random.choices"," twice would do the same job.",[12,1054,1055,1037,1058,1060,1061,464,1064,464,1067,1041,1070,1073],{},[30,1056,1057],{},"A result schema.",[203,1059,346],{}," turns bitstrings into ",[203,1062,1063],{},"neither",[203,1065,1066],{},"left_only",[203,1068,1069],{},"right_only",[203,1071,1072],{},"both",". The rest of the program branches on those words and never sees a bitstring. Adding a third input later means changing this table.",[12,1075,1076,1079,1080,1083,1084,1087],{},[30,1077,1078],{},"The bit order, stated once."," A counts key reads ",[203,1081,1082],{},"c1 c0",", so the rightmost character is qubit 0, and ",[203,1085,1086],{},"01"," means the left step fired and the right one did not. Get this backwards and your application does the opposite of what you meant, silently, because both keys are valid.",[12,1089,1090,1091,1041,1094,1097],{},"Our run on 22 September 2026, with ",[203,1092,1093],{},"p_left = 0.2",[203,1095,1096],{},"p_right = 0.8",":",[197,1099,1104],{"className":1100,"code":1102,"language":1103,"meta":193},[1101],"language-text","{'00': 172, '01': 56, '10': 621, '11': 151}\nboth        0.151   ######\nleft_only   0.056   ##\nneither     0.172   ######\nright_only  0.621   ########################\nexpected both = 0.160, neither = 0.160\n","text",[203,1105,1102],{"__ignoreMap":193},[12,1107,1108],{},"The ideal shares are 0.160, 0.040, 0.640 and 0.160. Every measured share sits near its ideal.",[1110,1111,1113,1117,1178],"assignment",{"check":1112},"your console prints your own four names, and each share sits near the number you worked out for it.",[23,1114,1116],{"id":1115},"assignment-name-the-results-your-own-idea-needs","Assignment: name the results your own idea needs",[989,1118,1119,1136,1142,1150,1153,1156,1175],{},[993,1120,1121,1122,1127,1128,1131,1132,1135],{},"Open ",[37,1123,1125],{"href":1124},"https:\u002F\u002Fqollab.xyz\u002Fu\u002Fqollab\u002Flearn-app-slice",[203,1126,194],{},", press ",[30,1129,1130],{},"Fork",", then ",[30,1133,1134],{},"Fork Project"," in the dialog.",[993,1137,1138,1139,1141],{},"In your fork, rename the four entries in ",[203,1140,346],{}," to the four outcomes your own idea would branch on.",[993,1143,1144,1145,1041,1147,1149],{},"Set ",[203,1146,1040],{},[203,1148,1044],{}," to the two probabilities your idea needs.",[993,1151,1152],{},"Work out the ideal share of each of your four outcomes, by multiplying the two probabilities out.",[993,1154,1155],{},"Predict which of your four will be the noisiest, and say why.",[993,1157,1158,1159,1162,1163,1166,1167,1170,1171,1174],{},"Press ",[30,1160,1161],{},"Run on Qollab",", choose ",[30,1164,1165],{},"IonQ Aria 1 (25q)"," under ",[30,1168,1169],{},"Remotely Run Simulators",", and press ",[30,1172,1173],{},"Run",".",[993,1176,1177],{},"Compare the four printed shares against the four you worked out.",[1179,1180,1182,1206,1215],"hint",{"label":1181},"Solution",[12,1183,1184,1185,464,1188,464,1191,1041,1194,1197,1198,464,1200,464,1202,464,1204,1174],{},"The four ideal shares are ",[203,1186,1187],{},"(1-pl)(1-pr)",[203,1189,1190],{},"pl(1-pr)",[203,1192,1193],{},"(1-pl)pr",[203,1195,1196],{},"pl·pr",", in the order ",[203,1199,1063],{},[203,1201,1066],{},[203,1203,1069],{},[203,1205,1072],{},[12,1207,1208,1209,1211,1212,1214],{},"The noisiest in relative terms is the smallest, because the uncertainty on a share is roughly the square root of its count divided by the shots. Ours was ",[203,1210,1066],{},": 56 shots, an ideal 40, and a measured 0.056 against 0.040. The same absolute error on ",[203,1213,1069],{},", which had 621 shots, is small by comparison.",[12,1216,1217,1218,1221],{},"If your four names do not cover every outcome, the listing raises a ",[203,1219,1220],{},"KeyError"," on the first key you left out, so the mistake shows up in development instead of in production.",[1110,1223,1225,1229,1232,1273],{"check":1224},"you have a tally from your own probability, and three written lines naming an idea, its shape, and its circuit, or a written reason it does not map.",[23,1226,1228],{"id":1227},"assignment-encode-one-probability-from-your-own-idea","Assignment: encode one probability from your own idea",[12,1230,1231],{},"Put one probability from your own idea through the boundary you built in lesson 3.",[989,1233,1234,1237,1240,1254,1260,1270],{},[993,1235,1236],{},"Write down an idea in one sentence, and say which of the five shapes it needs.",[993,1238,1239],{},"Find the single probability in it: a drop rate, a chance a note plays, how often a branch is taken, or how likely one of two states is.",[993,1241,1242,1243,1249,1250,1253],{},"Open your fork of ",[37,1244,1246],{"href":1245},"https:\u002F\u002Fqollab.xyz\u002Fu\u002Fqollab\u002Flearn-app-boundary",[203,1247,1248],{},"\u002Fu\u002Fqollab\u002Flearn-app-boundary"," from lesson 3. If the ",[203,1251,1252],{},"percent"," edit is still there, leave it.",[993,1255,1144,1256,1259],{},[203,1257,1258],{},"p_rare"," to your probability, and predict the tally you expect from 1,000 shots.",[993,1261,1158,1262,1162,1264,1166,1266,1170,1268,1174],{},[30,1263,1161],{},[30,1265,1165],{},[30,1267,1169],{},[30,1269,1173],{},[993,1271,1272],{},"Write down three lines: the idea, its output shape, and the circuit that would sit inside it. If step 1 showed the idea fits none of the five shapes, write down which of the four reasons it hit instead.",[1179,1274,1275,1285,1288],{"label":1181},[12,1276,1277,1278,1281,1282,1284],{},"A worked example: \"A rhythm generator where each step has a chance of firing.\" The rhythm generator needs shape one, sample from it. The probability is the chance a step fires, say 0.35. Setting ",[203,1279,1280],{},"p_rare = 0.35"," should give about 350 ones in 1,000 shots, inside a 95% window of roughly 320 to 380. The circuit inside the generator is one ",[203,1283,505],{}," per step, or one circuit sampled repeatedly.",[12,1286,1287],{},"A worked rejection: \"A scheduler that picks the cheapest delivery route.\" The scheduler is shape four, reduce to one number, and it hits the first reason. Classical routing heuristics are decades mature, and Quantum Courier's published stage 3 result is one measurement of that: classical annealing beat four QAOA variants at 25 customers.",[12,1289,1290],{},"Your tally will not equal your prediction exactly, for the reason lesson 2 gave.",[23,1292,1294],{"id":1293},"takeaway","Takeaway",[12,1296,1297],{},"Start from what your application consumes and choose the algorithm last. Match the output to one of the five things a distribution can do, then check the idea against the four reasons ideas fail to map.",[1299,1300,1301],"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 .sjrmR, html code.shiki .sjrmR{--shiki-default:#56B6C2}html pre.shiki code .sVC51, html code.shiki .sVC51{--shiki-default:#D19A66}html pre.shiki code .subq3, html code.shiki .subq3{--shiki-default:#98C379}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 .s_ZVi, html code.shiki .s_ZVi{--shiki-default:#E06C75;--shiki-default-font-style:italic}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);}",{"title":193,"searchDepth":221,"depth":221,"links":1303},[1304,1305,1306,1307,1308,1309,1310],{"id":25,"depth":221,"text":26},{"id":134,"depth":221,"text":135},{"id":168,"depth":221,"text":169},{"id":181,"depth":221,"text":182},{"id":1115,"depth":221,"text":1116},{"id":1227,"depth":221,"text":1228},{"id":1293,"depth":221,"text":1294},[1312,1313,1314,5],"Qollab","Learn","Using quantum in a real application",[],{"username":7,"name":1317,"role":1318,"avatar":1319},"Nicolaas Spijker","Community manager, Qollab","\u002F_content\u002Fimages\u002Fbuilders\u002Fnicolaas-spijker.webp",null,"Start from the shape of the output your application needs.","Work backwards from the output your application needs: match it to one of five things a distribution can do, or rule the idea out quickly.",false,"md","You can put a circuit inside a program, decide whether it belongs there, and work out what to build next.","lesson",{},true,{"slug":1330,"title":1331,"desc":1332},"\u002Fexplore","The projects","Open or fork any project built on Qollab.","\u002Fblog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fwhat-to-build","2026-09-22",[],{"title":5,"description":1322},"blog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fwhat-to-build",[],"using-quantum-in-a-real-application","Xixeh-8DDfgwheUbxwv2vamhdA0TtKoTLaetbz8-xa8",[],[1343,2092,3192,4659,6194,7262],{"id":1344,"title":1345,"authors":1346,"body":1347,"breadcrumb":2076,"builders":2077,"byline":2078,"category":1320,"categoryName":1320,"challenge":1320,"courseAuthor":1320,"courseLead":1320,"dek":2079,"description":2080,"draft":1323,"extension":1324,"eyebrow":1320,"featured":1323,"finish":1320,"fork":1320,"group":1320,"groupName":1320,"hero":1320,"heroAlt":1320,"heroCta":1320,"heroImage":1320,"homepageFeatured":1323,"kind":1326,"lessonCount":280,"meta":2081,"navigation":1328,"newsItems":1320,"next":2082,"ogImage":1320,"order":209,"outcomes":1320,"path":2086,"prerequisite":1320,"prerequisiteLinks":1320,"publishDate":1334,"readingTime":1320,"related":2087,"relatedProjects":1320,"section":1320,"seo":2088,"stem":2089,"tags":2090,"track":1339,"trackName":1314,"__hash__":2091},"blog\u002Fblog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fwhere-the-circuit-sits.md","Where the circuit sits",[7],{"type":9,"value":1348,"toc":2065},[1349,1352,1355,1362,1372,1375,1379,1384,1416,1419,1422,1425,1432,1542,1548,1552,1555,1583,1586,1592,1595,1599,1605,1608,1617,1620,1623,1626,1635,1638,1645,1648,1654,1657,1663,1671,1680,1683,1687,1693,1702,1708,1716,1917,1924,1927,1943,1956,1959,1962,1968,1975,2051,2053,2059,2062],[12,1350,1351],{},"A quantum circuit is a component your program calls. You send the quantum computer a circuit, you wait, and you get a tally of results back. The rest of your program stays in the Python or JavaScript you already write.",[12,1353,1354],{},"Programs like that are being built for finance, music, art and chemistry, and they are easier to build than they were a few years ago.",[12,1356,1357,1358,1361],{},"In spring 2026, after more than a decade in enterprise data architecture at a global bank, Jamie Dominguez started building with quantum computers. He built the ",[37,1359,1360],{"href":95},"Quantum Systemic Oracle"," alone, in a few weeks, to find out what he could make on real hardware with AI coding tools. The Oracle turns a day's market data into a risk score. Only one part of it, the portfolio optimization, is a quantum circuit, and Jamie treated that part as one component to wire in.",[1363,1364,1369],"pull-quote",{"avatar":1365,"name":1366,"role":1367,"username":1368},"\u002F_content\u002Fimages\u002Fbuilders\u002Fjamie-dominguez.webp","Jamie Dominguez","Creator, Quantum Systemic Oracle","jamie",[12,1370,1371],{},"This was my first QPU job and Qiskit run. I learned it's much easier to get started now than ever before.",[12,1373,1374],{},"You can wire a circuit into a program of your own the same way. Lesson 3 gives you one to start from, a weighted random picker built around a one-qubit circuit, which you fork and change, and lesson 5 races it against ordinary Python.",[23,1376,1378],{"id":1377},"the-five-steps-around-a-circuit","The five steps around a circuit",[16,1380],{"caption":1381,"no":20,"alt":1382,"src":1383},"Only two arrows cross the boundary. Application data goes right as circuit parameters; a tally comes back left as ordinary data. Both sides of the line are code you write.","A dashed vertical line divides the picture. On the left, ordinary code: app state feeds a prepare step. On the right, the quantum computer: a circuit feeds a measure step. An arrow labelled angles crosses the line to the right, and an arrow labelled a tally not a value crosses back to the left into a decode step, which feeds the result the program uses.","\u002F_content\u002Fimages\u002Freal-app\u002Fthe-boundary.svg",[989,1385,1386,1392,1398,1404,1410],{},[993,1387,1388,1391],{},[30,1389,1390],{},"App state."," Your application has some state: a request, a dataset or something a user just did.",[993,1393,1394,1397],{},[30,1395,1396],{},"Prepare."," Ordinary code turns that state into numbers the circuit can take, usually angles.",[993,1399,1400,1403],{},[30,1401,1402],{},"Circuit."," The circuit runs on the backend: a quantum computer, or a simulator of one.",[993,1405,1406,1409],{},[30,1407,1408],{},"Measure."," Each shot ends in a measurement that reads one bitstring, and the tally of those bitstrings, the counts, comes back to your program.",[993,1411,1412,1415],{},[30,1413,1414],{},"Decode."," Ordinary code turns the tally into a value the rest of your program can use.",[12,1417,1418],{},"Steps three and four run on the backend, and you reach them through one function call.",[12,1420,1421],{},"In the Oracle, the application state is the day's market data. The prepare step turns that data into the coefficients of a portfolio-optimization problem, and the coefficients set the circuit's rotation angles. IonQ runs the circuit and sends back a tally of sampled portfolios. In each 14-bit string, eight bits mark which of the eight candidate assets that portfolio holds.",[12,1423,1424],{},"The decode step measures the quality of the sampled portfolios and blends it with eight market signals into the risk score. The pipeline is built to publish the risk score to an Ethereum test network, where other programs can read it.",[12,1426,1427,1428,1431],{},"In the Oracle's listing, the function call between the two sides is ",[203,1429,1430],{},"backend.run",", with the circuit built above it and the tally read below it:",[190,1433,1437],{"name":1434,"no-picker":193,"run-href":1435,"tag":1436},"Qollab.py","\u002Fu\u002Fjamie\u002Fsystemic-oracle","Python · excerpt",[197,1438,1440],{"className":199,"code":1439,"language":201,"meta":193,"style":193},"qc = build_circuit(gammas, betas, ising_h, ising_J_pairs, SNAPSHOT)\njob = backend.run(transpile(qc, backend), shots=SHOTS)\nwhile job.status() is not JobStatus.DONE:\n    time.sleep(2)\ncounts = job.result().get_counts()   # sampled portfolios -> risk score (BPS)\n",[203,1441,1442,1459,1486,1510,1522],{"__ignoreMap":193},[206,1443,1444,1447,1449,1451,1454,1457],{"class":208,"line":209},[206,1445,1446],{"class":230},"qc ",[206,1448,297],{"class":296},[206,1450,454],{"class":453},[206,1452,1453],{"class":230},"(gammas, betas, ising_h, ising_J_pairs, ",[206,1455,1456],{"class":300},"SNAPSHOT",[206,1458,494],{"class":230},[206,1460,1461,1463,1465,1467,1469,1471,1474,1477,1479,1481,1484],{"class":208,"line":221},[206,1462,699],{"class":230},[206,1464,297],{"class":296},[206,1466,704],{"class":230},[206,1468,707],{"class":453},[206,1470,457],{"class":230},[206,1472,1473],{"class":453},"transpile",[206,1475,1476],{"class":230},"(qc, backend), ",[206,1478,719],{"class":718},[206,1480,297],{"class":296},[206,1482,1483],{"class":300},"SHOTS",[206,1485,494],{"class":230},[206,1487,1488,1490,1492,1494,1496,1499,1502,1505,1507],{"class":208,"line":240},[206,1489,732],{"class":226},[206,1491,735],{"class":230},[206,1493,738],{"class":453},[206,1495,741],{"class":230},[206,1497,1498],{"class":226},"is",[206,1500,1501],{"class":226}," not",[206,1503,1504],{"class":230}," JobStatus.",[206,1506,753],{"class":300},[206,1508,1509],{"class":230},":\n",[206,1511,1512,1514,1516,1518,1520],{"class":208,"line":255},[206,1513,774],{"class":230},[206,1515,777],{"class":453},[206,1517,457],{"class":230},[206,1519,319],{"class":300},[206,1521,494],{"class":230},[206,1523,1524,1526,1528,1530,1532,1534,1536,1539],{"class":208,"line":270},[206,1525,798],{"class":230},[206,1527,297],{"class":296},[206,1529,735],{"class":230},[206,1531,805],{"class":453},[206,1533,808],{"class":230},[206,1535,811],{"class":453},[206,1537,1538],{"class":230},"()   ",[206,1540,1541],{"class":217},"# sampled portfolios -> risk score (BPS)\n",[16,1543],{"caption":1544,"no":1545,"poster":1546,"video":1547},"The Oracle's dashboard for one day's run: the risk score moving as someone drags the market-signal sliders, the portfolio the quantum job picked beside the best one found by brute force, and the diagnostics of that run on IonQ Forte hardware.","Fig. 2","\u002F_content\u002Fimages\u002Freal-app\u002Foracle-poster.webp","https:\u002F\u002Fapi.cms.qollab.xyz\u002Fassets\u002Fe2405685-d94e-4678-95ff-78c4a081aa9c",[23,1549,1551],{"id":1550},"a-music-studio-a-market-tool-and-an-artwork","A music studio, a market tool and an artwork",[12,1553,1554],{},"Musiq, Quantum Regime Radar and Quantum Butterfly Field were also built in spring 2026, in a few weeks each. All three have a listing on Qollab that you can run and fork.",[1556,1557,1558,1567,1575],"ul",{},[993,1559,1560,1566],{},[30,1561,1562],{},[37,1563,1565],{"href":1564},"\u002Fexplore\u002Fmusiq","Musiq"," is a music studio in the browser that plays a circuit's outcomes as notes.",[993,1568,1569,1574],{},[30,1570,1571],{},[37,1572,1573],{"href":60},"Quantum Regime Radar"," is a market tool that scores a window of market returns against five volatility regimes taken from market history.",[993,1576,1577,1582],{},[30,1578,1579],{},[37,1580,1581],{"href":71},"Quantum Butterfly Field"," is an artwork in which five butterflies are five qubits, one of them damaged and then recovered.",[12,1584,1585],{},"Figure 3 lines the three programs up against the five steps.",[16,1587],{"caption":1588,"no":1589,"alt":1590,"src":1591},"The three projects differ in the data entering prepare, the raw result each one asks for, and what decode turns that result into.","Fig. 3","Three rows share five columns: app state, prepare, circuit and run, raw result, decode. Musiq goes from a circuit the user designed, through no preparation, to amplitudes and probabilities, to a waveform. Regime Radar goes from market returns, through fingerprint angles, to a comparison circuit, to the share of all-zero shots, to a regime score. Butterfly Field goes from scrambling settings, through a layer count and a seed, to an evolution circuit, to purities, entanglement and fidelities, to opacity and threads.","\u002F_content\u002Fimages\u002Freal-app\u002Fone-boundary-three-products.svg",[12,1593,1594],{},"All three programs use more than a tally. Musiq and Butterfly Field read values that only a simulator can hand back, such as amplitudes, phases and purities. The Radar computes exact overlaps to rank its regimes before it spends any shots. Lesson 2 covers when a program can have those values.",[1596,1597,1565],"h3",{"id":1598},"musiq",[16,1600],{"caption":1601,"no":1602,"poster":1603,"video":1604},"Building a circuit in Musiq, running it, and hearing the result, with its waveform and spectrum on screen. The video has sound.","Fig. 4","\u002F_content\u002Fimages\u002Fmusiq\u002Fhero.webp","https:\u002F\u002Fapi.cms.qollab.xyz\u002Fassets\u002F064dd3e0-1e11-4ebc-8646-a5b4444fbbca",[12,1606,1607],{},"Tomoya Hatanaka, who led Musiq, wanted music generated directly from quantum states, because he finds music built on classical random-number generators repetitive. Emmanuella Adams, a creative technologist, worked on how circuits become sound and on the studio's interface.",[1363,1609,1614],{"avatar":1610,"name":1611,"role":1612,"username":1613},"\u002F_content\u002Fimages\u002Fbuilders\u002Femmanuella-adams.webp","Emmanuella Adams","Creative technologist, Musiq","emmanuellaadams",[12,1615,1616],{},"Curiosity, not fear. Quantum computing is often presented as this impossible, gatekept thing. I want someone to hear their circuit and think, \"Oh, that's mine. I made that.\" The feeling of creating something you don't fully understand yet. That is where learning starts.",[12,1618,1619],{},"Musiq has no separate prepare step, because the circuit you design in the studio is its input. Musiq's decode step is a mapping table. Each measured outcome picks which note plays, how often the outcome came up sets how strong that note is, and the statevector's phases shape how the notes interfere. The output is a waveform you can play and export.",[1596,1621,1573],{"id":1622},"quantum-regime-radar",[12,1624,1625],{},"The Radar's premise is that a volatility model fitted in a calm market breaks in a crisis, so a modeller needs to know which regime the market is in first. Two of its five regimes are the low-volatility rally of 2017 and the 2020 COVID crash. The regime library is built on Alireza Khodaei's doctoral research, which estimated volatility-model parameters on a quantum annealer. An annealer is a different kind of quantum machine from the gate circuits in this course.",[1363,1627,1632],{"avatar":1628,"name":1629,"role":1630,"username":1631},"\u002F_content\u002Fimages\u002Fbuilders\u002Falireza-khodaei.webp","Alireza Khodaei","Creator, Quantum Regime Radar","alireza",[12,1633,1634],{},"We have a bunch of known market regimes with respect to volatility, and we make a quantum fingerprint out of each. Then, given live data: how similar are these two days to the pre-crisis regime? There is no yes-or-no answer. There is a probability.",[12,1636,1637],{},"The Radar's prepare step turns a window of market returns into the angles of a circuit whose state encodes how the market's volatility has behaved, a fingerprint of those conditions. The playground cell ships those angles already fitted.",[12,1639,1640,1641,1644],{},"The circuit prepares that fingerprint, runs a reference regime's circuit backwards over it, and measures. Running a circuit and then its reverse returns every qubit to 0, the way two ",[203,1642,1643],{},"h"," gates in a row do. So when the two fingerprints are identical, every shot on a noise-free simulator reads all zeros. The decode step reads the share of all-zero shots as a similarity score.",[12,1646,1647],{},"Figure 5 shows our run of the Radar on 22 September 2026, for NVDA in 2022, on the built-in simulator. The console shows the exact ranking first, with the COVID crash on top, then tests the top-ranked regime with one circuit. In the Probabilities panel, 17.68% of the 2,048 shots came back all zeros. The console reports that share as K = 0.1768, within shot noise of the exact 0.1779.",[16,1649],{"caption":1650,"no":1651,"alt":1652,"src":1653},"Regime Radar on the Qollab Playground: the console's ranking on the left, the Probabilities panel for the tally on the right.","Fig. 5","The Regime Radar project's output on the Qollab Playground, run on the built-in simulator. On the left, the console ranks five volatility regimes for NVDA in 2022, with the 2020 COVID crash on top at K 0.1779, runs one circuit for 2,048 shots, and reports a measured K of 0.1768. On the right, the Probabilities panel lists twelve-bit outcomes; the all-zeros outcome's bar, at 17.68%, is far longer than the others in view.","\u002F_content\u002Fimages\u002Freal-app\u002Fregime-radar-run.webp",[1596,1655,1581],{"id":1656},"quantum-butterfly-field",[16,1658],{"caption":1659,"no":1660,"poster":1661,"video":1662},"The opening of Quantum Butterfly Field: two butterflies arrive one at a time, then the field fills with threads as more fly in and the first scrambling beat begins. The video has sound.","Fig. 6","\u002F_content\u002Fimages\u002Freal-app\u002Fbutterfly-poster.webp","https:\u002F\u002Fapi.cms.qollab.xyz\u002Fassets\u002F3768811c-0ddc-4ad3-b2cd-416c8cebee9c",[12,1664,1665,1666,1670],{},"Xinyi Zhang, an artist and technologist, first painted Butterfly Field in 2024, while she lived on Oʻahu. She had the idea for the circuit after reading a Scientific American article on the quantum no-butterfly effect, a 2020 result by ",[37,1667,1669],{"href":1668},"https:\u002F\u002Farxiv.org\u002Fabs\u002F2003.07267","Yan and Sinitsyn",". Once information is scrambled deeply enough across an entangled system, damage to one part cannot destroy it, and running the scramble backwards recovers the damaged part almost completely.",[1363,1672,1677],{"avatar":1673,"name":1674,"role":1675,"username":1676},"\u002F_content\u002Fimages\u002Fbuilders\u002Fxinyi-zhang.webp","Xinyi Zhang","Creator, Quantum Butterfly Field","xinyi",[12,1678,1679],{},"The one rule I held onto throughout was that every visual parameter had to be driven by a real quantum value, nothing decorative, nothing faked. The wing opacity really is the purity, the threads really are the mutual information between the qubit pairs. When something didn't look right, the solution was not to invent a prettier number, but to find a better mapping. The beauty had to be grounded in the physics.",[12,1681,1682],{},"Butterfly Field's prepare step picks a scrambling depth and a random seed, which fix the circuit's gates. The circuit scrambles the five butterflies into one field, damages one of them, and runs the scramble backwards. For each layer, the simulation returns every butterfly's purity, how much each pair of butterflies shares, and a fidelity for how far the damaged butterfly has recovered. The final fidelity comes from recorded runs on IonQ Forte hardware. The decode step turns those numbers into the picture, and the fidelity, for instance, sets how brightly the damaged butterfly glows.",[23,1684,1686],{"id":1685},"find-the-boundary-in-quantum-garden","Find the boundary in Quantum Garden",[12,1688,1689,1690,1692],{},"Amber Wang and Justin Pincar, a data scientist and a software engineer, built ",[37,1691,40],{"href":39},", a digital garden where every plant gets its form from a circuit. They wanted to see what a garden based on the randomness of quantum measurement would look like. Neither came from quantum research. Justin had followed quantum computing for years before access to real hardware and the garden idea got him building.",[1363,1694,1699],{"avatar":1695,"name":1696,"role":1697,"username":1698},"\u002F_content\u002Fimages\u002Fbuilders\u002Famber-wang.webp","Amber Wang","Co-creator, Quantum Garden","AmberPincar",[12,1700,1701],{},"Designing for quantum means treating concepts like superposition, entanglement, and probabilistic measurement as actual creative materials, not just technical details. Instead of thinking, \"What output do I want?\" you're asking, \"What distribution of possible states do I want, and how should people encounter those states over time?\"",[16,1703],{"caption":1704,"no":1705,"alt":1706,"src":1707},"Quantum Garden's field, where plants germinate, bloom and fade on the garden's own schedule.","Fig. 7","The Quantum Garden field: flowers, grasses and small trees scattered across a pale lavender sky with soft clouds, several of them glowing, and a counter in the corner reading 129 plants.","\u002F_content\u002Fimages\u002Fquantum-garden\u002Ffig1-garden-preview.webp",[12,1709,1710,1711,1715],{},"Quantum Garden's listing on Qollab is about eighty lines and uses four gates, all of which you met in ",[37,1712,1714],{"href":1713},"\u002Flearn\u002Fprogramming-your-first-quantum-circuits","Course 2",". The excerpt below shows the first three of the listing's six layers, verbatim. The other three add phases, a second entangling pass and a final rotation, all from the same seed.",[190,1717,1720],{"name":1718,"no-picker":193,"run-href":1719,"tag":1436},"plant_circuit.py","\u002Fu\u002FAmberPincar\u002Fquantum-garden",[197,1721,1723],{"className":199,"code":1722,"language":201,"meta":193,"style":193},"seed = 42  # Each plant gets a deterministic seed from its ID hash\n\ncircuit = QuantumCircuit(5, 5)\n\n# Layer 1: Full superposition — all 32 outcomes initially possible\nfor i in range(5):\n    circuit.h(i)\n\n# Layer 2: Seed-based Ry rotations — parameterized bias per qubit\nfor i in range(5):\n    angle = (seed * (i + 1) * 0.1) % (2 * math.pi)\n    circuit.ry(angle, i)\n\n# Layer 3: Linear entanglement chain — correlates neighboring qubits\nfor i in range(4):\n    circuit.cx(i, i + 1)\n",[203,1724,1725,1738,1743,1762,1766,1771,1789,1799,1803,1808,1824,1867,1876,1880,1885,1901],{"__ignoreMap":193},[206,1726,1727,1730,1732,1735],{"class":208,"line":209},[206,1728,1729],{"class":230},"seed ",[206,1731,297],{"class":296},[206,1733,1734],{"class":300}," 42",[206,1736,1737],{"class":217},"  # Each plant gets a deterministic seed from its ID hash\n",[206,1739,1740],{"class":208,"line":221},[206,1741,1742],{"emptyLinePlaceholder":1328},"\n",[206,1744,1745,1748,1750,1752,1754,1756,1758,1760],{"class":208,"line":240},[206,1746,1747],{"class":230},"circuit ",[206,1749,297],{"class":296},[206,1751,483],{"class":453},[206,1753,457],{"class":230},[206,1755,615],{"class":300},[206,1757,464],{"class":230},[206,1759,615],{"class":300},[206,1761,494],{"class":230},[206,1763,1764],{"class":208,"line":255},[206,1765,1742],{"emptyLinePlaceholder":1328},[206,1767,1768],{"class":208,"line":270},[206,1769,1770],{"class":217},"# Layer 1: Full superposition — all 32 outcomes initially possible\n",[206,1772,1773,1775,1778,1780,1783,1785,1787],{"class":208,"line":280},[206,1774,659],{"class":226},[206,1776,1777],{"class":230}," i ",[206,1779,665],{"class":226},[206,1781,1782],{"class":296}," range",[206,1784,457],{"class":230},[206,1786,615],{"class":300},[206,1788,470],{"class":230},[206,1790,1791,1794,1796],{"class":208,"line":288},[206,1792,1793],{"class":230},"    circuit.",[206,1795,1643],{"class":453},[206,1797,1798],{"class":230},"(i)\n",[206,1800,1801],{"class":208,"line":305},[206,1802,1742],{"emptyLinePlaceholder":1328},[206,1804,1805],{"class":208,"line":320},[206,1806,1807],{"class":217},"# Layer 2: Seed-based Ry rotations — parameterized bias per qubit\n",[206,1809,1810,1812,1814,1816,1818,1820,1822],{"class":208,"line":333},[206,1811,659],{"class":226},[206,1813,1777],{"class":230},[206,1815,665],{"class":226},[206,1817,1782],{"class":296},[206,1819,457],{"class":230},[206,1821,615],{"class":300},[206,1823,470],{"class":230},[206,1825,1826,1829,1831,1834,1836,1839,1842,1845,1848,1850,1853,1855,1858,1860,1862,1864],{"class":208,"line":341},[206,1827,1828],{"class":230},"    angle ",[206,1830,297],{"class":296},[206,1832,1833],{"class":230}," (seed ",[206,1835,945],{"class":296},[206,1837,1838],{"class":230}," (i ",[206,1840,1841],{"class":296},"+",[206,1843,1844],{"class":300}," 1",[206,1846,1847],{"class":230},") ",[206,1849,945],{"class":296},[206,1851,1852],{"class":300}," 0.1",[206,1854,1847],{"class":230},[206,1856,1857],{"class":296},"%",[206,1859,972],{"class":230},[206,1861,319],{"class":300},[206,1863,512],{"class":296},[206,1865,1866],{"class":230}," math.pi)\n",[206,1868,1869,1871,1873],{"class":208,"line":355},[206,1870,1793],{"class":230},[206,1872,505],{"class":453},[206,1874,1875],{"class":230},"(angle, i)\n",[206,1877,1878],{"class":208,"line":373},[206,1879,1742],{"emptyLinePlaceholder":1328},[206,1881,1882],{"class":208,"line":392},[206,1883,1884],{"class":217},"# Layer 3: Linear entanglement chain — correlates neighboring qubits\n",[206,1886,1887,1889,1891,1893,1895,1897,1899],{"class":208,"line":407},[206,1888,659],{"class":226},[206,1890,1777],{"class":230},[206,1892,665],{"class":226},[206,1894,1782],{"class":296},[206,1896,457],{"class":230},[206,1898,444],{"class":300},[206,1900,470],{"class":230},[206,1902,1903,1905,1908,1911,1913,1915],{"class":208,"line":422},[206,1904,1793],{"class":230},[206,1906,1907],{"class":453},"cx",[206,1909,1910],{"class":230},"(i, i ",[206,1912,1841],{"class":296},[206,1914,1844],{"class":300},[206,1916,494],{"class":230},[12,1918,1919,1920,1923],{},"The prepare step is that ",[203,1921,1922],{},"seed",". The listing's comment says each plant's seed comes from its ID hash, and the seed sets every rotation angle in the circuit.",[12,1925,1926],{},"The listing's own header says the circuit's layers create a \"quantum fingerprint\" that determines a plant's glyph pattern, colour palette, growth rate and opacity. The decode step that turns the fingerprint into those traits lives in the garden's app, outside the eighty lines you are looking at. Five qubits give thirty-two possible outcomes, and each plant's traits come from one of them. The app draws that outcome from a pool of results computed in advance, which lesson 4 comes back to.",[12,1928,1121,1929,1127,1933,1935,1936,1166,1938,1940,1941,1174],{},[37,1930,1932],{"href":1931},"https:\u002F\u002Fqollab.xyz\u002Fu\u002FAmberPincar\u002Fquantum-garden","the project",[30,1934,1161],{},", and pick ",[30,1937,1165],{},[30,1939,1169],{}," in the Run Experiment dialog, then press ",[30,1942,1173],{},[12,1944,1945,1946,1948,1949,1951,1952,1955],{},"The ",[30,1947,1165],{}," row under ",[30,1950,1169],{}," is IonQ's simulator with a noise model of the Aria 1 machine, and it is free. The same name appears again further down under ",[30,1953,1954],{},"Quantum Computer",", which is the real machine and costs credits. Every run we pressed for this course used a simulator.",[12,1957,1958],{},"The first press takes a while, because the browser loads Python and Qiskit before anything runs. Ours took over a minute.",[12,1960,1961],{},"In our run on 22 September 2026 the console ended like this:",[197,1963,1966],{"className":1964,"code":1965,"language":1103,"meta":193},[1101],"Job status is JobStatus.DONE\nCounts for 100 shots: {'00001': 13, '00011': 15, '01001': 7, '01101': 24, '11101': 10}\n",[203,1967,1965],{"__ignoreMap":193},[12,1969,1970,1971,1974],{},"Only the ",[203,1972,1973],{},"Counts"," line carries a result back from IonQ. The counts on that line add up to 69 of the 100 shots.",[1110,1976,1978,1982,2012],{"check":1977},"your console shows a 'Counts for 100 shots:' line, and you can say which line of the listing produced it.",[23,1979,1981],{"id":1980},"assignment-find-the-boundary-in-a-project-you-did-not-write","Assignment: find the boundary in a project you did not write",[989,1983,1984,1990,2000,2003,2006,2009],{},[993,1985,1121,1986,1174],{},[37,1987,1988],{"href":1931},[203,1989,1719],{},[993,1991,1158,1992,1162,1994,1166,1996,1170,1998,1174],{},[30,1993,1161],{},[30,1995,1165],{},[30,1997,1169],{},[30,1999,1173],{},[993,2001,2002],{},"Wait for the console to finish. The first press is slow.",[993,2004,2005],{},"In the printed output, find the one line that came back across the boundary.",[993,2007,2008],{},"In the listing, find the single line that sends the circuit across the boundary.",[993,2010,2011],{},"Find the line that decides what the circuit is, and read what it is built from.",[1179,2013,2014,2027,2041,2048],{"label":1181},[12,2015,1945,2016,2019,2020,2023,2024,2026],{},[203,2017,2018],{},"Counts for 100 shots:"," line is the only result that came through the boundary. The ",[203,2021,2022],{},"Job status"," lines above the ",[203,2025,1973],{}," line are the script polling for that result, and the drawn circuit above those was printed by your browser before anything ran.",[12,2028,2029,2032,2033,2036,2037,2040],{},[203,2030,2031],{},"job = backend.run(circuit, shots=shots)",", inside ",[203,2034,2035],{},"main",", is the line that crosses, and the only place ",[203,2038,2039],{},"backend"," is used.",[12,2042,2043,2044,2047],{},"The circuit is built from ",[203,2045,2046],{},"seed = 42",". Every angle in the listing is computed from the seed and the qubit's index, so the seed alone sets which circuit runs; the listing draws no random numbers.",[12,2049,2050],{},"Your tally will not match ours, and a second press will give a different tally again.",[23,2052,1294],{"id":1293},[12,2054,2055,2056,2058],{},"In the Qollab listing of each of the five projects, a ",[203,2057,1430],{}," call hands the circuit to a backend, and the result comes back across that call as ordinary data. To read a quantum application you did not write, find that call first, then read what the program feeds into it and what it makes of the result.",[12,2060,2061],{},"Lesson 2 presses Quantum Garden again and shows where the 31 shots missing from its tally went.",[1299,2063,2064],{},"html pre.shiki code .sn6KH, html code.shiki .sn6KH{--shiki-default:#ABB2BF}html pre.shiki code .sjrmR, html code.shiki .sjrmR{--shiki-default:#56B6C2}html pre.shiki code .sVbv2, html code.shiki .sVbv2{--shiki-default:#61AFEF}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 .seHd6, html code.shiki .seHd6{--shiki-default:#C678DD}html pre.shiki code .sV9Aq, html code.shiki .sV9Aq{--shiki-default:#7F848E;--shiki-default-font-style:italic}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);}",{"title":193,"searchDepth":221,"depth":221,"links":2066},[2067,2068,2073,2074,2075],{"id":1377,"depth":221,"text":1378},{"id":1550,"depth":221,"text":1551,"children":2069},[2070,2071,2072],{"id":1598,"depth":240,"text":1565},{"id":1622,"depth":240,"text":1573},{"id":1656,"depth":240,"text":1581},{"id":1685,"depth":221,"text":1686},{"id":1980,"depth":221,"text":1981},{"id":1293,"depth":221,"text":1294},[1312,1313,1314,1345],[],{"username":7,"name":1317,"role":1318,"avatar":1319},"A risk pipeline, a music studio, a market tool, an artwork and a garden each call a quantum circuit from ordinary code.","A quantum circuit is a component your program calls, and a risk pipeline, a music studio, a market tool, an artwork and a garden each show where that call sits.",{},{"slug":2083,"title":2084,"desc":2085},"\u002Fblog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fwhat-crosses-the-boundary","What crosses the boundary","A quantum computer sends its results back as a tally, and a program that needs the exact state simulates the circuit instead.","\u002Fblog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fwhere-the-circuit-sits",[],{"title":1345,"description":2080},"blog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fwhere-the-circuit-sits",[],"kjGGywxJozASb7jEkYZfiwgGqxVpdm5Xgg_DPt-6Kyc",{"id":2093,"title":2084,"authors":2094,"body":2095,"breadcrumb":3178,"builders":3179,"byline":3180,"category":1320,"categoryName":1320,"challenge":1320,"courseAuthor":1320,"courseLead":1320,"dek":2085,"description":3181,"draft":1323,"extension":1324,"eyebrow":1320,"featured":1323,"finish":1320,"fork":1320,"group":1320,"groupName":1320,"hero":1320,"heroAlt":1320,"heroCta":1320,"heroImage":1320,"homepageFeatured":1323,"kind":1326,"lessonCount":280,"meta":3182,"navigation":1328,"newsItems":1320,"next":3183,"ogImage":1320,"order":221,"outcomes":1320,"path":2083,"prerequisite":1320,"prerequisiteLinks":1320,"publishDate":1334,"readingTime":1320,"related":3187,"relatedProjects":1320,"section":1320,"seo":3188,"stem":3189,"tags":3190,"track":1339,"trackName":1314,"__hash__":3191},"blog\u002Fblog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fwhat-crosses-the-boundary.md",[7],{"type":9,"value":2096,"toc":3168},[2097,2103,2110,2116,2120,2123,2126,2129,2135,2140,2144,2158,2795,2800,2806,2809,2913,2917,2923,2934,2941,2948,2952,2978,2981,3032,3036,3042,3048,3059,3064,3067,3083,3086,3157,3159,3162,3165],[12,2098,2099,2100,2102],{},"A tally is the only result a quantum computer sends back across the boundary: the number of shots that read each bitstring. In lesson 1 you pressed Quantum Garden on IonQ's Aria 1 simulator, and Garden printed its counts on the ",[203,2101,2018],{}," line. Our run on 22 September 2026 printed counts that added up to 69 of the 100 shots.",[12,2104,2105,2106,2109],{},"Musiq, Quantum Regime Radar and Quantum Butterfly Field, from lesson 1, use more than a tally. The three projects read exact amplitudes, phases, purities or overlaps, which come from a circuit's exact state, its ",[30,2107,2108],{},"statevector",". Programs get a statevector only by simulating the circuit, so the parts of an application that need one run on a simulator.",[12,2111,2112,2113,2115],{},"You read one circuit both ways in the lesson's listing, as a statevector and as a tally, and moving a phase shows which reading changes. At the end you press Quantum Garden twice and work out why neither ",[203,2114,1973],{}," line adds up to 100 shots.",[23,2117,2119],{"id":2118},"why-hardware-cannot-hand-you-a-statevector","Why hardware cannot hand you a statevector",[12,2121,2122],{},"A physical quantum state does not expose its amplitudes. The only way to learn anything from one is to measure it, and measuring returns a single bitstring and changes the state into the one you just read. Run the same circuit again and you get another single bitstring; a thousand runs give a tally of bitstrings that estimates the distribution.",[12,2124,2125],{},"A simulator holds the amplitudes in memory as ordinary floating-point numbers, so it can hand them to you directly, phases included, without measuring anything.",[12,2127,2128],{},"Better hardware will not add amplitudes to the output, because the limit comes from measurement itself: reading a physical qubit returns one outcome, however good the qubit is.",[12,2130,2131,2134],{},[30,2132,2133],{},"If your application needs amplitudes or phases, it runs on a simulator",", which caps how many qubits you can use, because holding the state of n qubits takes 2ⁿ numbers. If your application can work from a distribution, it can run on hardware.",[16,2136],{"alt":2137,"caption":2138,"no":20,"src":2139},"Two panels. On the left, hardware: the circuit is rebuilt for every shot, each measurement yields one bitstring, and repeating 1,000 times gives a tally, labelled probabilities estimated and phase absent. On the right, a simulator: it holds an array of 2 to the n complex amplitudes, and can either hand that array over directly or sample it to imitate hardware and produce a tally, labelled amplitudes and phases available.","A simulator can hand over the amplitudes it holds, or sample them to imitate hardware.","\u002F_content\u002Fimages\u002Freal-app\u002Ftwo-observation-paths.svg",[23,2141,2143],{"id":2142},"read-one-circuit-both-ways","Read one circuit both ways",[12,2145,2146,2147,2150,2151,2154,2155,2157],{},"The circuit in this listing is a Hadamard followed by an ",[203,2148,2149],{},"rz"," that puts a phase on one of the two paths. The listing reads the circuit both ways: ",[203,2152,2153],{},"Statevector"," asks the simulator for the amplitudes, which costs no shots and files no job, and ",[203,2156,1430],{}," samples the same circuit a thousand times.",[190,2159,2162],{"name":2160,"no-picker":193,"run-href":2161,"tag":195},"observe.py","\u002Fu\u002Fqollab\u002Flearn-app-observe",[197,2163,2165],{"className":199,"code":2164,"language":201,"meta":193,"style":193},"# 'backend' already exists when this runs: it is whatever you pick in the Run Experiment dialog.\nfrom math import pi\nfrom qiskit import QuantumCircuit\nfrom qiskit.quantum_info import Statevector\nfrom qiskit.providers.jobstatus import JobStatus\nimport time\n\nshots = 1000\nphi = 0.0\n\n\ndef build(measured):\n    qc = QuantumCircuit(1, 1)\n    qc.h(0)\n    qc.rz(phi, 0)\n    if measured:\n        qc.measure(0, 0)\n    return qc\n\n\nsv = Statevector(build(measured=False))\namps = [complex(a) for a in sv.data]\nprint(f\"statevector: |0> {amps[0]:+.3f}   |1> {amps[1]:+.3f}\")\nprint(f\"from it:     P(0)={abs(amps[0])**2:.3f}  P(1)={abs(amps[1])**2:.3f}\")\n\njob = backend.run(build(measured=True), shots=shots)\nwhile job.status() not in (JobStatus.DONE, JobStatus.ERROR, JobStatus.CANCELLED):\n    time.sleep(5)\n\ncounts = job.result().get_counts()\nprint(f\"counts:      {counts}\")\nz = counts.get(\"0\", 0)\nprint(f\"from them:   P(0)={z \u002F shots:.3f}  P(1)={(shots - z) \u002F shots:.3f}\")\n",[203,2166,2167,2173,2186,2198,2212,2224,2232,2238,2248,2260,2266,2272,2288,2308,2322,2337,2347,2366,2374,2380,2386,2415,2443,2490,2550,2556,2590,2620,2634,2640,2658,2681,2707,2758],{"__ignoreMap":193},[206,2168,2169,2171],{"class":208,"line":209},[206,2170,214],{"class":212,"aria-hidden":213},[206,2172,218],{"class":217},[206,2174,2175,2177,2179,2181,2183],{"class":208,"line":221},[206,2176,214],{"class":212,"aria-hidden":213},[206,2178,227],{"class":226},[206,2180,231],{"class":230},[206,2182,234],{"class":226},[206,2184,2185],{"class":230}," pi\n",[206,2187,2188,2190,2192,2194,2196],{"class":208,"line":240},[206,2189,214],{"class":212,"aria-hidden":213},[206,2191,227],{"class":226},[206,2193,247],{"class":230},[206,2195,234],{"class":226},[206,2197,252],{"class":230},[206,2199,2200,2202,2204,2207,2209],{"class":208,"line":255},[206,2201,214],{"class":212,"aria-hidden":213},[206,2203,227],{"class":226},[206,2205,2206],{"class":230}," qiskit.quantum_info ",[206,2208,234],{"class":226},[206,2210,2211],{"class":230}," Statevector\n",[206,2213,2214,2216,2218,2220,2222],{"class":208,"line":270},[206,2215,214],{"class":212,"aria-hidden":213},[206,2217,227],{"class":226},[206,2219,262],{"class":230},[206,2221,234],{"class":226},[206,2223,267],{"class":230},[206,2225,2226,2228,2230],{"class":208,"line":280},[206,2227,214],{"class":212,"aria-hidden":213},[206,2229,234],{"class":226},[206,2231,277],{"class":230},[206,2233,2234,2236],{"class":208,"line":288},[206,2235,214],{"class":212,"aria-hidden":213},[206,2237,285],{},[206,2239,2240,2242,2244,2246],{"class":208,"line":305},[206,2241,214],{"class":212,"aria-hidden":213},[206,2243,293],{"class":230},[206,2245,297],{"class":296},[206,2247,301],{"class":300},[206,2249,2250,2252,2255,2257],{"class":208,"data-cue":304,"line":320},[206,2251,304],{"class":308},[206,2253,2254],{"class":230},"phi ",[206,2256,297],{"class":296},[206,2258,2259],{"class":300}," 0.0\n",[206,2261,2262,2264],{"class":208,"line":333},[206,2263,214],{"class":212,"aria-hidden":213},[206,2265,285],{},[206,2267,2268,2270],{"class":208,"line":341},[206,2269,214],{"class":212,"aria-hidden":213},[206,2271,285],{},[206,2273,2274,2276,2278,2281,2283,2286],{"class":208,"data-cue":319,"line":355},[206,2275,319],{"class":308},[206,2277,450],{"class":226},[206,2279,2280],{"class":453}," build",[206,2282,457],{"class":230},[206,2284,2285],{"class":460},"measured",[206,2287,470],{"class":230},[206,2289,2290,2292,2294,2296,2298,2300,2302,2304,2306],{"class":208,"line":373},[206,2291,214],{"class":212,"aria-hidden":213},[206,2293,478],{"class":230},[206,2295,297],{"class":296},[206,2297,483],{"class":453},[206,2299,457],{"class":230},[206,2301,304],{"class":300},[206,2303,464],{"class":230},[206,2305,304],{"class":300},[206,2307,494],{"class":230},[206,2309,2310,2312,2314,2316,2318,2320],{"class":208,"line":392},[206,2311,214],{"class":212,"aria-hidden":213},[206,2313,502],{"class":230},[206,2315,1643],{"class":453},[206,2317,457],{"class":230},[206,2319,526],{"class":300},[206,2321,494],{"class":230},[206,2323,2324,2326,2328,2330,2333,2335],{"class":208,"line":407},[206,2325,214],{"class":212,"aria-hidden":213},[206,2327,502],{"class":230},[206,2329,2149],{"class":453},[206,2331,2332],{"class":230},"(phi, ",[206,2334,526],{"class":300},[206,2336,494],{"class":230},[206,2338,2339,2341,2344],{"class":208,"line":422},[206,2340,214],{"class":212,"aria-hidden":213},[206,2342,2343],{"class":226},"    if",[206,2345,2346],{"class":230}," measured:\n",[206,2348,2349,2351,2354,2356,2358,2360,2362,2364],{"class":208,"line":430},[206,2350,214],{"class":212,"aria-hidden":213},[206,2352,2353],{"class":230},"        qc.",[206,2355,566],{"class":453},[206,2357,457],{"class":230},[206,2359,526],{"class":300},[206,2361,464],{"class":230},[206,2363,526],{"class":300},[206,2365,494],{"class":230},[206,2367,2368,2370,2372],{"class":208,"line":437},[206,2369,214],{"class":212,"aria-hidden":213},[206,2371,595],{"class":226},[206,2373,598],{"class":230},[206,2375,2376,2378],{"class":208,"line":445},[206,2377,214],{"class":212,"aria-hidden":213},[206,2379,285],{},[206,2381,2382,2384],{"class":208,"line":473},[206,2383,214],{"class":212,"aria-hidden":213},[206,2385,285],{},[206,2387,2388,2390,2393,2395,2398,2400,2403,2405,2407,2409,2412],{"class":208,"data-cue":340,"line":497},[206,2389,340],{"class":308},[206,2391,2392],{"class":230},"sv ",[206,2394,297],{"class":296},[206,2396,2397],{"class":453}," Statevector",[206,2399,457],{"class":230},[206,2401,2402],{"class":453},"build",[206,2404,457],{"class":230},[206,2406,2285],{"class":718},[206,2408,297],{"class":296},[206,2410,2411],{"class":300},"False",[206,2413,2414],{"class":230},"))\n",[206,2416,2417,2419,2422,2424,2427,2430,2433,2435,2438,2440],{"class":208,"line":531},[206,2418,214],{"class":212,"aria-hidden":213},[206,2420,2421],{"class":230},"amps ",[206,2423,297],{"class":296},[206,2425,2426],{"class":230}," [",[206,2428,2429],{"class":296},"complex",[206,2431,2432],{"class":230},"(a) ",[206,2434,659],{"class":226},[206,2436,2437],{"class":230}," a ",[206,2439,665],{"class":226},[206,2441,2442],{"class":230}," sv.data]\n",[206,2444,2445,2447,2449,2451,2453,2456,2458,2461,2463,2466,2469,2471,2474,2476,2478,2480,2482,2484,2486,2488],{"class":208,"line":559},[206,2446,214],{"class":212,"aria-hidden":213},[206,2448,822],{"class":296},[206,2450,457],{"class":230},[206,2452,872],{"class":226},[206,2454,2455],{"class":360},"\"statevector: |0> ",[206,2457,878],{"class":300},[206,2459,2460],{"class":230},"amps[",[206,2462,526],{"class":300},[206,2464,2465],{"class":230},"]",[206,2467,2468],{"class":226},":+.3f",[206,2470,887],{"class":300},[206,2472,2473],{"class":360},"   |1> ",[206,2475,878],{"class":300},[206,2477,2460],{"class":230},[206,2479,304],{"class":300},[206,2481,2465],{"class":230},[206,2483,2468],{"class":226},[206,2485,887],{"class":300},[206,2487,875],{"class":360},[206,2489,494],{"class":230},[206,2491,2492,2494,2496,2498,2500,2503,2505,2508,2511,2513,2516,2519,2521,2523,2525,2528,2530,2532,2534,2536,2538,2540,2542,2544,2546,2548],{"class":208,"line":590},[206,2493,214],{"class":212,"aria-hidden":213},[206,2495,822],{"class":296},[206,2497,457],{"class":230},[206,2499,872],{"class":226},[206,2501,2502],{"class":360},"\"from it:     P(0)=",[206,2504,878],{"class":300},[206,2506,2507],{"class":296},"abs",[206,2509,2510],{"class":230},"(amps[",[206,2512,526],{"class":300},[206,2514,2515],{"class":230},"])",[206,2517,2518],{"class":296},"**",[206,2520,319],{"class":300},[206,2522,895],{"class":226},[206,2524,887],{"class":300},[206,2526,2527],{"class":360},"  P(1)=",[206,2529,878],{"class":300},[206,2531,2507],{"class":296},[206,2533,2510],{"class":230},[206,2535,304],{"class":300},[206,2537,2515],{"class":230},[206,2539,2518],{"class":296},[206,2541,319],{"class":300},[206,2543,895],{"class":226},[206,2545,887],{"class":300},[206,2547,875],{"class":360},[206,2549,494],{"class":230},[206,2551,2552,2554],{"class":208,"line":601},[206,2553,214],{"class":212,"aria-hidden":213},[206,2555,285],{},[206,2557,2558,2560,2562,2564,2566,2568,2570,2572,2574,2576,2578,2581,2584,2586,2588],{"class":208,"data-cue":444,"line":608},[206,2559,444],{"class":308},[206,2561,699],{"class":230},[206,2563,297],{"class":296},[206,2565,704],{"class":230},[206,2567,707],{"class":453},[206,2569,457],{"class":230},[206,2571,2402],{"class":453},[206,2573,457],{"class":230},[206,2575,2285],{"class":718},[206,2577,297],{"class":296},[206,2579,2580],{"class":300},"True",[206,2582,2583],{"class":230},"), ",[206,2585,719],{"class":718},[206,2587,297],{"class":296},[206,2589,724],{"class":230},[206,2591,2592,2594,2596,2598,2600,2602,2604,2606,2608,2610,2612,2614,2616,2618],{"class":208,"line":616},[206,2593,214],{"class":212,"aria-hidden":213},[206,2595,732],{"class":226},[206,2597,735],{"class":230},[206,2599,738],{"class":453},[206,2601,741],{"class":230},[206,2603,744],{"class":226},[206,2605,747],{"class":226},[206,2607,750],{"class":230},[206,2609,753],{"class":300},[206,2611,756],{"class":230},[206,2613,759],{"class":300},[206,2615,756],{"class":230},[206,2617,764],{"class":300},[206,2619,470],{"class":230},[206,2621,2622,2624,2626,2628,2630,2632],{"class":208,"line":638},[206,2623,214],{"class":212,"aria-hidden":213},[206,2625,774],{"class":230},[206,2627,777],{"class":453},[206,2629,457],{"class":230},[206,2631,615],{"class":300},[206,2633,494],{"class":230},[206,2635,2636,2638],{"class":208,"line":680},[206,2637,214],{"class":212,"aria-hidden":213},[206,2639,285],{},[206,2641,2642,2644,2646,2648,2650,2652,2654,2656],{"class":208,"data-cue":615,"line":687},[206,2643,615],{"class":308},[206,2645,798],{"class":230},[206,2647,297],{"class":296},[206,2649,735],{"class":230},[206,2651,805],{"class":453},[206,2653,808],{"class":230},[206,2655,811],{"class":453},[206,2657,814],{"class":230},[206,2659,2660,2662,2664,2666,2668,2671,2673,2675,2677,2679],{"class":208,"line":694},[206,2661,214],{"class":212,"aria-hidden":213},[206,2663,822],{"class":296},[206,2665,457],{"class":230},[206,2667,872],{"class":226},[206,2669,2670],{"class":360},"\"counts:      ",[206,2672,878],{"class":300},[206,2674,628],{"class":230},[206,2676,887],{"class":300},[206,2678,875],{"class":360},[206,2680,494],{"class":230},[206,2682,2683,2685,2688,2690,2693,2696,2698,2701,2703,2705],{"class":208,"line":727},[206,2684,214],{"class":212,"aria-hidden":213},[206,2686,2687],{"class":230},"z ",[206,2689,297],{"class":296},[206,2691,2692],{"class":230}," counts.",[206,2694,2695],{"class":453},"get",[206,2697,457],{"class":230},[206,2699,2700],{"class":360},"\"0\"",[206,2702,464],{"class":230},[206,2704,526],{"class":300},[206,2706,494],{"class":230},[206,2708,2709,2711,2713,2715,2717,2720,2722,2724,2726,2729,2731,2733,2735,2737,2740,2743,2746,2748,2750,2752,2754,2756],{"class":208,"line":769},[206,2710,214],{"class":212,"aria-hidden":213},[206,2712,822],{"class":296},[206,2714,457],{"class":230},[206,2716,872],{"class":226},[206,2718,2719],{"class":360},"\"from them:   P(0)=",[206,2721,878],{"class":300},[206,2723,2687],{"class":230},[206,2725,653],{"class":296},[206,2727,2728],{"class":230}," shots",[206,2730,895],{"class":226},[206,2732,887],{"class":300},[206,2734,2527],{"class":360},[206,2736,878],{"class":300},[206,2738,2739],{"class":230},"(shots ",[206,2741,2742],{"class":296},"-",[206,2744,2745],{"class":230}," z) ",[206,2747,653],{"class":296},[206,2749,2728],{"class":230},[206,2751,895],{"class":226},[206,2753,887],{"class":300},[206,2755,875],{"class":360},[206,2757,494],{"class":230},[989,2759,2760,2767,2774,2781,2788],{"class":991},[993,2761,2762,2764],{"data-cue":304},[206,2763,304],{"class":308},[206,2765,2766],{"class":999},"the dial: 0 or pi. Change it and run again",[993,2768,2769,2771],{"data-cue":319},[206,2770,319],{"class":308},[206,2772,2773],{"class":999},"the same circuit, with or without the measurement",[993,2775,2776,2778],{"data-cue":340},[206,2777,340],{"class":308},[206,2779,2780],{"class":999},"the simulator hands over the numbers themselves",[993,2782,2783,2785],{"data-cue":444},[206,2784,444],{"class":308},[206,2786,2787],{"class":999},"the only job this run files",[993,2789,2790,2792],{"data-cue":615},[206,2791,615],{"class":308},[206,2793,2794],{"class":999},"the same circuit, observed by sampling",[12,2796,1090,2797,1097],{},[203,2798,2799],{},"phi = 0",[197,2801,2804],{"className":2802,"code":2803,"language":1103,"meta":193},[1101],"statevector: |0> +0.707+0.000j   |1> +0.707+0.000j\nfrom it:     P(0)=0.500  P(1)=0.500\ncounts:      {'0': 478, '1': 522}\nfrom them:   P(0)=0.478  P(1)=0.522\n",[203,2805,2803],{"__ignoreMap":193},[12,2807,2808],{},"The statevector gives exactly 0.500, computed from the amplitudes the simulator holds. The tally gives 0.478, counted from a thousand samples of the same circuit in the same press.",[1110,2810,2812,2816,2868],{"check":2811},"your two statevector lines differ, and both counts lines hold '0' and '1' at roughly half the shots each.",[23,2813,2815],{"id":2814},"assignment-move-the-phase-and-see-which-reading-changes","Assignment: move the phase and see which reading changes",[989,2817,2818,2829,2840,2851,2857,2860,2863],{},[993,2819,1121,2820,1127,2825,1131,2827,1135],{},[37,2821,2823],{"href":2822},"https:\u002F\u002Fqollab.xyz\u002Fu\u002Fqollab\u002Flearn-app-observe",[203,2824,2161],{},[30,2826,1130],{},[30,2828,1134],{},[993,2830,2831,2832,1162,2834,1166,2836,1170,2838,1174],{},"In your fork, press ",[30,2833,1161],{},[30,2835,1165],{},[30,2837,1169],{},[30,2839,1173],{},[993,2841,2842,2843,2846,2847,2850],{},"Write down the ",[203,2844,2845],{},"statevector:"," line and the ",[203,2848,2849],{},"counts:"," line.",[993,2852,2853,2854,1174],{},"Change line 9 to ",[203,2855,2856],{},"phi = pi",[993,2858,2859],{},"Predict whether the statevector line will change.",[993,2861,2862],{},"Predict whether the measured shares will change.",[993,2864,1158,2865,2867],{},[30,2866,1173],{}," again, and compare both pairs of lines.",[1179,2869,2870,2873,2876,2882,2910],{"label":1181},[12,2871,2872],{},"The statevector changes. The ideal shares stay at 0.500 and 0.500, and the sampled shares move a little from press to press, as any tally does.",[12,2874,2875],{},"Our two presses on 22 September 2026:",[197,2877,2880],{"className":2878,"code":2879,"language":1103,"meta":193},[1101],"phi = 0    statevector: |0> +0.707+0.000j   |1> +0.707+0.000j    counts: {'0': 478, '1': 522}\nphi = pi   statevector: |0> +0.000-0.707j   |1> +0.000+0.707j    counts: {'0': 506, '1': 494}\n",[203,2881,2879],{"__ignoreMap":193},[12,2883,2884,2887,2888,2891,2892,2895,2896,1041,2899,2902,2903,2905,2906,2909],{},[203,2885,2886],{},"rz(phi)"," puts a relative phase of ",[203,2889,2890],{},"phi"," between the two amplitudes. At ",[203,2893,2894],{},"pi"," the relative sign between the two amplitudes reverses, and they read ",[203,2897,2898],{},"-0.707j",[203,2900,2901],{},"+0.707j",". A measurement in the 0\u002F1 basis, the one ",[203,2904,566],{}," reads in, uses each amplitude's squared magnitude, ",[203,2907,2908],{},"|a|²",", and a magnitude carries no phase, so both ideal shares stay at one half.",[12,2911,2912],{},"These counts cannot tell the two states apart.",[23,2914,2916],{"id":2915},"which-reading-musiq-regime-radar-and-butterfly-field-chose","Which reading Musiq, Regime Radar and Butterfly Field chose",[2918,2919,2920],"aside-note",{},[12,2921,2922],{},"You do not need to run these three projects; the one this lesson presses is Quantum Garden, from lesson 1.",[12,2924,2925,2929,2930,1174],{},[30,2926,2927],{},[37,2928,1565],{"href":1564}," needs both, and its mapping table says so. The measurement probability sets how strong each frequency component is, which is a counts quantity. The statevector phase sets oscillator phase and interference. The statevector amplitude sets loudness; a tally does carry the share whose square root is the amplitude's size, but not the amplitude's sign. No tally carries a phase as the circuit stands: two states with the same distribution and different phases give identical tallies, unless the circuit rotates the phase into the measured basis first, as the second Hadamard did in ",[37,2931,2933],{"href":2932},"\u002Flearn\u002Fprogramming-your-first-quantum-circuits\u002Finterference","Course 2's interference lesson",[12,2935,2936,2940],{},[30,2937,2938],{},[37,2939,1573],{"href":60}," ships three scoring paths in one file. An exact statevector overlap ranks all five regimes offline with no shots. A sampler path runs the same comparison on simulation or hardware. The IonQ path transpiles to the native gate set. The Radar uses the exact path to produce the ranking and spends the single hardware job verifying one row of it, with shot-noise error bars on the measured value.",[12,2942,2943,2947],{},[30,2944,2945],{},[37,2946,1581],{"href":71}," splits its work into two tracks. An exact statevector simulation runs live on every visit in a serverless function and drives the animation, because per-layer purities and pairwise entanglement are state quantities. The damage-and-healing fidelities, which measure how completely the damaged butterfly's state is recovered, come from recorded IonQ Forte runs, replayed from a library.",[23,2949,2951],{"id":2950},"four-things-a-tally-does-that-a-return-value-does-not","Four things a tally does that a return value does not",[1556,2953,2954,2960,2966,2972],{},[993,2955,2956,2959],{},[30,2957,2958],{},"A tally changes almost every run."," Even the same circuit on the same backend gives a different tally on the next press, so a test that asserts an exact tally will fail intermittently.",[993,2961,2962,2965],{},[30,2963,2964],{},"Some shots read the wrong answer, and nothing marks them."," On real hardware and on a noise-model simulator, the wrong shots sit in your tally alongside the right ones.",[993,2967,2968,2971],{},[30,2969,2970],{},"Nothing throws when the answer is wrong."," A circuit with a bug in it returns a well-formed tally, and so does a circuit that ran on a degraded machine. Your decode step turns either into a number, and your application uses it. You have to write any check on the tally yourself.",[993,2973,2974,2977],{},[30,2975,2976],{},"A tally costs shots, and more shots give more precision."," The uncertainty on a measured share is the standard error, and it shrinks with the square root of the number of shots. At 1,000 shots a measured share lands within about ±0.028 of a true share of 0.300, 95% of the time. To halve the window you run four times as many shots.",[12,2979,2980],{},"Each row of the table quadruples the shots and halves the window:",[2982,2983,2984,2996],"table",{},[2985,2986,2987],"thead",{},[2988,2989,2990,2993],"tr",{},[2991,2992,719],"th",{},[2991,2994,2995],{},"95% window on a 0.300 share",[2997,2998,2999,3008,3016,3024],"tbody",{},[2988,3000,3001,3005],{},[3002,3003,3004],"td",{},"250",[3002,3006,3007],{},"±0.057",[2988,3009,3010,3013],{},[3002,3011,3012],{},"1,000",[3002,3014,3015],{},"±0.028",[2988,3017,3018,3021],{},[3002,3019,3020],{},"4,000",[3002,3022,3023],{},"±0.014",[2988,3025,3026,3029],{},[3002,3027,3028],{},"16,000",[3002,3030,3031],{},"±0.007",[23,3033,3035],{"id":3034},"the-same-circuit-pressed-twice","The same circuit, pressed twice",[12,3037,3038,3039,3041],{},"Quantum Garden hard-codes ",[203,3040,2046],{},", so its circuit is identical on every press. We pressed the project twice on the IonQ Aria 1 simulator, IonQ's simulator with the Aria 1 noise model, on 22 September 2026, and changed nothing in between.",[197,3043,3046],{"className":3044,"code":3045,"language":1103,"meta":193},[1101],"press 1:  {'00001': 13, '00011': 15, '01001': 7, '01101': 24, '11101': 10}\npress 2:  {'00001': 16, '00011': 17, '00101': 8, '01001': 7, '01101': 24}\n",[203,3047,3045],{"__ignoreMap":193},[12,3049,3050,3051,3054,3055,3058],{},"Two of the four shared outcomes changed count, 13 to 16 and 15 to 17, and two stayed at 7 and 24. The two presses also do not agree on which outcomes exist: ",[203,3052,3053],{},"11101"," is in the first and absent from the second, and ",[203,3056,3057],{},"00101"," is in the second and absent from the first.",[16,3060],{"alt":3061,"caption":3062,"no":1589,"src":3063},"Two charts of the same circuit pressed twice at 100 shots, with a dashed cutoff at five shots. Press one reports 00001 at 13, 00011 at 15, 01001 at 7, 01101 at 24 and 11101 at 10, while 00101 is dashed and marked five or fewer. Press two reports 00001 at 16, 00011 at 17, 00101 at 8, 01001 at 7 and 01101 at 24, while 11101 is dashed and marked five or fewer. Each press ran 100 shots and printed 69 and 72.","The circuit's distribution did not gain or lose outcomes between presses. Sampling put two outcomes on the other side of the decode threshold, and the printed outcomes changed with them.","\u002F_content\u002Fimages\u002Freal-app\u002Fgarden-threshold.svg",[12,3065,3066],{},"Neither line adds up to 100: the first holds 69 shots and the second 72, so nearly a third of the data is missing from both.",[12,3068,3069,3070,3072,3073,1041,3076,3079,3080,3082],{},"The listing's own ",[203,3071,2035],{}," causes both differences: it takes ",[203,3074,3075],{},"excludeLowProbabilityValues=True",[203,3077,3078],{},"lowProbabilityThreshold=0.05",", then drops every outcome that got five shots or fewer. An outcome near the threshold clears the threshold in one press and misses in the next, so the outcome appears and disappears. The missing shots, 31 in the first press and 28 in the second, are the outcomes ",[203,3081,2035],{}," discarded.",[12,3084,3085],{},"The filter is a decode-step decision, made for a good reason: at 100 shots across 32 possible outcomes, the rare ones are indistinguishable from noise, so a plant built from them would reflect noise. The filter does not show in the output, though, and it causes the two presses to disagree.",[1110,3087,3089,3093,3129],{"check":3088},"you have two different 'Counts for 100 shots:' lines from the same unchanged project, and you can say why neither of them adds up to 100.",[23,3090,3092],{"id":3091},"assignment-press-the-same-circuit-twice","Assignment: press the same circuit twice",[989,3094,3095,3101,3111,3116,3123,3126],{},[993,3096,1121,3097,1174],{},[37,3098,3099],{"href":1931},[203,3100,1719],{},[993,3102,1158,3103,1162,3105,1166,3107,1170,3109,1174],{},[30,3104,1161],{},[30,3106,1165],{},[30,3108,1169],{},[30,3110,1173],{},[993,3112,2842,3113,3115],{},[203,3114,2018],{}," line exactly.",[993,3117,1158,3118,3120,3121,1174],{},[30,3119,1161],{}," again, choose the same backend, and press ",[30,3122,1173],{},[993,3124,3125],{},"Write down the second line, and add up the shots in each.",[993,3127,3128],{},"Work out why two presses of an unchanged circuit disagree about which outcomes exist.",[1179,3130,3131,3137,3143,3146],{"label":1181},[12,3132,3133,3134,3136],{},"Nothing changed between the presses. ",[203,3135,2046],{}," is in the listing, so the circuit is identical and both tallies are samples of one distribution.",[12,3138,3139,3140,3142],{},"The counts differ because a tally is a sample. The outcome list differs because ",[203,3141,2035],{}," drops anything with five shots or fewer out of 100, and an outcome near that threshold crosses it in one press and not the next.",[12,3144,3145],{},"Your shots will not add up to 100 for the same reason. Ours came to 69 and 72.",[12,3147,3148,3149,3151,3152,1041,3154,3156],{},"More shots make the two presses agree more closely, and changing the shot count needs a fork, because ",[203,3150,2035],{}," pins it at 100. Four times as many shots halve the window on every share. More shots do not make the outcomes under 5% appear, because the threshold is a share of the shots and rises with them, but they do make an outcome near the threshold less likely to cross it by chance, which is what made ",[203,3153,3053],{},[203,3155,3057],{}," appear in one press and not the other.",[23,3158,1294],{"id":1293},[12,3160,3161],{},"If your application can work from a distribution, it can run on hardware, because every backend returns a tally. Amplitudes and phases themselves come only from a simulator, which caps the qubit count. A tally is a sample that changes almost every run, and nothing in it marks a wrong shot, so your code has to check it.",[12,3163,3164],{},"Lesson 3 keeps the circuit behind three steps, so the rest of your program handles only ordinary values.",[1299,3166,3167],{},"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 .sjrmR, html code.shiki .sjrmR{--shiki-default:#56B6C2}html pre.shiki code .sVC51, html code.shiki .sVC51{--shiki-default:#D19A66}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 .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);}",{"title":193,"searchDepth":221,"depth":221,"links":3169},[3170,3171,3172,3173,3174,3175,3176,3177],{"id":2118,"depth":221,"text":2119},{"id":2142,"depth":221,"text":2143},{"id":2814,"depth":221,"text":2815},{"id":2915,"depth":221,"text":2916},{"id":2950,"depth":221,"text":2951},{"id":3034,"depth":221,"text":3035},{"id":3091,"depth":221,"text":3092},{"id":1293,"depth":221,"text":1294},[1312,1313,1314,2084],[],{"username":7,"name":1317,"role":1318,"avatar":1319},"A tally is the only result a quantum computer sends back across the boundary; a program that needs the exact amplitudes and phases simulates the circuit.",{},{"slug":3184,"title":3185,"desc":3186},"\u002Fblog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Finputs-in-result-out","Inputs in, a result out","Build the circuit from application data, run it, and decode the tally into a typed result.",[],{"title":2084,"description":3181},"blog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fwhat-crosses-the-boundary",[],"HUwW-1sySGSAOnLJkSCBap0lD74lTmAAl4HLiuSXKM8",{"id":3193,"title":3185,"authors":3194,"body":3195,"breadcrumb":4645,"builders":4646,"byline":4647,"category":1320,"categoryName":1320,"challenge":1320,"courseAuthor":1320,"courseLead":1320,"dek":3186,"description":4648,"draft":1323,"extension":1324,"eyebrow":1320,"featured":1323,"finish":1320,"fork":1320,"group":1320,"groupName":1320,"hero":1320,"heroAlt":1320,"heroCta":1320,"heroImage":1320,"homepageFeatured":1323,"kind":1326,"lessonCount":280,"meta":4649,"navigation":1328,"newsItems":1320,"next":4650,"ogImage":1320,"order":240,"outcomes":1320,"path":3184,"prerequisite":1320,"prerequisiteLinks":1320,"publishDate":1334,"readingTime":1320,"related":4654,"relatedProjects":1320,"section":1320,"seo":4655,"stem":4656,"tags":4657,"track":1339,"trackName":1314,"__hash__":4658},"blog\u002Fblog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Finputs-in-result-out.md",[7],{"type":9,"value":3196,"toc":4630},[3197,3200,3207,3210,3230,3234,3237,3240,3247,3255,3259,3262,3315,3329,3342,3346,3351,3934,3943,3956,3960,3967,3980,3983,3989,3992,3995,4009,4084,4090,4095,4162,4184,4191,4195,4201,4319,4336,4345,4409,4613,4615,4624,4627],[12,3198,3199],{},"Inputs go in as application data and a result comes back as a tally. Write the code between the two as three steps, and let no other part of your program touch a circuit.",[12,3201,3202,3203,3206],{},"Without the three steps, circuit code turns up all over your program. Angles get computed where the HTTP handler lives, ",[203,3204,3205],{},"counts.get(\"1\", 0)"," turns up in a template, and before long nobody can change the circuit without reading the whole application. With the three steps in place, the rest of your program calls one function and gets a dict back.",[12,3208,3209],{},"The three steps are:",[1556,3211,3212,3218,3224],{},[993,3213,3214,3217],{},[203,3215,3216],{},"build_circuit(p)"," takes an application value and returns a circuit. Nothing else in your program builds circuits.",[993,3219,3220,3221,3223],{},"the run submits the circuit and waits. The run is the only place ",[203,3222,2039],{}," appears.",[993,3225,3226,3229],{},[203,3227,3228],{},"decode(counts, n)"," takes the tally and returns something typed. Nothing else in your program reads raw counts.",[23,3231,3233],{"id":3232},"a-weighted-random-picker","A weighted random picker",[12,3235,3236],{},"The picker takes a number of draws and a probability, say a thousand draws at thirty percent, and returns how many came up rare. Loot boxes, playlist shuffles and A\u002FB assignments all work this way.",[12,3238,3239],{},"You are going to build the picker on a quantum computer, and lesson 5 measures whether that was worth doing.",[23,3241,3243,3244,3246],{"id":3242},"where-backend-comes-from","Where ",[203,3245,2039],{}," comes from",[12,3248,3249,3251,3252,3254],{},[203,3250,2039],{}," is the one name in the listing that is never declared: it already exists when your code runs, as a global handed to your script before its first line, and it is whatever you chose in the Run Experiment dialog. You never construct ",[203,3253,2039],{}," or name a machine in code, so you change where the circuit runs in the dialog.",[23,3256,3258],{"id":3257},"the-circuit","The circuit",[12,3260,3261],{},"The circuit is three lines:",[197,3263,3265],{"className":199,"code":3264,"language":201,"meta":193,"style":193},"qc = QuantumCircuit(1, 1)\nqc.ry(theta, 0)\nqc.measure(0, 0)\n",[203,3266,3267,3285,3299],{"__ignoreMap":193},[206,3268,3269,3271,3273,3275,3277,3279,3281,3283],{"class":208,"line":209},[206,3270,1446],{"class":230},[206,3272,297],{"class":296},[206,3274,483],{"class":453},[206,3276,457],{"class":230},[206,3278,304],{"class":300},[206,3280,464],{"class":230},[206,3282,304],{"class":300},[206,3284,494],{"class":230},[206,3286,3287,3290,3292,3295,3297],{"class":208,"line":221},[206,3288,3289],{"class":230},"qc.",[206,3291,505],{"class":453},[206,3293,3294],{"class":230},"(theta, ",[206,3296,526],{"class":300},[206,3298,494],{"class":230},[206,3300,3301,3303,3305,3307,3309,3311,3313],{"class":208,"line":240},[206,3302,3289],{"class":230},[206,3304,566],{"class":453},[206,3306,457],{"class":230},[206,3308,526],{"class":300},[206,3310,464],{"class":230},[206,3312,526],{"class":300},[206,3314,494],{"class":230},[12,3316,3317,3318,3323,3324,3328],{},"You met ",[37,3319,3321],{"href":3320},"\u002Flearn\u002Fdocs\u002Fry-gate",[203,3322,505],{}," in Course 2, where the lesson on ",[37,3325,3327],{"href":3326},"\u002Flearn\u002Fprogramming-your-first-quantum-circuits\u002Frotations","rotations"," showed that the angle sets how often the qubit reads 1. Your application data enters the circuit through that angle.",[12,3330,3331,3334,3335,3337,3338,3341],{},[203,3332,3333],{},"2 * asin(sqrt(p))"," is the angle that puts the probability of measuring 1 at exactly ",[203,3336,12],{},": at ",[203,3339,3340],{},"p = 0.3"," the qubit reads 1 three times in ten, on average.",[23,3343,3345],{"id":3344},"the-whole-listing","The whole listing",[16,3347],{"alt":3348,"caption":3349,"no":20,"src":3350},"A left-to-right trace. p_rare, a float, enters build_circuit, which converts it with two times arcsine of the square root of p into theta and returns an RY gate followed by a measurement. A shaded region marks the part that runs somewhere else: the run returns a Job, which returns counts as a dict of string to int. Those counts enter decode, which returns a dict of rare, common and share.","build_circuit converts the application value into a circuit before the run submits the circuit, and decode turns the tally back into ordinary values.","\u002F_content\u002Fimages\u002Freal-app\u002Ftyped-boundary-trace.svg",[190,3352,3354],{"name":3353,"no-picker":193,"run-href":1248,"tag":195},"picker.py",[197,3355,3357],{"className":199,"code":3356,"language":201,"meta":193,"style":193},"# 'backend' already exists when this runs: it is whatever you pick in the Run Experiment dialog.\nfrom math import asin, sqrt\nfrom qiskit import QuantumCircuit\nfrom qiskit.providers.jobstatus import JobStatus\nimport time\n\nshots = 1000\np_rare = 0.3\n\n\ndef build_circuit(p):\n    theta = 2 * asin(sqrt(p))        #   the angle whose RY puts P(1) at exactly p\n    qc = QuantumCircuit(1, 1)\n    qc.ry(theta, 0)\n    qc.measure(0, 0)\n    return qc\n\n\ndef decode(counts, n):\n    rare = counts.get(\"1\", 0)\n    return {\"rare\": rare, \"common\": n - rare, \"share\": rare \u002F n}\n\n\nqc = build_circuit(p_rare)\nprint(qc)\n\njob = backend.run(qc, shots=shots)\nwhile job.status() not in (JobStatus.DONE, JobStatus.ERROR, JobStatus.CANCELLED):\n    time.sleep(5)\n\ncounts = job.result().get_counts()\nprint(counts)\n\nresult = decode(counts, shots)\nprint(f\"opened {shots} boxes: {result['rare']} rare, {result['common']} common\")\nprint(f\"share rare: {result['share']:.3f}   asked for: {p_rare:.3f}\")\n",[203,3358,3359,3365,3377,3389,3401,3409,3415,3425,3437,3443,3449,3463,3489,3509,3523,3541,3549,3555,3561,3579,3603,3639,3645,3651,3664,3673,3679,3700,3730,3744,3750,3768,3776,3782,3797,3849,3890],{"__ignoreMap":193},[206,3360,3361,3363],{"class":208,"line":209},[206,3362,214],{"class":212,"aria-hidden":213},[206,3364,218],{"class":217},[206,3366,3367,3369,3371,3373,3375],{"class":208,"line":221},[206,3368,214],{"class":212,"aria-hidden":213},[206,3370,227],{"class":226},[206,3372,231],{"class":230},[206,3374,234],{"class":226},[206,3376,237],{"class":230},[206,3378,3379,3381,3383,3385,3387],{"class":208,"line":240},[206,3380,214],{"class":212,"aria-hidden":213},[206,3382,227],{"class":226},[206,3384,247],{"class":230},[206,3386,234],{"class":226},[206,3388,252],{"class":230},[206,3390,3391,3393,3395,3397,3399],{"class":208,"line":255},[206,3392,214],{"class":212,"aria-hidden":213},[206,3394,227],{"class":226},[206,3396,262],{"class":230},[206,3398,234],{"class":226},[206,3400,267],{"class":230},[206,3402,3403,3405,3407],{"class":208,"line":270},[206,3404,214],{"class":212,"aria-hidden":213},[206,3406,234],{"class":226},[206,3408,277],{"class":230},[206,3410,3411,3413],{"class":208,"line":280},[206,3412,214],{"class":212,"aria-hidden":213},[206,3414,285],{},[206,3416,3417,3419,3421,3423],{"class":208,"data-cue":304,"line":288},[206,3418,304],{"class":308},[206,3420,293],{"class":230},[206,3422,297],{"class":296},[206,3424,301],{"class":300},[206,3426,3427,3429,3432,3434],{"class":208,"data-cue":319,"line":305},[206,3428,319],{"class":308},[206,3430,3431],{"class":230},"p_rare ",[206,3433,297],{"class":296},[206,3435,3436],{"class":300}," 0.3\n",[206,3438,3439,3441],{"class":208,"line":320},[206,3440,214],{"class":212,"aria-hidden":213},[206,3442,285],{},[206,3444,3445,3447],{"class":208,"line":333},[206,3446,214],{"class":212,"aria-hidden":213},[206,3448,285],{},[206,3450,3451,3453,3455,3457,3459,3461],{"class":208,"data-cue":340,"line":341},[206,3452,340],{"class":308},[206,3454,450],{"class":226},[206,3456,454],{"class":453},[206,3458,457],{"class":230},[206,3460,12],{"class":460},[206,3462,470],{"class":230},[206,3464,3465,3467,3470,3472,3475,3477,3479,3481,3483,3486],{"class":208,"line":355},[206,3466,214],{"class":212,"aria-hidden":213},[206,3468,3469],{"class":230},"    theta ",[206,3471,297],{"class":296},[206,3473,3474],{"class":300}," 2",[206,3476,512],{"class":296},[206,3478,515],{"class":453},[206,3480,457],{"class":230},[206,3482,520],{"class":453},[206,3484,3485],{"class":230},"(p))        ",[206,3487,3488],{"class":217},"#   the angle whose RY puts P(1) at exactly p\n",[206,3490,3491,3493,3495,3497,3499,3501,3503,3505,3507],{"class":208,"line":373},[206,3492,214],{"class":212,"aria-hidden":213},[206,3494,478],{"class":230},[206,3496,297],{"class":296},[206,3498,483],{"class":453},[206,3500,457],{"class":230},[206,3502,304],{"class":300},[206,3504,464],{"class":230},[206,3506,304],{"class":300},[206,3508,494],{"class":230},[206,3510,3511,3513,3515,3517,3519,3521],{"class":208,"line":392},[206,3512,214],{"class":212,"aria-hidden":213},[206,3514,502],{"class":230},[206,3516,505],{"class":453},[206,3518,3294],{"class":230},[206,3520,526],{"class":300},[206,3522,494],{"class":230},[206,3524,3525,3527,3529,3531,3533,3535,3537,3539],{"class":208,"line":407},[206,3526,214],{"class":212,"aria-hidden":213},[206,3528,502],{"class":230},[206,3530,566],{"class":453},[206,3532,457],{"class":230},[206,3534,526],{"class":300},[206,3536,464],{"class":230},[206,3538,526],{"class":300},[206,3540,494],{"class":230},[206,3542,3543,3545,3547],{"class":208,"line":422},[206,3544,214],{"class":212,"aria-hidden":213},[206,3546,595],{"class":226},[206,3548,598],{"class":230},[206,3550,3551,3553],{"class":208,"line":430},[206,3552,214],{"class":212,"aria-hidden":213},[206,3554,285],{},[206,3556,3557,3559],{"class":208,"line":437},[206,3558,214],{"class":212,"aria-hidden":213},[206,3560,285],{},[206,3562,3563,3565,3567,3569,3571,3573,3575,3577],{"class":208,"data-cue":444,"line":445},[206,3564,444],{"class":308},[206,3566,450],{"class":226},[206,3568,623],{"class":453},[206,3570,457],{"class":230},[206,3572,628],{"class":460},[206,3574,464],{"class":230},[206,3576,633],{"class":460},[206,3578,470],{"class":230},[206,3580,3581,3583,3586,3588,3590,3592,3594,3597,3599,3601],{"class":208,"line":473},[206,3582,214],{"class":212,"aria-hidden":213},[206,3584,3585],{"class":230},"    rare ",[206,3587,297],{"class":296},[206,3589,2692],{"class":230},[206,3591,2695],{"class":453},[206,3593,457],{"class":230},[206,3595,3596],{"class":360},"\"1\"",[206,3598,464],{"class":230},[206,3600,526],{"class":300},[206,3602,494],{"class":230},[206,3604,3605,3607,3609,3611,3614,3617,3620,3623,3625,3628,3631,3634,3636],{"class":208,"line":497},[206,3606,214],{"class":212,"aria-hidden":213},[206,3608,595],{"class":226},[206,3610,645],{"class":230},[206,3612,3613],{"class":360},"\"rare\"",[206,3615,3616],{"class":230},": rare, ",[206,3618,3619],{"class":360},"\"common\"",[206,3621,3622],{"class":230},": n ",[206,3624,2742],{"class":296},[206,3626,3627],{"class":230}," rare, ",[206,3629,3630],{"class":360},"\"share\"",[206,3632,3633],{"class":230},": rare ",[206,3635,653],{"class":296},[206,3637,3638],{"class":230}," n}\n",[206,3640,3641,3643],{"class":208,"line":531},[206,3642,214],{"class":212,"aria-hidden":213},[206,3644,285],{},[206,3646,3647,3649],{"class":208,"line":559},[206,3648,214],{"class":212,"aria-hidden":213},[206,3650,285],{},[206,3652,3653,3655,3657,3659,3661],{"class":208,"line":590},[206,3654,214],{"class":212,"aria-hidden":213},[206,3656,1446],{"class":230},[206,3658,297],{"class":296},[206,3660,454],{"class":453},[206,3662,3663],{"class":230},"(p_rare)\n",[206,3665,3666,3668,3670],{"class":208,"line":601},[206,3667,214],{"class":212,"aria-hidden":213},[206,3669,822],{"class":296},[206,3671,3672],{"class":230},"(qc)\n",[206,3674,3675,3677],{"class":208,"line":608},[206,3676,214],{"class":212,"aria-hidden":213},[206,3678,285],{},[206,3680,3681,3683,3685,3687,3689,3691,3694,3696,3698],{"class":208,"data-cue":615,"line":616},[206,3682,615],{"class":308},[206,3684,699],{"class":230},[206,3686,297],{"class":296},[206,3688,704],{"class":230},[206,3690,707],{"class":453},[206,3692,3693],{"class":230},"(qc, ",[206,3695,719],{"class":718},[206,3697,297],{"class":296},[206,3699,724],{"class":230},[206,3701,3702,3704,3706,3708,3710,3712,3714,3716,3718,3720,3722,3724,3726,3728],{"class":208,"line":638},[206,3703,214],{"class":212,"aria-hidden":213},[206,3705,732],{"class":226},[206,3707,735],{"class":230},[206,3709,738],{"class":453},[206,3711,741],{"class":230},[206,3713,744],{"class":226},[206,3715,747],{"class":226},[206,3717,750],{"class":230},[206,3719,753],{"class":300},[206,3721,756],{"class":230},[206,3723,759],{"class":300},[206,3725,756],{"class":230},[206,3727,764],{"class":300},[206,3729,470],{"class":230},[206,3731,3732,3734,3736,3738,3740,3742],{"class":208,"line":680},[206,3733,214],{"class":212,"aria-hidden":213},[206,3735,774],{"class":230},[206,3737,777],{"class":453},[206,3739,457],{"class":230},[206,3741,615],{"class":300},[206,3743,494],{"class":230},[206,3745,3746,3748],{"class":208,"line":687},[206,3747,214],{"class":212,"aria-hidden":213},[206,3749,285],{},[206,3751,3752,3754,3756,3758,3760,3762,3764,3766],{"class":208,"line":694},[206,3753,214],{"class":212,"aria-hidden":213},[206,3755,798],{"class":230},[206,3757,297],{"class":296},[206,3759,735],{"class":230},[206,3761,805],{"class":453},[206,3763,808],{"class":230},[206,3765,811],{"class":453},[206,3767,814],{"class":230},[206,3769,3770,3772,3774],{"class":208,"line":727},[206,3771,214],{"class":212,"aria-hidden":213},[206,3773,822],{"class":296},[206,3775,825],{"class":230},[206,3777,3778,3780],{"class":208,"line":769},[206,3779,214],{"class":212,"aria-hidden":213},[206,3781,285],{},[206,3783,3785,3787,3790,3792,3794],{"class":208,"data-cue":3784,"line":786},"6",[206,3786,3784],{"class":308},[206,3788,3789],{"class":230},"result ",[206,3791,297],{"class":296},[206,3793,623],{"class":453},[206,3795,3796],{"class":230},"(counts, shots)\n",[206,3798,3799,3801,3803,3805,3807,3810,3812,3814,3816,3819,3821,3824,3827,3829,3831,3833,3835,3837,3840,3842,3844,3847],{"class":208,"line":793},[206,3800,214],{"class":212,"aria-hidden":213},[206,3802,822],{"class":296},[206,3804,457],{"class":230},[206,3806,872],{"class":226},[206,3808,3809],{"class":360},"\"opened ",[206,3811,878],{"class":300},[206,3813,719],{"class":230},[206,3815,887],{"class":300},[206,3817,3818],{"class":360}," boxes: ",[206,3820,878],{"class":300},[206,3822,3823],{"class":230},"result[",[206,3825,3826],{"class":360},"'rare'",[206,3828,2465],{"class":230},[206,3830,887],{"class":300},[206,3832,3627],{"class":360},[206,3834,878],{"class":300},[206,3836,3823],{"class":230},[206,3838,3839],{"class":360},"'common'",[206,3841,2465],{"class":230},[206,3843,887],{"class":300},[206,3845,3846],{"class":360}," common\"",[206,3848,494],{"class":230},[206,3850,3851,3853,3855,3857,3859,3862,3864,3866,3869,3871,3873,3875,3878,3880,3882,3884,3886,3888],{"class":208,"line":817},[206,3852,214],{"class":212,"aria-hidden":213},[206,3854,822],{"class":296},[206,3856,457],{"class":230},[206,3858,872],{"class":226},[206,3860,3861],{"class":360},"\"share rare: ",[206,3863,878],{"class":300},[206,3865,3823],{"class":230},[206,3867,3868],{"class":360},"'share'",[206,3870,2465],{"class":230},[206,3872,895],{"class":226},[206,3874,887],{"class":300},[206,3876,3877],{"class":360},"   asked for: ",[206,3879,878],{"class":300},[206,3881,1258],{"class":230},[206,3883,895],{"class":226},[206,3885,887],{"class":300},[206,3887,875],{"class":360},[206,3889,494],{"class":230},[989,3891,3892,3899,3906,3913,3920,3927],{"class":991},[993,3893,3894,3896],{"data-cue":304},[206,3895,304],{"class":308},[206,3897,3898],{"class":999},"one press buys this many draws",[993,3900,3901,3903],{"data-cue":319},[206,3902,319],{"class":308},[206,3904,3905],{"class":999},"the app's input: how often a draw should come up rare",[993,3907,3908,3910],{"data-cue":340},[206,3909,340],{"class":308},[206,3911,3912],{"class":999},"app value in, circuit out",[993,3914,3915,3917],{"data-cue":444},[206,3916,444],{"class":308},[206,3918,3919],{"class":999},"counts in, something the app can use out",[993,3921,3922,3924],{"data-cue":615},[206,3923,615],{"class":308},[206,3925,3926],{"class":999},"one job, the circuit run 1,000 times",[993,3928,3929,3931],{"data-cue":3784},[206,3930,3784],{"class":308},[206,3932,3933],{"class":999},"the only line the rest of an app would need",[12,3935,3936,3937,3939,3940,3942],{},"Lines 1 to 5 are imports and the note about ",[203,3938,2039],{},". Lines 7 and 8 are the two numbers you will change. The two functions and the ",[203,3941,1430],{}," call are the boundary. Lines 24 to 36 are the script that uses them: build, run, wait, decode, print.",[12,3944,3945,3947,3948,1041,3950,3952,3953,3955],{},[203,3946,1430],{}," returns straight away with a job rather than a result, because the work happens on IonQ's cloud. The loop polls until the job reaches a terminal state, and it checks for ",[203,3949,759],{},[203,3951,764],{}," as well as ",[203,3954,753],{},", because a job that fails would otherwise leave you polling forever.",[23,3957,3959],{"id":3958},"predict-then-run","Predict, then run",[12,3961,3962,3963,3966],{},"Before you press anything, write down a number: out of 1,000 shots at ",[203,3964,3965],{},"p_rare = 0.3",", how many do you expect to read 1?",[12,3968,3969,3970,1127,3972,1162,3974,1166,3976,1170,3978,1174],{},"Then open ",[37,3971,1932],{"href":1245},[30,3973,1161],{},[30,3975,1165],{},[30,3977,1169],{},[30,3979,1173],{},[12,3981,3982],{},"Our run on 22 September 2026 printed this:",[197,3984,3987],{"className":3985,"code":3986,"language":1103,"meta":193},[1101],"     ┌────────────┐┌─┐\n  q: ┤ Ry(1.1593) ├┤M├\n     └────────────┘└╥┘\nc: 1\u002F═══════════════╩═\n                    0\n{'0': 720, '1': 280}\nopened 1000 boxes: 280 rare, 720 common\nshare rare: 0.280   asked for: 0.300\n",[203,3988,3986],{"__ignoreMap":193},[12,3990,3991],{},"The tally read 280 ones, against the 300 we asked for.",[12,3993,3994],{},"A prediction of exactly 300 is correct for the distribution, and as lesson 2 showed, a tally will almost never match it. The spread to expect at 1,000 shots is about ±28 either side of 300. Our 280 sits inside that band, as would 315, and so will yours nineteen times out of twenty.",[12,3996,3997,3998,4001,4002,4005,4006,4008],{},"The drawn circuit at the top shows ",[203,3999,4000],{},"Ry(1.1593)",", which is ",[203,4003,4004],{},"2 * asin(sqrt(0.3))"," in radians. Your application passed a probability, and ",[203,4007,712],{}," converted it to that angle.",[1110,4010,4012,4016,4019,4055],{"check":4011},"your drawn circuit reads Ry(π\u002F2) and your tally's '1' count is between about 470 and 530.",[23,4013,4015],{"id":4014},"assignment-change-the-probability-and-predict-the-tally","Assignment: change the probability and predict the tally",[12,4017,4018],{},"You need your own copy before you can change anything, because a published project is read-only to everyone but its owner.",[989,4020,4021,4030,4036,4039,4042,4052],{},[993,4022,4023,4024,4026,4027,4029],{},"On the project page, signed in, press ",[30,4025,1130],{},", then keep or change the name in the Fork Project dialog and press ",[30,4028,1134],{},". You now have your own copy at your own username.",[993,4031,4032,4033,1174],{},"In your fork, change line 8 to ",[203,4034,4035],{},"p_rare = 0.5",[993,4037,4038],{},"Work out what the new angle will be, in radians, and what the drawn circuit should show.",[993,4040,4041],{},"Write down how many of the 1,000 shots you expect to read 1.",[993,4043,1158,4044,1162,4046,1166,4048,1170,4050,1174],{},[30,4045,1161],{},[30,4047,1165],{},[30,4049,1169],{},[30,4051,1173],{},[993,4053,4054],{},"Compare the drawn circuit and the tally against both of your predictions.",[1179,4056,4057,4074,4077],{"label":1181},[12,4058,4059,4062,4063,4001,4066,4069,4070,4073],{},[203,4060,4061],{},"2 * asin(sqrt(0.5))"," is ",[203,4064,4065],{},"2 * asin(0.7071)",[203,4067,4068],{},"pi\u002F2",", or 1.5708 radians. The drawn circuit should read ",[203,4071,4072],{},"Ry(π\u002F2)",": the console writes an angle as a fraction of pi whenever one fits, and none fits the 1.1593 of the run above.",[12,4075,4076],{},"Expect about 500 shots reading 1. At 1,000 shots the 95% spread is roughly 469 to 531, so any count in that range is normal.",[12,4078,4079,4080,4083],{},"At ",[203,4081,4082],{},"p = 0.5"," the rotation is exactly a quarter turn, and the two outcomes are equally likely. Other probabilities give less round angles from the same formula.",[23,4085,4087,4088],{"id":4086},"inside-decode","Inside ",[203,4089,851],{},[12,4091,4092,4094],{},[203,4093,851],{}," is three lines long, and it turns the quantum result into ordinary data.",[197,4096,4098],{"className":199,"code":4097,"language":201,"meta":193,"style":193},"def decode(counts, n):\n    rare = counts.get(\"1\", 0)\n    return {\"rare\": rare, \"common\": n - rare, \"share\": rare \u002F n}\n",[203,4099,4100,4116,4136],{"__ignoreMap":193},[206,4101,4102,4104,4106,4108,4110,4112,4114],{"class":208,"line":209},[206,4103,450],{"class":226},[206,4105,623],{"class":453},[206,4107,457],{"class":230},[206,4109,628],{"class":460},[206,4111,464],{"class":230},[206,4113,633],{"class":460},[206,4115,470],{"class":230},[206,4117,4118,4120,4122,4124,4126,4128,4130,4132,4134],{"class":208,"line":221},[206,4119,3585],{"class":230},[206,4121,297],{"class":296},[206,4123,2692],{"class":230},[206,4125,2695],{"class":453},[206,4127,457],{"class":230},[206,4129,3596],{"class":360},[206,4131,464],{"class":230},[206,4133,526],{"class":300},[206,4135,494],{"class":230},[206,4137,4138,4140,4142,4144,4146,4148,4150,4152,4154,4156,4158,4160],{"class":208,"line":240},[206,4139,595],{"class":226},[206,4141,645],{"class":230},[206,4143,3613],{"class":360},[206,4145,3616],{"class":230},[206,4147,3619],{"class":360},[206,4149,3622],{"class":230},[206,4151,2742],{"class":296},[206,4153,3627],{"class":230},[206,4155,3630],{"class":360},[206,4157,3633],{"class":230},[206,4159,653],{"class":296},[206,4161,3638],{"class":230},[12,4163,4164,4166,4167,4169,4170,4173,4174,4177,4178,4180,4181,4183],{},[203,4165,851],{}," uses ",[203,4168,3205],{}," instead of ",[203,4171,4172],{},"counts[\"1\"]"," because a key you expect can be absent. At ",[203,4175,4176],{},"p_rare = 0.001"," a thousand shots contain no ones about one press in three, and ",[203,4179,4172],{}," would raise a ",[203,4182,1220],{}," in production, intermittently.",[12,4185,4186,4187,4190],{},"The return value is a dict with named keys. A dict like ",[203,4188,4189],{},"{\"rare\": 280, \"common\": 720, \"share\": 0.28}"," can be read by someone who has never heard of a qubit.",[23,4192,4194],{"id":4193},"testing-the-half-you-can-test","Testing the half you can test",[12,4196,4197,4198,4200],{},"A circuit run is slow, costs shots and returns something different every time, which makes it hard to test. ",[203,4199,851],{}," is none of those: a pure function from a dict to a dict, which you can test without a quantum computer.",[197,4202,4204],{"className":199,"code":4203,"language":201,"meta":193,"style":193},"assert decode({\"0\": 700, \"1\": 300}, 1000) == {\"rare\": 300, \"common\": 700, \"share\": 0.3}\nassert decode({\"0\": 1000}, 1000) == {\"rare\": 0, \"common\": 1000, \"share\": 0.0}\n",[203,4205,4206,4270],{"__ignoreMap":193},[206,4207,4208,4211,4213,4216,4218,4220,4223,4225,4227,4229,4232,4235,4238,4240,4243,4245,4247,4249,4251,4253,4255,4257,4259,4261,4263,4265,4268],{"class":208,"line":209},[206,4209,4210],{"class":226},"assert",[206,4212,623],{"class":453},[206,4214,4215],{"class":230},"({",[206,4217,2700],{"class":360},[206,4219,364],{"class":230},[206,4221,4222],{"class":300},"700",[206,4224,464],{"class":230},[206,4226,3596],{"class":360},[206,4228,364],{"class":230},[206,4230,4231],{"class":300},"300",[206,4233,4234],{"class":230},"}, ",[206,4236,4237],{"class":300},"1000",[206,4239,1847],{"class":230},[206,4241,4242],{"class":296},"==",[206,4244,645],{"class":230},[206,4246,3613],{"class":360},[206,4248,364],{"class":230},[206,4250,4231],{"class":300},[206,4252,464],{"class":230},[206,4254,3619],{"class":360},[206,4256,364],{"class":230},[206,4258,4222],{"class":300},[206,4260,464],{"class":230},[206,4262,3630],{"class":360},[206,4264,364],{"class":230},[206,4266,4267],{"class":300},"0.3",[206,4269,427],{"class":230},[206,4271,4272,4274,4276,4278,4280,4282,4284,4286,4288,4290,4292,4294,4296,4298,4300,4302,4304,4306,4308,4310,4312,4314,4317],{"class":208,"line":221},[206,4273,4210],{"class":226},[206,4275,623],{"class":453},[206,4277,4215],{"class":230},[206,4279,2700],{"class":360},[206,4281,364],{"class":230},[206,4283,4237],{"class":300},[206,4285,4234],{"class":230},[206,4287,4237],{"class":300},[206,4289,1847],{"class":230},[206,4291,4242],{"class":296},[206,4293,645],{"class":230},[206,4295,3613],{"class":360},[206,4297,364],{"class":230},[206,4299,526],{"class":300},[206,4301,464],{"class":230},[206,4303,3619],{"class":360},[206,4305,364],{"class":230},[206,4307,4237],{"class":300},[206,4309,464],{"class":230},[206,4311,3630],{"class":360},[206,4313,364],{"class":230},[206,4315,4316],{"class":300},"0.0",[206,4318,427],{"class":230},[12,4320,4321,4322,4324,4325,4327,4328,4166,4330,4332,4333,4335],{},"The second assert feeds ",[203,4323,851],{}," a tally with the ",[203,4326,3596],{}," key missing, the low-probability case, and passes only because ",[203,4329,851],{},[203,4331,3205],{},". Swap in ",[203,4334,4172],{}," and the second assert raises within milliseconds on your own machine.",[12,4337,4338,4339,4341,4342,4344],{},"You can test ",[203,4340,712],{}," the same way, by checking the angle it produces for a known ",[203,4343,12],{},". Only the run in the middle needs a backend, and it contains no logic of its own.",[1110,4346,4348,4352,4387],{"check":4347},"your console shows a KeyError: '1' raised inside decode, and then finishes cleanly again once you restore .get.",[23,4349,4351],{"id":4350},"assignment-break-the-decoder-without-running-a-circuit","Assignment: break the decoder without running a circuit",[989,4353,4354,4363,4368,4376,4379,4384],{},[993,4355,4356,4357,4359,4360,4362],{},"In your fork, add the two ",[203,4358,4210],{}," lines above, directly under the ",[203,4361,851],{}," function.",[993,4364,1158,4365,4367],{},[30,4366,1161],{}," and confirm the script still finishes. Passing asserts print nothing.",[993,4369,4370,4371,4373,4374,1174],{},"Change ",[203,4372,3205],{}," to ",[203,4375,4172],{},[993,4377,4378],{},"Predict which of the two asserts fails, and what the error will say.",[993,4380,1158,4381,4383],{},[30,4382,1173],{}," again.",[993,4385,4386],{},"Read the traceback, then change the line back.",[1179,4388,4389,4398,4401],{"label":1181},[12,4390,4391,4392,4395,4396,1174],{},"The second assert fails, with ",[203,4393,4394],{},"KeyError: '1'",", and the traceback points inside ",[203,4397,851],{},[12,4399,4400],{},"The first assert passes either way, because that tally has both keys. A test suite containing only the first line would have told you the code was fine.",[12,4402,4403,4404,1041,4406,4408],{},"The asserts sit above the calls to ",[203,4405,712],{},[203,4407,1430],{},", so the failing one stops the script before any circuit is built or submitted.",[1110,4410,4412,4416,4422,4459],{"check":4411},"your console prints a percentage near 50%, and it matches the '1' count in the tally printed directly above it.",[23,4413,4415],{"id":4414},"assignment-change-what-the-boundary-hands-back","Assignment: change what the boundary hands back",[12,4417,4418,4419,4421],{},"Leave ",[203,4420,4035],{}," from the previous task in your fork.",[989,4423,4424,4433,4439,4442,4452],{},[993,4425,4426,4427,4429,4430,4432],{},"In your fork, change ",[203,4428,851],{}," so the returned dict also carries a ",[203,4431,1252],{}," key, the share expressed out of 100 and rounded to one decimal place.",[993,4434,4435,4436,4438],{},"Change the last ",[203,4437,822],{}," so it prints that percentage instead of the share.",[993,4440,4441],{},"Before running, work out what the printed percentage should be, given the tally you already have on screen from the previous task.",[993,4443,1158,4444,1162,4446,1166,4448,1170,4450,1174],{},[30,4445,1161],{},[30,4447,1165],{},[30,4449,1169],{},[30,4451,1173],{},[993,4453,4454,4455,4458],{},"Check the printed percentage against the ",[203,4456,4457],{},"'1'"," count in the new tally.",[1179,4460,4461,4464,4559,4604,4610],{"label":1181},[12,4462,4463],{},"One line added and one changed:",[197,4465,4467],{"className":199,"code":4466,"language":201,"meta":193,"style":193},"def decode(counts, n):\n    rare = counts.get(\"1\", 0)\n    return {\"rare\": rare, \"common\": n - rare, \"share\": rare \u002F n, \"percent\": round(100 * rare \u002F n, 1)}\n",[203,4468,4469,4485,4505],{"__ignoreMap":193},[206,4470,4471,4473,4475,4477,4479,4481,4483],{"class":208,"line":209},[206,4472,450],{"class":226},[206,4474,623],{"class":453},[206,4476,457],{"class":230},[206,4478,628],{"class":460},[206,4480,464],{"class":230},[206,4482,633],{"class":460},[206,4484,470],{"class":230},[206,4486,4487,4489,4491,4493,4495,4497,4499,4501,4503],{"class":208,"line":221},[206,4488,3585],{"class":230},[206,4490,297],{"class":296},[206,4492,2692],{"class":230},[206,4494,2695],{"class":453},[206,4496,457],{"class":230},[206,4498,3596],{"class":360},[206,4500,464],{"class":230},[206,4502,526],{"class":300},[206,4504,494],{"class":230},[206,4506,4507,4509,4511,4513,4515,4517,4519,4521,4523,4525,4527,4529,4532,4535,4537,4540,4542,4545,4547,4550,4552,4554,4556],{"class":208,"line":240},[206,4508,595],{"class":226},[206,4510,645],{"class":230},[206,4512,3613],{"class":360},[206,4514,3616],{"class":230},[206,4516,3619],{"class":360},[206,4518,3622],{"class":230},[206,4520,2742],{"class":296},[206,4522,3627],{"class":230},[206,4524,3630],{"class":360},[206,4526,3633],{"class":230},[206,4528,653],{"class":296},[206,4530,4531],{"class":230}," n, ",[206,4533,4534],{"class":360},"\"percent\"",[206,4536,364],{"class":230},[206,4538,4539],{"class":296},"round",[206,4541,457],{"class":230},[206,4543,4544],{"class":300},"100",[206,4546,512],{"class":296},[206,4548,4549],{"class":230}," rare ",[206,4551,653],{"class":296},[206,4553,4531],{"class":230},[206,4555,304],{"class":300},[206,4557,4558],{"class":230},")}\n",[197,4560,4562],{"className":199,"code":4561,"language":201,"meta":193,"style":193},"print(f\"rare share: {result['percent']}%   asked for: {100 * p_rare}%\")\n",[203,4563,4564],{"__ignoreMap":193},[206,4565,4566,4568,4570,4572,4575,4577,4579,4582,4584,4586,4589,4592,4594,4597,4599,4602],{"class":208,"line":209},[206,4567,822],{"class":296},[206,4569,457],{"class":230},[206,4571,872],{"class":226},[206,4573,4574],{"class":360},"\"rare share: ",[206,4576,878],{"class":300},[206,4578,3823],{"class":230},[206,4580,4581],{"class":360},"'percent'",[206,4583,2465],{"class":230},[206,4585,887],{"class":300},[206,4587,4588],{"class":360},"%   asked for: ",[206,4590,4591],{"class":300},"{100",[206,4593,512],{"class":296},[206,4595,4596],{"class":230}," p_rare",[206,4598,887],{"class":300},[206,4600,4601],{"class":360},"%\"",[206,4603,494],{"class":230},[12,4605,4606,4607,4609],{},"The percentage should be the ",[203,4608,4457],{}," count divided by ten, since there are 1,000 shots. A tally of 507 gives 50.7%.",[12,4611,4612],{},"The printed percentage will not be exactly 50%, and it will differ from the previous task's run, because pressing Run again drew a fresh sample.",[23,4614,1294],{"id":1293},[12,4616,4617,4618,4620,4621,4623],{},"Keep the circuit behind three steps. ",[203,4619,712],{}," turns your data into a circuit, the run submits it and waits, and ",[203,4622,851],{}," turns the tally into a typed value the rest of the program uses. Only the run needs a backend, so both functions can be tested like any other code.",[12,4625,4626],{},"Lesson 4 puts the boundary behind an interface, which has to show something during the wait and handle a failed run.",[1299,4628,4629],{},"html pre.shiki code .sn6KH, html code.shiki .sn6KH{--shiki-default:#ABB2BF}html pre.shiki code .sjrmR, html code.shiki .sjrmR{--shiki-default:#56B6C2}html pre.shiki code .sVbv2, html code.shiki .sVbv2{--shiki-default:#61AFEF}html pre.shiki code .sVC51, html code.shiki .sVC51{--shiki-default:#D19A66}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 .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 .sb9H8, html code.shiki .sb9H8{--shiki-default:#D19A66;--shiki-default-font-style:italic}html pre.shiki code .subq3, html code.shiki .subq3{--shiki-default:#98C379}html pre.shiki code .s_ZVi, html code.shiki .s_ZVi{--shiki-default:#E06C75;--shiki-default-font-style:italic}",{"title":193,"searchDepth":221,"depth":221,"links":4631},[4632,4633,4635,4636,4637,4638,4639,4641,4642,4643,4644],{"id":3232,"depth":221,"text":3233},{"id":3242,"depth":221,"text":4634},"Where backend comes from",{"id":3257,"depth":221,"text":3258},{"id":3344,"depth":221,"text":3345},{"id":3958,"depth":221,"text":3959},{"id":4014,"depth":221,"text":4015},{"id":4086,"depth":221,"text":4640},"Inside decode",{"id":4193,"depth":221,"text":4194},{"id":4350,"depth":221,"text":4351},{"id":4414,"depth":221,"text":4415},{"id":1293,"depth":221,"text":1294},[1312,1313,1314,3185],[],{"username":7,"name":1317,"role":1318,"avatar":1319},"Turn application inputs into a typed result in three steps: build the circuit, run it, and decode what comes back.",{},{"slug":4651,"title":4652,"desc":4653},"\u002Fblog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fthe-app-around-it","The app around the circuit","A circuit run takes seconds and can fail, and your interface has to handle both.",[],{"title":3185,"description":4648},"blog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Finputs-in-result-out",[],"yrEmTq8eAsrjOjU-argn12A_tSKYo5IAABfn7dt73_0",{"id":4660,"title":4652,"authors":4661,"body":4662,"breadcrumb":6180,"builders":6181,"byline":6182,"category":1320,"categoryName":1320,"challenge":1320,"courseAuthor":1320,"courseLead":1320,"dek":4653,"description":6183,"draft":1323,"extension":1324,"eyebrow":1320,"featured":1323,"finish":1320,"fork":1320,"group":1320,"groupName":1320,"hero":1320,"heroAlt":1320,"heroCta":1320,"heroImage":1320,"homepageFeatured":1323,"kind":1326,"lessonCount":280,"meta":6184,"navigation":1328,"newsItems":1320,"next":6185,"ogImage":1320,"order":255,"outcomes":1320,"path":4651,"prerequisite":1320,"prerequisiteLinks":1320,"publishDate":1334,"readingTime":1320,"related":6189,"relatedProjects":1320,"section":1320,"seo":6190,"stem":6191,"tags":6192,"track":1339,"trackName":1314,"__hash__":6193},"blog\u002Fblog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fthe-app-around-it.md",[7],{"type":9,"value":4663,"toc":6168},[4664,4667,4670,4674,4677,4697,4703,4707,5439,5446,5451,5454,5463,5472,5475,5581,5587,5612,5633,5657,5661,5664,5832,5878,5930,5934,5939,5942,5948,5956,5964,5967,5975,5978,5981,6157,6159,6162,6165],[12,4665,4666],{},"The app around a circuit has two jobs the previous lesson ignored. The app has to say something while the run is in flight, and it has to handle the run failing.",[12,4668,4669],{},"A Python script can ignore both jobs, because nobody watches its output while it waits. An interface has a person in front of it, and that person is looking at your screen for the eighty seconds it takes a first press to come back.",[23,4671,4673],{"id":4672},"switching-to-js-qiskit","Switching to JS \u002F Qiskit",[12,4675,4676],{},"The Playground runs quantum projects in two frameworks. The last lesson used Python. JS \u002F Qiskit gives you three editable panes, JavaScript, HTML and CSS, plus a live preview, so you can build a working interface without installing anything.",[12,4678,4679,4680,4683,4684,4687,4688,4691,4692,4696],{},"The API is the Python Qiskit API with three conventions on top: no ",[203,4681,4682],{},"new"," when constructing, ",[203,4685,4686],{},".callKwargs"," for keyword arguments, and ",[203,4689,4690],{},".toJs()"," to unpack a Python value. Course 3's lesson on ",[37,4693,4695],{"href":4694},"\u002Flearn\u002Fbuilding-your-first-qollab-project\u002Frun-in-javascript","running a circuit in JavaScript"," covers the editor itself, the four panes and browser support.",[12,4698,4699,4700,4702],{},"Your JavaScript runs in a sandboxed frame in your browser, and so does ",[203,4701,2039],{},". That frame loads the same Python runtime a Python project uses and runs the same prologue, from the same Run Experiment dialog, so a JavaScript project reaches IonQ the way a Python one does.",[23,4704,4706],{"id":4705},"the-interface","The interface",[190,4708,4712],{"name":4709,"no-picker":193,"run-href":4710,"tag":4711},"picker.js","\u002Fu\u002Fqollab\u002Flearn-app-ui","JavaScript · Playground",[197,4713,4717],{"className":4714,"code":4715,"language":4716,"meta":193,"style":193},"language-js shiki shiki-themes one-dark-pro","\u002F\u002F 'backend' already exists when this runs: it is whatever you pick in the Run Experiment dialog.\nimport { QuantumCircuit } from 'qiskit';\n\nconst shots = 1000;          \u002F\u002F one press buys this many draws\nconst pRare = 0.3;           \u002F\u002F the app's input: how often a draw should come up rare\n\nconst out = document.getElementById('out');\nconst bar = document.getElementById('bar');\nconst foot = document.getElementById('foot');\n\nfunction buildCircuit(p) {               \u002F\u002F app value in, circuit out\n  const theta = 2 * Math.asin(Math.sqrt(p));\n  const qc = QuantumCircuit(1, 1);       \u002F\u002F no `new`: the constructor is called like Python's\n  qc.ry(theta, 0);\n  qc.measure(0, 0);\n  return qc;\n}\n\nfunction decode(counts, n) {             \u002F\u002F counts in, something the app can use out\n  const rare = counts['1'] ?? 0;\n  return { rare, common: n - rare, share: rare \u002F n };\n}\n\nout.textContent = 'Opening ' + shots + ' boxes...';   \u002F\u002F the in-flight state, because this takes real time\n\ntry {\n  const job = await backend.run(buildCircuit(pRare), { shots });\n  const result = await job.result();\n  const counts = result.get_counts().toJs();   \u002F\u002F .toJs() unpacks the Python dict into a plain object\n\n  const drawn = decode(counts, shots);\n  out.textContent = drawn.rare + ' rare, ' + drawn.common + ' common';\n  bar.style.width = (drawn.share * 100).toFixed(1) + '%';\n  foot.textContent = 'share ' + drawn.share.toFixed(3) + ', asked for ' + pRare.toFixed(3);\n} catch (err) {\n  out.textContent = 'The run did not finish: ' + err;   \u002F\u002F the failed state, because it can fail\n  foot.textContent = 'Press Run to try again.';\n}\n","js",[203,4718,4719,4724,4746,4750,4769,4787,4791,4816,4838,4860,4864,4882,4920,4945,4965,4983,4992,4996,5000,5020,5048,5087,5091,5095,5126,5130,5137,5174,5194,5219,5223,5244,5281,5330,5381,5397,5420,5435],{"__ignoreMap":193},[206,4720,4721],{"class":208,"line":209},[206,4722,4723],{"class":217},"\u002F\u002F 'backend' already exists when this runs: it is whatever you pick in the Run Experiment dialog.\n",[206,4725,4726,4728,4731,4735,4738,4740,4743],{"class":208,"line":221},[206,4727,234],{"class":226},[206,4729,4730],{"class":230}," { ",[206,4732,4734],{"class":4733},"sVyAn","QuantumCircuit",[206,4736,4737],{"class":230}," } ",[206,4739,227],{"class":226},[206,4741,4742],{"class":360}," 'qiskit'",[206,4744,4745],{"class":230},";\n",[206,4747,4748],{"class":208,"line":240},[206,4749,1742],{"emptyLinePlaceholder":1328},[206,4751,4752,4755,4758,4760,4763,4766],{"class":208,"line":255},[206,4753,4754],{"class":226},"const",[206,4756,2728],{"class":4757},"sU0A5",[206,4759,349],{"class":296},[206,4761,4762],{"class":300}," 1000",[206,4764,4765],{"class":230},";          ",[206,4767,4768],{"class":217},"\u002F\u002F one press buys this many draws\n",[206,4770,4771,4773,4776,4778,4781,4784],{"class":208,"line":270},[206,4772,4754],{"class":226},[206,4774,4775],{"class":4757}," pRare",[206,4777,349],{"class":296},[206,4779,4780],{"class":300}," 0.3",[206,4782,4783],{"class":230},";           ",[206,4785,4786],{"class":217},"\u002F\u002F the app's input: how often a draw should come up rare\n",[206,4788,4789],{"class":208,"line":280},[206,4790,1742],{"emptyLinePlaceholder":1328},[206,4792,4793,4795,4798,4800,4803,4805,4808,4810,4813],{"class":208,"line":288},[206,4794,4754],{"class":226},[206,4796,4797],{"class":4757}," out",[206,4799,349],{"class":296},[206,4801,4802],{"class":4757}," document",[206,4804,1174],{"class":230},[206,4806,4807],{"class":453},"getElementById",[206,4809,457],{"class":230},[206,4811,4812],{"class":360},"'out'",[206,4814,4815],{"class":230},");\n",[206,4817,4818,4820,4823,4825,4827,4829,4831,4833,4836],{"class":208,"line":305},[206,4819,4754],{"class":226},[206,4821,4822],{"class":4757}," bar",[206,4824,349],{"class":296},[206,4826,4802],{"class":4757},[206,4828,1174],{"class":230},[206,4830,4807],{"class":453},[206,4832,457],{"class":230},[206,4834,4835],{"class":360},"'bar'",[206,4837,4815],{"class":230},[206,4839,4840,4842,4845,4847,4849,4851,4853,4855,4858],{"class":208,"line":320},[206,4841,4754],{"class":226},[206,4843,4844],{"class":4757}," foot",[206,4846,349],{"class":296},[206,4848,4802],{"class":4757},[206,4850,1174],{"class":230},[206,4852,4807],{"class":453},[206,4854,457],{"class":230},[206,4856,4857],{"class":360},"'foot'",[206,4859,4815],{"class":230},[206,4861,4862],{"class":208,"line":333},[206,4863,1742],{"emptyLinePlaceholder":1328},[206,4865,4866,4869,4872,4874,4876,4879],{"class":208,"line":341},[206,4867,4868],{"class":226},"function",[206,4870,4871],{"class":453}," buildCircuit",[206,4873,457],{"class":230},[206,4875,12],{"class":718},[206,4877,4878],{"class":230},") {               ",[206,4880,4881],{"class":217},"\u002F\u002F app value in, circuit out\n",[206,4883,4884,4887,4890,4892,4894,4896,4899,4901,4904,4906,4909,4911,4913,4915,4917],{"class":208,"line":355},[206,4885,4886],{"class":226},"  const",[206,4888,4889],{"class":4757}," theta",[206,4891,349],{"class":296},[206,4893,3474],{"class":300},[206,4895,512],{"class":296},[206,4897,4898],{"class":4757}," Math",[206,4900,1174],{"class":230},[206,4902,4903],{"class":453},"asin",[206,4905,457],{"class":230},[206,4907,4908],{"class":4757},"Math",[206,4910,1174],{"class":230},[206,4912,520],{"class":453},[206,4914,457],{"class":230},[206,4916,12],{"class":4733},[206,4918,4919],{"class":230},"));\n",[206,4921,4922,4924,4927,4929,4931,4933,4935,4937,4939,4942],{"class":208,"line":373},[206,4923,4886],{"class":226},[206,4925,4926],{"class":4757}," qc",[206,4928,349],{"class":296},[206,4930,483],{"class":453},[206,4932,457],{"class":230},[206,4934,304],{"class":300},[206,4936,464],{"class":230},[206,4938,304],{"class":300},[206,4940,4941],{"class":230},");       ",[206,4943,4944],{"class":217},"\u002F\u002F no `new`: the constructor is called like Python's\n",[206,4946,4947,4950,4952,4954,4956,4959,4961,4963],{"class":208,"line":392},[206,4948,4949],{"class":4757},"  qc",[206,4951,1174],{"class":230},[206,4953,505],{"class":453},[206,4955,457],{"class":230},[206,4957,4958],{"class":4733},"theta",[206,4960,464],{"class":230},[206,4962,526],{"class":300},[206,4964,4815],{"class":230},[206,4966,4967,4969,4971,4973,4975,4977,4979,4981],{"class":208,"line":407},[206,4968,4949],{"class":4757},[206,4970,1174],{"class":230},[206,4972,566],{"class":453},[206,4974,457],{"class":230},[206,4976,526],{"class":300},[206,4978,464],{"class":230},[206,4980,526],{"class":300},[206,4982,4815],{"class":230},[206,4984,4985,4988,4990],{"class":208,"line":422},[206,4986,4987],{"class":226},"  return",[206,4989,4926],{"class":4733},[206,4991,4745],{"class":230},[206,4993,4994],{"class":208,"line":430},[206,4995,427],{"class":230},[206,4997,4998],{"class":208,"line":437},[206,4999,1742],{"emptyLinePlaceholder":1328},[206,5001,5002,5004,5006,5008,5010,5012,5014,5017],{"class":208,"line":445},[206,5003,4868],{"class":226},[206,5005,623],{"class":453},[206,5007,457],{"class":230},[206,5009,628],{"class":718},[206,5011,464],{"class":230},[206,5013,633],{"class":718},[206,5015,5016],{"class":230},") {             ",[206,5018,5019],{"class":217},"\u002F\u002F counts in, something the app can use out\n",[206,5021,5022,5024,5027,5029,5032,5035,5037,5040,5043,5046],{"class":208,"line":473},[206,5023,4886],{"class":226},[206,5025,5026],{"class":4757}," rare",[206,5028,349],{"class":296},[206,5030,5031],{"class":4733}," counts",[206,5033,5034],{"class":230},"[",[206,5036,4457],{"class":360},[206,5038,5039],{"class":230},"] ",[206,5041,5042],{"class":296},"??",[206,5044,5045],{"class":300}," 0",[206,5047,4745],{"class":230},[206,5049,5050,5052,5054,5057,5059,5062,5064,5066,5068,5070,5072,5074,5076,5078,5081,5084],{"class":208,"line":497},[206,5051,4987],{"class":226},[206,5053,4730],{"class":230},[206,5055,5056],{"class":4733},"rare",[206,5058,464],{"class":230},[206,5060,5061],{"class":4733},"common",[206,5063,364],{"class":230},[206,5065,633],{"class":4733},[206,5067,964],{"class":296},[206,5069,5026],{"class":4733},[206,5071,464],{"class":230},[206,5073,892],{"class":4733},[206,5075,364],{"class":230},[206,5077,5056],{"class":4733},[206,5079,5080],{"class":296}," \u002F",[206,5082,5083],{"class":4733}," n",[206,5085,5086],{"class":230}," };\n",[206,5088,5089],{"class":208,"line":531},[206,5090,427],{"class":230},[206,5092,5093],{"class":208,"line":559},[206,5094,1742],{"emptyLinePlaceholder":1328},[206,5096,5097,5100,5102,5105,5107,5110,5113,5115,5117,5120,5123],{"class":208,"line":590},[206,5098,5099],{"class":4757},"out",[206,5101,1174],{"class":230},[206,5103,5104],{"class":4733},"textContent",[206,5106,349],{"class":296},[206,5108,5109],{"class":360}," 'Opening '",[206,5111,5112],{"class":296}," +",[206,5114,2728],{"class":4733},[206,5116,5112],{"class":296},[206,5118,5119],{"class":360}," ' boxes...'",[206,5121,5122],{"class":230},";   ",[206,5124,5125],{"class":217},"\u002F\u002F the in-flight state, because this takes real time\n",[206,5127,5128],{"class":208,"line":601},[206,5129,1742],{"emptyLinePlaceholder":1328},[206,5131,5132,5135],{"class":208,"line":608},[206,5133,5134],{"class":226},"try",[206,5136,352],{"class":230},[206,5138,5139,5141,5144,5146,5149,5152,5154,5156,5158,5161,5163,5166,5169,5171],{"class":208,"line":616},[206,5140,4886],{"class":226},[206,5142,5143],{"class":4757}," job",[206,5145,349],{"class":296},[206,5147,5148],{"class":226}," await",[206,5150,5151],{"class":4757}," backend",[206,5153,1174],{"class":230},[206,5155,707],{"class":453},[206,5157,457],{"class":230},[206,5159,5160],{"class":453},"buildCircuit",[206,5162,457],{"class":230},[206,5164,5165],{"class":4733},"pRare",[206,5167,5168],{"class":230},"), { ",[206,5170,719],{"class":4733},[206,5172,5173],{"class":230}," });\n",[206,5175,5176,5178,5181,5183,5185,5187,5189,5191],{"class":208,"line":638},[206,5177,4886],{"class":226},[206,5179,5180],{"class":4757}," result",[206,5182,349],{"class":296},[206,5184,5148],{"class":226},[206,5186,5143],{"class":4757},[206,5188,1174],{"class":230},[206,5190,805],{"class":453},[206,5192,5193],{"class":230},"();\n",[206,5195,5196,5198,5200,5202,5204,5206,5208,5210,5213,5216],{"class":208,"line":680},[206,5197,4886],{"class":226},[206,5199,5031],{"class":4757},[206,5201,349],{"class":296},[206,5203,5180],{"class":4757},[206,5205,1174],{"class":230},[206,5207,811],{"class":453},[206,5209,808],{"class":230},[206,5211,5212],{"class":453},"toJs",[206,5214,5215],{"class":230},"();   ",[206,5217,5218],{"class":217},"\u002F\u002F .toJs() unpacks the Python dict into a plain object\n",[206,5220,5221],{"class":208,"line":687},[206,5222,1742],{"emptyLinePlaceholder":1328},[206,5224,5225,5227,5230,5232,5234,5236,5238,5240,5242],{"class":208,"line":694},[206,5226,4886],{"class":226},[206,5228,5229],{"class":4757}," drawn",[206,5231,349],{"class":296},[206,5233,623],{"class":453},[206,5235,457],{"class":230},[206,5237,628],{"class":4733},[206,5239,464],{"class":230},[206,5241,719],{"class":4733},[206,5243,4815],{"class":230},[206,5245,5246,5249,5251,5253,5255,5257,5259,5261,5263,5266,5268,5270,5272,5274,5276,5279],{"class":208,"line":727},[206,5247,5248],{"class":4757},"  out",[206,5250,1174],{"class":230},[206,5252,5104],{"class":4733},[206,5254,349],{"class":296},[206,5256,5229],{"class":4757},[206,5258,1174],{"class":230},[206,5260,5056],{"class":4733},[206,5262,5112],{"class":296},[206,5264,5265],{"class":360}," ' rare, '",[206,5267,5112],{"class":296},[206,5269,5229],{"class":4757},[206,5271,1174],{"class":230},[206,5273,5061],{"class":4733},[206,5275,5112],{"class":296},[206,5277,5278],{"class":360}," ' common'",[206,5280,4745],{"class":230},[206,5282,5283,5286,5288,5290,5292,5295,5297,5299,5302,5304,5306,5308,5311,5314,5317,5319,5321,5323,5325,5328],{"class":208,"line":769},[206,5284,5285],{"class":4757},"  bar",[206,5287,1174],{"class":230},[206,5289,1299],{"class":4757},[206,5291,1174],{"class":230},[206,5293,5294],{"class":4733},"width",[206,5296,349],{"class":296},[206,5298,972],{"class":230},[206,5300,5301],{"class":4757},"drawn",[206,5303,1174],{"class":230},[206,5305,892],{"class":4733},[206,5307,512],{"class":296},[206,5309,5310],{"class":300}," 100",[206,5312,5313],{"class":230},").",[206,5315,5316],{"class":453},"toFixed",[206,5318,457],{"class":230},[206,5320,304],{"class":300},[206,5322,1847],{"class":230},[206,5324,1841],{"class":296},[206,5326,5327],{"class":360}," '%'",[206,5329,4745],{"class":230},[206,5331,5332,5335,5337,5339,5341,5344,5346,5348,5350,5352,5354,5356,5358,5360,5362,5364,5367,5369,5371,5373,5375,5377,5379],{"class":208,"line":786},[206,5333,5334],{"class":4757},"  foot",[206,5336,1174],{"class":230},[206,5338,5104],{"class":4733},[206,5340,349],{"class":296},[206,5342,5343],{"class":360}," 'share '",[206,5345,5112],{"class":296},[206,5347,5229],{"class":4757},[206,5349,1174],{"class":230},[206,5351,892],{"class":4757},[206,5353,1174],{"class":230},[206,5355,5316],{"class":453},[206,5357,457],{"class":230},[206,5359,340],{"class":300},[206,5361,1847],{"class":230},[206,5363,1841],{"class":296},[206,5365,5366],{"class":360}," ', asked for '",[206,5368,5112],{"class":296},[206,5370,4775],{"class":4757},[206,5372,1174],{"class":230},[206,5374,5316],{"class":453},[206,5376,457],{"class":230},[206,5378,340],{"class":300},[206,5380,4815],{"class":230},[206,5382,5383,5386,5389,5391,5394],{"class":208,"line":793},[206,5384,5385],{"class":230},"} ",[206,5387,5388],{"class":226},"catch",[206,5390,972],{"class":230},[206,5392,5393],{"class":4733},"err",[206,5395,5396],{"class":230},") {\n",[206,5398,5399,5401,5403,5405,5407,5410,5412,5415,5417],{"class":208,"line":817},[206,5400,5248],{"class":4757},[206,5402,1174],{"class":230},[206,5404,5104],{"class":4733},[206,5406,349],{"class":296},[206,5408,5409],{"class":360}," 'The run did not finish: '",[206,5411,5112],{"class":296},[206,5413,5414],{"class":4733}," err",[206,5416,5122],{"class":230},[206,5418,5419],{"class":217},"\u002F\u002F the failed state, because it can fail\n",[206,5421,5422,5424,5426,5428,5430,5433],{"class":208,"line":828},[206,5423,5334],{"class":4757},[206,5425,1174],{"class":230},[206,5427,5104],{"class":4733},[206,5429,349],{"class":296},[206,5431,5432],{"class":360}," 'Press Run to try again.'",[206,5434,4745],{"class":230},[206,5436,5437],{"class":208,"line":835},[206,5438,427],{"class":230},[12,5440,5441,1041,5443,5445],{},[203,5442,5160],{},[203,5444,851],{}," are the same two functions as lesson 3, in another language.",[16,5447],{"alt":5448,"caption":5449,"no":20,"src":5450},"Ready leads to Running when the reader presses Run. Running leads to Success when the result arrives and the page shows the tally, or to Failed when the catch block runs and the page shows the error. Failed leads back to Running on another press. A note underneath warns that a result from an earlier press must not overwrite a newer one.","A remote quantum call moves through four states, and every path out of Running has to replace the running text.","\u002F_content\u002Fimages\u002Freal-app\u002Fui-state-machine.svg",[12,5452,5453],{},"The new code sits on either side of the call.",[12,5455,5456,5459,5460,5462],{},[30,5457,5458],{},"The in-flight state."," The line before ",[203,5461,1430],{}," writes \"Opening 1000 boxes...\" into the page. Without that line the interface sits unchanged for the ten to fifteen seconds the job takes, and a person can decide your app is broken and reload.",[12,5464,5465,5468,5469,5471],{},[30,5466,5467],{},"The failed state."," The ",[203,5470,5388],{}," writes the error where the result would have gone, and tells the reader they can press Run again. A quantum run has more ways to fail than a local function call: the queue can reject the job, the network can drop, and the backend can error. Code that assumes success never replaces the in-flight text.",[12,5473,5474],{},"Both states are ordinary front-end work, needed by any remote call that is slow and can fail, including a circuit run.",[1110,5476,5478,5482,5485,5544],{"check":5477},"one press prints 'ui state: failed' and a later press prints 'ui state: success', and neither press leaves the preview on its running message.",[23,5479,5481],{"id":5480},"assignment-make-the-run-fail-on-purpose","Assignment: make the run fail on purpose",[12,5483,5484],{},"A real failure is hard to wait for, so throw one on purpose.",[989,5486,5487,5497,5506,5516,5519,5529,5532,5541],{},[993,5488,5489,5490,5493,5494,5496],{},"In your fork, add ",[203,5491,5492],{},"console.log('ui state: success');"," as the last line inside the ",[203,5495,5134],{}," block, after the bar is set.",[993,5498,5499,5500,5503,5504,1174],{},"Add ",[203,5501,5502],{},"console.log('ui state: failed');"," as the first line inside ",[203,5505,5388],{},[993,5507,5499,5508,5503,5511,5513,5514,1174],{},[203,5509,5510],{},"throw new Error('test failure');",[203,5512,5134],{},", above ",[203,5515,1430],{},[993,5517,5518],{},"Predict what the preview will show, and predict which of the two console lines will appear.",[993,5520,1158,5521,1162,5523,1166,5525,1170,5527,1174],{},[30,5522,1161],{},[30,5524,1165],{},[30,5526,1169],{},[30,5528,1173],{},[993,5530,5531],{},"Write down the console line and the preview text.",[993,5533,5534,5535,5538,5539,4383],{},"Delete the ",[203,5536,5537],{},"throw"," line, and press ",[30,5540,1173],{},[993,5542,5543],{},"Write down the console line and the preview text this time.",[1179,5545,5546,5562,5572,5575],{"label":1181},[12,5547,5548,5549,5551,5552,5554,5555,5557,5558,5561],{},"With the ",[203,5550,5537],{}," in place the circuit never runs. The exception is raised before ",[203,5553,1430],{},", control jumps straight to ",[203,5556,5388],{},", the console prints ",[203,5559,5560],{},"ui state: failed",", and the preview reads \"The run did not finish: Error: test failure\" with \"Press Run to try again.\" underneath.",[12,5563,5564,5565,5567,5568,5571],{},"Remove the ",[203,5566,5537],{}," and the same interface comes back through the other path: ",[203,5569,5570],{},"ui state: success",", and the tally in the preview.",[12,5573,5574],{},"Neither path leaves the preview on \"Opening 1000 boxes...\", as Figure 1 shows.",[12,5576,5577,5578,5580],{},"A real failure looks the same to your code: it arrives in ",[203,5579,5388],{},", and the running text needs replacing.",[23,5582,5584,5586],{"id":5583},"tojs-returns-a-plain-object-not-a-map",[203,5585,4690],{}," returns a plain object, not a Map",[197,5588,5590],{"className":4714,"code":5589,"language":4716,"meta":193,"style":193},"const counts = result.get_counts().toJs();\n",[203,5591,5592],{"__ignoreMap":193},[206,5593,5594,5596,5598,5600,5602,5604,5606,5608,5610],{"class":208,"line":209},[206,5595,4754],{"class":226},[206,5597,5031],{"class":4757},[206,5599,349],{"class":296},[206,5601,5180],{"class":4757},[206,5603,1174],{"class":230},[206,5605,811],{"class":453},[206,5607,808],{"class":230},[206,5609,5212],{"class":453},[206,5611,5193],{"class":230},[12,5613,5614,5617,5618,5620,5621,5624,5625,5628,5629,5632],{},[203,5615,5616],{},"get_counts()"," returns a proxy to a Python dict. ",[203,5619,4690],{}," unpacks that proxy, and on this platform the result is a ",[30,5622,5623],{},"plain JavaScript object",", so ",[203,5626,5627],{},"counts['1']"," works and ",[203,5630,5631],{},"Object.keys(counts)"," works.",[12,5634,5635,5636,5638,5639,5642,5643,5645,5646,5649,5650,5652,5653,5656],{},"Our first version wrapped the ",[203,5637,4690],{}," result in ",[203,5640,5641],{},"Object.fromEntries",", the call you would write if ",[203,5644,4690],{}," returned a ",[203,5647,5648],{},"Map",". ",[203,5651,4690],{}," does not, and the run failed with ",[203,5654,5655],{},"TypeError: object is not iterable",". The circuit had executed correctly and the job had completed; the failure was one wrapper call of JavaScript after the boundary.",[23,5658,5660],{"id":5659},"the-page-and-its-styles","The page and its styles",[12,5662,5663],{},"The other two panes are small on purpose, because they are yours to replace.",[190,5665,5668],{"name":5666,"no-picker":193,"run-href":4710,"tag":5667},"picker.html","HTML · Playground",[197,5669,5673],{"className":5670,"code":5671,"language":5672,"meta":193,"style":193},"language-html shiki shiki-themes one-dark-pro","\u003Cdiv id=\"picker\">\n  \u003Ch1>Loot box opener\u003C\u002Fh1>\n  \u003Cp class=\"sub\">One press opens 1,000 boxes. The circuit decides how many are rare.\u003C\u002Fp>\n  \u003Cp id=\"out\" class=\"out\">Ready.\u003C\u002Fp>\n  \u003Cdiv class=\"track\">\u003Cdiv id=\"bar\" class=\"bar\">\u003C\u002Fdiv>\u003C\u002Fdiv>\n  \u003Cp id=\"foot\" class=\"foot\">\u003C\u002Fp>\n\u003C\u002Fdiv>\n","html",[203,5674,5675,5694,5709,5730,5756,5798,5823],{"__ignoreMap":193},[206,5676,5677,5680,5683,5686,5688,5691],{"class":208,"line":209},[206,5678,5679],{"class":230},"\u003C",[206,5681,5682],{"class":4733},"div",[206,5684,5685],{"class":300}," id",[206,5687,297],{"class":230},[206,5689,5690],{"class":360},"\"picker\"",[206,5692,5693],{"class":230},">\n",[206,5695,5696,5699,5702,5705,5707],{"class":208,"line":221},[206,5697,5698],{"class":230},"  \u003C",[206,5700,5701],{"class":4733},"h1",[206,5703,5704],{"class":230},">Loot box opener\u003C\u002F",[206,5706,5701],{"class":4733},[206,5708,5693],{"class":230},[206,5710,5711,5713,5715,5718,5720,5723,5726,5728],{"class":208,"line":240},[206,5712,5698],{"class":230},[206,5714,12],{"class":4733},[206,5716,5717],{"class":300}," class",[206,5719,297],{"class":230},[206,5721,5722],{"class":360},"\"sub\"",[206,5724,5725],{"class":230},">One press opens 1,000 boxes. The circuit decides how many are rare.\u003C\u002F",[206,5727,12],{"class":4733},[206,5729,5693],{"class":230},[206,5731,5732,5734,5736,5738,5740,5743,5745,5747,5749,5752,5754],{"class":208,"line":255},[206,5733,5698],{"class":230},[206,5735,12],{"class":4733},[206,5737,5685],{"class":300},[206,5739,297],{"class":230},[206,5741,5742],{"class":360},"\"out\"",[206,5744,5717],{"class":300},[206,5746,297],{"class":230},[206,5748,5742],{"class":360},[206,5750,5751],{"class":230},">Ready.\u003C\u002F",[206,5753,12],{"class":4733},[206,5755,5693],{"class":230},[206,5757,5758,5760,5762,5764,5766,5769,5772,5774,5776,5778,5781,5783,5785,5787,5790,5792,5794,5796],{"class":208,"line":270},[206,5759,5698],{"class":230},[206,5761,5682],{"class":4733},[206,5763,5717],{"class":300},[206,5765,297],{"class":230},[206,5767,5768],{"class":360},"\"track\"",[206,5770,5771],{"class":230},">\u003C",[206,5773,5682],{"class":4733},[206,5775,5685],{"class":300},[206,5777,297],{"class":230},[206,5779,5780],{"class":360},"\"bar\"",[206,5782,5717],{"class":300},[206,5784,297],{"class":230},[206,5786,5780],{"class":360},[206,5788,5789],{"class":230},">\u003C\u002F",[206,5791,5682],{"class":4733},[206,5793,5789],{"class":230},[206,5795,5682],{"class":4733},[206,5797,5693],{"class":230},[206,5799,5800,5802,5804,5806,5808,5811,5813,5815,5817,5819,5821],{"class":208,"line":280},[206,5801,5698],{"class":230},[206,5803,12],{"class":4733},[206,5805,5685],{"class":300},[206,5807,297],{"class":230},[206,5809,5810],{"class":360},"\"foot\"",[206,5812,5717],{"class":300},[206,5814,297],{"class":230},[206,5816,5810],{"class":360},[206,5818,5789],{"class":230},[206,5820,12],{"class":4733},[206,5822,5693],{"class":230},[206,5824,5825,5828,5830],{"class":208,"line":288},[206,5826,5827],{"class":230},"\u003C\u002F",[206,5829,5682],{"class":4733},[206,5831,5693],{"class":230},[190,5833,5836],{"name":5834,"no-picker":193,"run-href":4710,"tag":5835},"picker.css","CSS · Playground",[197,5837,5841],{"className":5838,"code":5839,"language":5840,"meta":193,"style":193},"language-css shiki shiki-themes one-dark-pro","#picker { font: 15px\u002F1.5 system-ui, sans-serif; color: #1a1a1a; max-width: 460px; margin: 0 auto; padding: 8px; }\n#picker h1 { font-size: 19px; margin: 0 0 4px; }\n#picker .sub { margin: 0 0 18px; color: #555; font-size: 13px; }\n#picker .out { font-size: 17px; font-weight: 600; margin: 0 0 8px; }\n#picker .track { background: #ececf0; border-radius: 999px; height: 14px; overflow: hidden; }\n#picker .bar { background: #6d4aff; height: 100%; width: 0; transition: width .35s ease; }\n#picker .foot { color: #666; font-size: 12px; margin: 8px 0 0; font-variant-numeric: tabular-nums; }\n","css",[203,5842,5843,5848,5853,5858,5863,5868,5873],{"__ignoreMap":193},[206,5844,5845],{"class":208,"line":209},[206,5846,5847],{},"#picker { font: 15px\u002F1.5 system-ui, sans-serif; color: #1a1a1a; max-width: 460px; margin: 0 auto; padding: 8px; }\n",[206,5849,5850],{"class":208,"line":221},[206,5851,5852],{},"#picker h1 { font-size: 19px; margin: 0 0 4px; }\n",[206,5854,5855],{"class":208,"line":240},[206,5856,5857],{},"#picker .sub { margin: 0 0 18px; color: #555; font-size: 13px; }\n",[206,5859,5860],{"class":208,"line":255},[206,5861,5862],{},"#picker .out { font-size: 17px; font-weight: 600; margin: 0 0 8px; }\n",[206,5864,5865],{"class":208,"line":270},[206,5866,5867],{},"#picker .track { background: #ececf0; border-radius: 999px; height: 14px; overflow: hidden; }\n",[206,5869,5870],{"class":208,"line":280},[206,5871,5872],{},"#picker .bar { background: #6d4aff; height: 100%; width: 0; transition: width .35s ease; }\n",[206,5874,5875],{"class":208,"line":288},[206,5876,5877],{},"#picker .foot { color: #666; font-size: 12px; margin: 8px 0 0; font-variant-numeric: tabular-nums; }\n",[1110,5879,5881,5885,5919],{"check":5880},"you have seen the in-flight line and the results of two presses of an unchanged fork, pressing once more if the two happen to match.",[23,5882,5884],{"id":5883},"assignment-watch-the-two-states-then-press-again","Assignment: watch the two states, then press again",[989,5886,5887,5898,5908,5911,5914],{},[993,5888,1121,5889,1127,5894,1131,5896,1135],{},[37,5890,5892],{"href":5891},"https:\u002F\u002Fqollab.xyz\u002Fu\u002Fqollab\u002Flearn-app-ui",[203,5893,4710],{},[30,5895,1130],{},[30,5897,1134],{},[993,5899,2831,5900,1162,5902,1166,5904,1170,5906,1174],{},[30,5901,1161],{},[30,5903,1165],{},[30,5905,1169],{},[30,5907,1173],{},[993,5909,5910],{},"Watch the preview while the job runs. Write down what the preview says before the result arrives.",[993,5912,5913],{},"When the result lands, write down the two numbers and the share.",[993,5915,1158,5916,5918],{},[30,5917,1173],{}," again without changing anything, and write down the new numbers.",[1179,5920,5921,5924,5927],{"label":1181},[12,5922,5923],{},"Before the result arrives the preview reads \"Opening 1000 boxes...\".",[12,5925,5926],{},"Our run on 22 September 2026 came back with 310 rare and 690 common, a share of 0.310 against the 0.300 asked for. Yours will differ, and your second press will differ from your first, for the reason lesson 2 gave.",[12,5928,5929],{},"The bar moves between presses because its width is set from the share.",[23,5931,5933],{"id":5932},"live-recorded-precomputed-or-scheduled","Live, recorded, precomputed or scheduled",[16,5935],{"alt":5936,"caption":5937,"no":1545,"src":5938},"Four lanes. Live call: user to job to wait to result, always fresh, the user waits seconds, and failures reach the user. Recorded replay: user to a library of stored runs to an immediate result, fresh as of recording, no waiting, failing at recording time. Precomputed pool: batch jobs to a database to the user, fresh as of the last batch, no waiting, failing in the batch. Scheduled pipeline: scheduler to job to published value to another program, fresh as of the last schedule, with no user waiting at all.","The circuit can be identical in all four shapes. The shapes differ in when the circuit runs, who waits, where the result lives, and how stale the result may be.","\u002F_content\u002Fimages\u002Freal-app\u002Ffour-topologies.svg",[12,5940,5941],{},"Your fork makes a live call: a person presses a button and waits for a quantum computer. A live call is one of four shapes in Figure 2.",[12,5943,5944,5947],{},[30,5945,5946],{},"Live call."," You just built this shape: the user waits the full latency on every press. It suits a tool whose purpose is running the circuit, such as the Playground itself.",[12,5949,5950,1037,5953,5955],{},[30,5951,5952],{},"Recorded, then replayed.",[37,5954,1581],{"href":71}," runs two tracks. An exact statevector simulation runs live on every visit inside a serverless function and drives the animation. The damage-and-healing fidelities come from IonQ Forte runs captured offline and replayed from a library, per the write-up, so each visit draws a different recorded run. Nobody waits for a queue, and the fidelities still come from hardware.",[12,5957,5958,1037,5961,5963],{},[30,5959,5960],{},"Precomputed pool.",[37,5962,40],{"href":39}," is the project from lessons 1 and 2, and its write-up gives the reasoning. Running circuits live when a visitor arrives would be slow and expensive. So the team computes a pool of measurement results in advance, and each plant draws from it when first observed. The write-up puts the reveal of a plant's traits at under 50 milliseconds.",[12,5965,5966],{},"Garden's stack is Next.js, React, Three.js, Qiskit, IonQ and PostgreSQL. Four of those six, everything except Qiskit and IonQ, are ordinary web tools.",[12,5968,5969,5468,5972,5974],{},[30,5970,5971],{},"Scheduled pipeline.",[37,5973,1360],{"href":95}," is built to run once a day: a Python engine pulls market signals, a quantum step runs on IonQ, and the result is published on-chain. Smart contracts can then read the result with the same call they would use for a price feed.",[12,5976,5977],{},"The Oracle's write-up describes the output as a number other code builds on rather than a dashboard for people. When another program consumes your result, neither the in-flight state nor the failed state applies, and a scheduled pipeline is enough.",[12,5979,5980],{},"The choice between the four shapes is a latency and cost decision, made the way you would make it for any expensive third-party call.",[1110,5982,5984,5988,5991,6038],{"check":5983},"your fork shows its result as soon as the console says Running... with useRecorded true, and only after a further wait when it is false.",[23,5985,5987],{"id":5986},"assignment-turn-your-live-call-into-a-replay","Assignment: turn your live call into a replay",[12,5989,5990],{},"Your fork currently calls the circuit every time someone presses Run. Make your fork behave like Butterfly Field's recorded replay instead.",[989,5992,5993,5999,6005,6019,6027,6035],{},[993,5994,5995,5996,1174],{},"In your fork, copy the tally from your last run into the code as a literal object, for example ",[203,5997,5998],{},"const recorded = { '0': 690, '1': 310 };",[993,6000,6001,6002,1174],{},"Add a constant near the top, ",[203,6003,6004],{},"const useRecorded = true;",[993,6006,6007,6008,6011,6012,6015,6016,6018],{},"Change the code so that when ",[203,6009,6010],{},"useRecorded"," is true it decodes ",[203,6013,6014],{},"recorded"," and never calls ",[203,6017,1430],{},", and when it is false it runs the circuit as before.",[993,6020,1158,6021,6023,6024,6026],{},[30,6022,1173],{}," with ",[203,6025,6010],{}," set to true and time how long the result takes to appear.",[993,6028,1144,6029,6031,6032,6034],{},[203,6030,6010],{}," back to false, press ",[30,6033,1173],{},", and time it again.",[993,6036,6037],{},"Write down what the replay gained and what it gave up.",[1179,6039,6040,6043,6151,6154],{"label":1181},[12,6041,6042],{},"The shape of the change is a branch around the call:",[197,6044,6046],{"className":4714,"code":6045,"language":4716,"meta":193,"style":193},"let counts;\nif (useRecorded) {\n  counts = recorded;\n} else {\n  const job = await backend.run(buildCircuit(pRare), { shots });\n  counts = (await job.result()).get_counts().toJs();\n}\n",[203,6047,6048,6057,6068,6080,6089,6119,6147],{"__ignoreMap":193},[206,6049,6050,6053,6055],{"class":208,"line":209},[206,6051,6052],{"class":226},"let",[206,6054,5031],{"class":4733},[206,6056,4745],{"class":230},[206,6058,6059,6062,6064,6066],{"class":208,"line":221},[206,6060,6061],{"class":226},"if",[206,6063,972],{"class":230},[206,6065,6010],{"class":4733},[206,6067,5396],{"class":230},[206,6069,6070,6073,6075,6078],{"class":208,"line":240},[206,6071,6072],{"class":4733},"  counts",[206,6074,349],{"class":296},[206,6076,6077],{"class":4733}," recorded",[206,6079,4745],{"class":230},[206,6081,6082,6084,6087],{"class":208,"line":255},[206,6083,5385],{"class":230},[206,6085,6086],{"class":226},"else",[206,6088,352],{"class":230},[206,6090,6091,6093,6095,6097,6099,6101,6103,6105,6107,6109,6111,6113,6115,6117],{"class":208,"line":270},[206,6092,4886],{"class":226},[206,6094,5143],{"class":4757},[206,6096,349],{"class":296},[206,6098,5148],{"class":226},[206,6100,5151],{"class":4757},[206,6102,1174],{"class":230},[206,6104,707],{"class":453},[206,6106,457],{"class":230},[206,6108,5160],{"class":453},[206,6110,457],{"class":230},[206,6112,5165],{"class":4733},[206,6114,5168],{"class":230},[206,6116,719],{"class":4733},[206,6118,5173],{"class":230},[206,6120,6121,6123,6125,6127,6130,6132,6134,6136,6139,6141,6143,6145],{"class":208,"line":280},[206,6122,6072],{"class":4733},[206,6124,349],{"class":296},[206,6126,972],{"class":230},[206,6128,6129],{"class":226},"await",[206,6131,5143],{"class":4757},[206,6133,1174],{"class":230},[206,6135,805],{"class":453},[206,6137,6138],{"class":230},"()).",[206,6140,811],{"class":453},[206,6142,808],{"class":230},[206,6144,5212],{"class":453},[206,6146,5193],{"class":230},[206,6148,6149],{"class":208,"line":288},[206,6150,427],{"class":230},[12,6152,6153],{},"With the branch taken the result appears the moment your code starts, because nothing leaves the machine. The Playground still loads its runtime first, and that load is separate from the job wait the replay removes. With the branch false you are back to waiting for the job too.",[12,6155,6156],{},"The replay removed the job wait and gave up freshness: the tally is fixed, identical on every visit, and it stops being a sample of anything once your circuit changes. Butterfly Field keeps a library of recorded runs and draws a different one each visit, so repeat visits do not all show the same result.",[23,6158,1294],{"id":1293},[12,6160,6161],{},"A run on IonQ's cloud takes seconds and can fail, so a page that runs the circuit live needs an in-flight state and a failed state. Run the circuit ahead of time when a person should not wait on each press, when each press would cost too much, or when another program reads the result. The three ways to do that are a recorded replay, a precomputed pool and a scheduled pipeline. The result is then only as fresh as the last run.",[12,6163,6164],{},"Lesson 5 measures whether the quantum version was worth building.",[1299,6166,6167],{},"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 .sVyAn, html code.shiki .sVyAn{--shiki-default:#E06C75}html pre.shiki code .subq3, html code.shiki .subq3{--shiki-default:#98C379}html pre.shiki code .sU0A5, html code.shiki .sU0A5{--shiki-default:#E5C07B}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 .sVbv2, html code.shiki .sVbv2{--shiki-default:#61AFEF}html pre.shiki code .s_ZVi, html code.shiki .s_ZVi{--shiki-default:#E06C75;--shiki-default-font-style:italic}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);}",{"title":193,"searchDepth":221,"depth":221,"links":6169},[6170,6171,6172,6173,6175,6176,6177,6178,6179],{"id":4672,"depth":221,"text":4673},{"id":4705,"depth":221,"text":4706},{"id":5480,"depth":221,"text":5481},{"id":5583,"depth":221,"text":6174},".toJs() returns a plain object, not a Map",{"id":5659,"depth":221,"text":5660},{"id":5883,"depth":221,"text":5884},{"id":5932,"depth":221,"text":5933},{"id":5986,"depth":221,"text":5987},{"id":1293,"depth":221,"text":1294},[1312,1313,1314,4652],[],{"username":7,"name":1317,"role":1318,"avatar":1319},"An app around a circuit handles a call that takes seconds and can fail, in one of four shapes: live, recorded replay, precomputed pool or scheduled pipeline.",{},{"slug":6186,"title":6187,"desc":6188},"\u002Fblog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fis-quantum-worth-it","Is quantum worth it in your app","Run the same job both ways and compare the counts and the timings.",[],{"title":4652,"description":6183},"blog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fthe-app-around-it",[],"A2gsPE4R_M_cDY4IE3sdMtDzLYoDMJYUr6xC3SCwFTI",{"id":6195,"title":6187,"authors":6196,"body":6197,"breadcrumb":7251,"builders":7252,"byline":7253,"category":1320,"categoryName":1320,"challenge":1320,"courseAuthor":1320,"courseLead":1320,"dek":6188,"description":7254,"draft":1323,"extension":1324,"eyebrow":1320,"featured":1323,"finish":1320,"fork":1320,"group":1320,"groupName":1320,"hero":1320,"heroAlt":1320,"heroCta":1320,"heroImage":1320,"homepageFeatured":1323,"kind":1326,"lessonCount":280,"meta":7255,"navigation":1328,"newsItems":1320,"next":7256,"ogImage":1320,"order":270,"outcomes":1320,"path":6186,"prerequisite":1320,"prerequisiteLinks":1320,"publishDate":1334,"readingTime":1320,"related":7257,"relatedProjects":1320,"section":1320,"seo":7258,"stem":7259,"tags":7260,"track":1339,"trackName":1314,"__hash__":7261},"blog\u002Fblog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fis-quantum-worth-it.md",[7],{"type":9,"value":6198,"toc":7241},[6199,6206,6210,6213,6960,6966,6980,6986,6989,6994,7000,7003,7007,7010,7013,7017,7023,7026,7030,7037,7040,7094,7097,7106,7110,7113,7119,7125,7131,7137,7141,7147,7153,7159,7165,7171,7230,7232,7235,7238],[12,6200,6201,6202,6205],{},"You answer whether quantum is worth it by measuring: ",[203,6203,6204],{},"race.py"," draws the picker's thousand samples twice, once with one line of ordinary Python and once with the circuit from lesson 3, and compares the two runs on count and on time.",[23,6207,6209],{"id":6208},"the-race","The race",[12,6211,6212],{},"The file runs both methods once and scores them with the same arithmetic.",[190,6214,6216],{"name":6204,"no-picker":193,"run-href":6215,"tag":195},"\u002Fu\u002Fqollab\u002Flearn-app-race",[197,6217,6219],{"className":199,"code":6218,"language":201,"meta":193,"style":193},"# 'backend' already exists when this runs: it is whatever you pick in the Run Experiment dialog.\nfrom math import asin, sqrt\nfrom qiskit import QuantumCircuit\nfrom qiskit.providers.jobstatus import JobStatus\nimport random\nimport time\n\nshots = 1000\np_rare = 0.3\n\n# --- the conventional answer -------------------------------------------------\nt0 = time.perf_counter()\npicks = random.choices([\"common\", \"rare\"], weights=[1 - p_rare, p_rare], k=shots)\nclassical = {\"rare\": picks.count(\"rare\"), \"common\": picks.count(\"common\")}\nclassical_s = time.perf_counter() - t0\n\n# --- the quantum answer ------------------------------------------------------\nqc = QuantumCircuit(1, 1)\nqc.ry(2 * asin(sqrt(p_rare)), 0)\nqc.measure(0, 0)\n\nt1 = time.perf_counter()\njob = backend.run(qc, shots=shots)\nwhile job.status() not in (JobStatus.DONE, JobStatus.ERROR, JobStatus.CANCELLED):\n    time.sleep(1)\ncounts = job.result().get_counts()\nquantum = {\"rare\": counts.get(\"1\", 0), \"common\": counts.get(\"0\", 0)}\nquantum_s = time.perf_counter() - t1\n\n# --- read the result honestly ------------------------------------------------\nprint(f\"classical  {classical}   in {classical_s * 1000:.2f} ms\")\nprint(f\"quantum    {quantum}   in {quantum_s:.1f} s\")\nprint()\ngap = abs(classical[\"rare\"] - quantum[\"rare\"])\nprint(f\"the two draws differ by {gap} out of {shots}\")\nprint(\"two independent 1,000-shot draws land within 40 of each other 95% of the time,\")\nprint(\"so anything up to about 40 here is the two methods agreeing.\")\nprint()\nprint(f\"the quantum run took about {quantum_s \u002F classical_s:,.0f} times as long,\")\nprint(\"almost all of it queue and round trip rather than computation.\")\n",[203,6220,6221,6227,6239,6251,6263,6272,6280,6286,6296,6306,6312,6319,6336,6383,6420,6440,6446,6453,6473,6500,6518,6524,6539,6559,6589,6603,6621,6665,6685,6691,6698,6739,6776,6784,6812,6845,6864,6877,6885,6917,6930],{"__ignoreMap":193},[206,6222,6223,6225],{"class":208,"line":209},[206,6224,214],{"class":212,"aria-hidden":213},[206,6226,218],{"class":217},[206,6228,6229,6231,6233,6235,6237],{"class":208,"line":221},[206,6230,214],{"class":212,"aria-hidden":213},[206,6232,227],{"class":226},[206,6234,231],{"class":230},[206,6236,234],{"class":226},[206,6238,237],{"class":230},[206,6240,6241,6243,6245,6247,6249],{"class":208,"line":240},[206,6242,214],{"class":212,"aria-hidden":213},[206,6244,227],{"class":226},[206,6246,247],{"class":230},[206,6248,234],{"class":226},[206,6250,252],{"class":230},[206,6252,6253,6255,6257,6259,6261],{"class":208,"line":255},[206,6254,214],{"class":212,"aria-hidden":213},[206,6256,227],{"class":226},[206,6258,262],{"class":230},[206,6260,234],{"class":226},[206,6262,267],{"class":230},[206,6264,6265,6267,6269],{"class":208,"line":270},[206,6266,214],{"class":212,"aria-hidden":213},[206,6268,234],{"class":226},[206,6270,6271],{"class":230}," random\n",[206,6273,6274,6276,6278],{"class":208,"line":280},[206,6275,214],{"class":212,"aria-hidden":213},[206,6277,234],{"class":226},[206,6279,277],{"class":230},[206,6281,6282,6284],{"class":208,"line":288},[206,6283,214],{"class":212,"aria-hidden":213},[206,6285,285],{},[206,6287,6288,6290,6292,6294],{"class":208,"line":305},[206,6289,214],{"class":212,"aria-hidden":213},[206,6291,293],{"class":230},[206,6293,297],{"class":296},[206,6295,301],{"class":300},[206,6297,6298,6300,6302,6304],{"class":208,"line":320},[206,6299,214],{"class":212,"aria-hidden":213},[206,6301,3431],{"class":230},[206,6303,297],{"class":296},[206,6305,3436],{"class":300},[206,6307,6308,6310],{"class":208,"line":333},[206,6309,214],{"class":212,"aria-hidden":213},[206,6311,285],{},[206,6313,6314,6316],{"class":208,"line":341},[206,6315,214],{"class":212,"aria-hidden":213},[206,6317,6318],{"class":217},"# --- the conventional answer -------------------------------------------------\n",[206,6320,6321,6323,6326,6328,6331,6334],{"class":208,"line":355},[206,6322,214],{"class":212,"aria-hidden":213},[206,6324,6325],{"class":230},"t0 ",[206,6327,297],{"class":296},[206,6329,6330],{"class":230}," time.",[206,6332,6333],{"class":453},"perf_counter",[206,6335,814],{"class":230},[206,6337,6338,6340,6343,6345,6348,6351,6353,6355,6357,6359,6362,6365,6367,6369,6371,6373,6376,6379,6381],{"class":208,"data-cue":304,"line":373},[206,6339,304],{"class":308},[206,6341,6342],{"class":230},"picks ",[206,6344,297],{"class":296},[206,6346,6347],{"class":230}," random.",[206,6349,6350],{"class":453},"choices",[206,6352,569],{"class":230},[206,6354,3619],{"class":360},[206,6356,464],{"class":230},[206,6358,3613],{"class":360},[206,6360,6361],{"class":230},"], ",[206,6363,6364],{"class":718},"weights",[206,6366,297],{"class":296},[206,6368,5034],{"class":230},[206,6370,304],{"class":300},[206,6372,964],{"class":296},[206,6374,6375],{"class":230}," p_rare, p_rare], ",[206,6377,6378],{"class":718},"k",[206,6380,297],{"class":296},[206,6382,724],{"class":230},[206,6384,6385,6387,6390,6392,6394,6396,6399,6402,6404,6406,6408,6410,6412,6414,6416,6418],{"class":208,"line":392},[206,6386,214],{"class":212,"aria-hidden":213},[206,6388,6389],{"class":230},"classical ",[206,6391,297],{"class":296},[206,6393,645],{"class":230},[206,6395,3613],{"class":360},[206,6397,6398],{"class":230},": picks.",[206,6400,6401],{"class":453},"count",[206,6403,457],{"class":230},[206,6405,3613],{"class":360},[206,6407,2583],{"class":230},[206,6409,3619],{"class":360},[206,6411,6398],{"class":230},[206,6413,6401],{"class":453},[206,6415,457],{"class":230},[206,6417,3619],{"class":360},[206,6419,4558],{"class":230},[206,6421,6422,6424,6427,6429,6431,6433,6435,6437],{"class":208,"line":407},[206,6423,214],{"class":212,"aria-hidden":213},[206,6425,6426],{"class":230},"classical_s ",[206,6428,297],{"class":296},[206,6430,6330],{"class":230},[206,6432,6333],{"class":453},[206,6434,741],{"class":230},[206,6436,2742],{"class":296},[206,6438,6439],{"class":230}," t0\n",[206,6441,6442,6444],{"class":208,"line":422},[206,6443,214],{"class":212,"aria-hidden":213},[206,6445,285],{},[206,6447,6448,6450],{"class":208,"line":430},[206,6449,214],{"class":212,"aria-hidden":213},[206,6451,6452],{"class":217},"# --- the quantum answer ------------------------------------------------------\n",[206,6454,6455,6457,6459,6461,6463,6465,6467,6469,6471],{"class":208,"line":437},[206,6456,214],{"class":212,"aria-hidden":213},[206,6458,1446],{"class":230},[206,6460,297],{"class":296},[206,6462,483],{"class":453},[206,6464,457],{"class":230},[206,6466,304],{"class":300},[206,6468,464],{"class":230},[206,6470,304],{"class":300},[206,6472,494],{"class":230},[206,6474,6475,6477,6479,6481,6483,6485,6487,6489,6491,6493,6496,6498],{"class":208,"data-cue":319,"line":445},[206,6476,319],{"class":308},[206,6478,3289],{"class":230},[206,6480,505],{"class":453},[206,6482,457],{"class":230},[206,6484,319],{"class":300},[206,6486,512],{"class":296},[206,6488,515],{"class":453},[206,6490,457],{"class":230},[206,6492,520],{"class":453},[206,6494,6495],{"class":230},"(p_rare)), ",[206,6497,526],{"class":300},[206,6499,494],{"class":230},[206,6501,6502,6504,6506,6508,6510,6512,6514,6516],{"class":208,"line":473},[206,6503,214],{"class":212,"aria-hidden":213},[206,6505,3289],{"class":230},[206,6507,566],{"class":453},[206,6509,457],{"class":230},[206,6511,526],{"class":300},[206,6513,464],{"class":230},[206,6515,526],{"class":300},[206,6517,494],{"class":230},[206,6519,6520,6522],{"class":208,"line":497},[206,6521,214],{"class":212,"aria-hidden":213},[206,6523,285],{},[206,6525,6526,6528,6531,6533,6535,6537],{"class":208,"line":531},[206,6527,214],{"class":212,"aria-hidden":213},[206,6529,6530],{"class":230},"t1 ",[206,6532,297],{"class":296},[206,6534,6330],{"class":230},[206,6536,6333],{"class":453},[206,6538,814],{"class":230},[206,6540,6541,6543,6545,6547,6549,6551,6553,6555,6557],{"class":208,"line":559},[206,6542,214],{"class":212,"aria-hidden":213},[206,6544,699],{"class":230},[206,6546,297],{"class":296},[206,6548,704],{"class":230},[206,6550,707],{"class":453},[206,6552,3693],{"class":230},[206,6554,719],{"class":718},[206,6556,297],{"class":296},[206,6558,724],{"class":230},[206,6560,6561,6563,6565,6567,6569,6571,6573,6575,6577,6579,6581,6583,6585,6587],{"class":208,"line":590},[206,6562,214],{"class":212,"aria-hidden":213},[206,6564,732],{"class":226},[206,6566,735],{"class":230},[206,6568,738],{"class":453},[206,6570,741],{"class":230},[206,6572,744],{"class":226},[206,6574,747],{"class":226},[206,6576,750],{"class":230},[206,6578,753],{"class":300},[206,6580,756],{"class":230},[206,6582,759],{"class":300},[206,6584,756],{"class":230},[206,6586,764],{"class":300},[206,6588,470],{"class":230},[206,6590,6591,6593,6595,6597,6599,6601],{"class":208,"data-cue":340,"line":601},[206,6592,340],{"class":308},[206,6594,774],{"class":230},[206,6596,777],{"class":453},[206,6598,457],{"class":230},[206,6600,304],{"class":300},[206,6602,494],{"class":230},[206,6604,6605,6607,6609,6611,6613,6615,6617,6619],{"class":208,"line":608},[206,6606,214],{"class":212,"aria-hidden":213},[206,6608,798],{"class":230},[206,6610,297],{"class":296},[206,6612,735],{"class":230},[206,6614,805],{"class":453},[206,6616,808],{"class":230},[206,6618,811],{"class":453},[206,6620,814],{"class":230},[206,6622,6623,6625,6628,6630,6632,6634,6637,6639,6641,6643,6645,6647,6649,6651,6653,6655,6657,6659,6661,6663],{"class":208,"line":616},[206,6624,214],{"class":212,"aria-hidden":213},[206,6626,6627],{"class":230},"quantum ",[206,6629,297],{"class":296},[206,6631,645],{"class":230},[206,6633,3613],{"class":360},[206,6635,6636],{"class":230},": counts.",[206,6638,2695],{"class":453},[206,6640,457],{"class":230},[206,6642,3596],{"class":360},[206,6644,464],{"class":230},[206,6646,526],{"class":300},[206,6648,2583],{"class":230},[206,6650,3619],{"class":360},[206,6652,6636],{"class":230},[206,6654,2695],{"class":453},[206,6656,457],{"class":230},[206,6658,2700],{"class":360},[206,6660,464],{"class":230},[206,6662,526],{"class":300},[206,6664,4558],{"class":230},[206,6666,6667,6669,6672,6674,6676,6678,6680,6682],{"class":208,"line":638},[206,6668,214],{"class":212,"aria-hidden":213},[206,6670,6671],{"class":230},"quantum_s ",[206,6673,297],{"class":296},[206,6675,6330],{"class":230},[206,6677,6333],{"class":453},[206,6679,741],{"class":230},[206,6681,2742],{"class":296},[206,6683,6684],{"class":230}," t1\n",[206,6686,6687,6689],{"class":208,"line":680},[206,6688,214],{"class":212,"aria-hidden":213},[206,6690,285],{},[206,6692,6693,6695],{"class":208,"line":687},[206,6694,214],{"class":212,"aria-hidden":213},[206,6696,6697],{"class":217},"# --- read the result honestly ------------------------------------------------\n",[206,6699,6700,6702,6704,6706,6708,6711,6713,6716,6718,6721,6723,6725,6727,6729,6732,6734,6737],{"class":208,"line":694},[206,6701,214],{"class":212,"aria-hidden":213},[206,6703,822],{"class":296},[206,6705,457],{"class":230},[206,6707,872],{"class":226},[206,6709,6710],{"class":360},"\"classical  ",[206,6712,878],{"class":300},[206,6714,6715],{"class":230},"classical",[206,6717,887],{"class":300},[206,6719,6720],{"class":360},"   in ",[206,6722,878],{"class":300},[206,6724,6426],{"class":230},[206,6726,945],{"class":296},[206,6728,4762],{"class":300},[206,6730,6731],{"class":226},":.2f",[206,6733,887],{"class":300},[206,6735,6736],{"class":360}," ms\"",[206,6738,494],{"class":230},[206,6740,6741,6743,6745,6747,6749,6752,6754,6757,6759,6761,6763,6766,6769,6771,6774],{"class":208,"line":727},[206,6742,214],{"class":212,"aria-hidden":213},[206,6744,822],{"class":296},[206,6746,457],{"class":230},[206,6748,872],{"class":226},[206,6750,6751],{"class":360},"\"quantum    ",[206,6753,878],{"class":300},[206,6755,6756],{"class":230},"quantum",[206,6758,887],{"class":300},[206,6760,6720],{"class":360},[206,6762,878],{"class":300},[206,6764,6765],{"class":230},"quantum_s",[206,6767,6768],{"class":226},":.1f",[206,6770,887],{"class":300},[206,6772,6773],{"class":360}," s\"",[206,6775,494],{"class":230},[206,6777,6778,6780,6782],{"class":208,"line":769},[206,6779,214],{"class":212,"aria-hidden":213},[206,6781,822],{"class":296},[206,6783,814],{"class":230},[206,6785,6786,6788,6791,6793,6796,6799,6801,6803,6805,6808,6810],{"class":208,"line":786},[206,6787,214],{"class":212,"aria-hidden":213},[206,6789,6790],{"class":230},"gap ",[206,6792,297],{"class":296},[206,6794,6795],{"class":296}," abs",[206,6797,6798],{"class":230},"(classical[",[206,6800,3613],{"class":360},[206,6802,5039],{"class":230},[206,6804,2742],{"class":296},[206,6806,6807],{"class":230}," quantum[",[206,6809,3613],{"class":360},[206,6811,587],{"class":230},[206,6813,6814,6816,6818,6820,6822,6825,6827,6830,6832,6835,6837,6839,6841,6843],{"class":208,"line":793},[206,6815,214],{"class":212,"aria-hidden":213},[206,6817,822],{"class":296},[206,6819,457],{"class":230},[206,6821,872],{"class":226},[206,6823,6824],{"class":360},"\"the two draws differ by ",[206,6826,878],{"class":300},[206,6828,6829],{"class":230},"gap",[206,6831,887],{"class":300},[206,6833,6834],{"class":360}," out of ",[206,6836,878],{"class":300},[206,6838,719],{"class":230},[206,6840,887],{"class":300},[206,6842,875],{"class":360},[206,6844,494],{"class":230},[206,6846,6847,6849,6851,6853,6856,6859,6862],{"class":208,"line":817},[206,6848,214],{"class":212,"aria-hidden":213},[206,6850,822],{"class":296},[206,6852,457],{"class":230},[206,6854,6855],{"class":360},"\"two independent 1,000-shot draws land within 40 of each other 95",[206,6857,6858],{"class":300},"% o",[206,6860,6861],{"class":360},"f the time,\"",[206,6863,494],{"class":230},[206,6865,6866,6868,6870,6872,6875],{"class":208,"data-cue":444,"line":828},[206,6867,444],{"class":308},[206,6869,822],{"class":296},[206,6871,457],{"class":230},[206,6873,6874],{"class":360},"\"so anything up to about 40 here is the two methods agreeing.\"",[206,6876,494],{"class":230},[206,6878,6879,6881,6883],{"class":208,"line":835},[206,6880,214],{"class":212,"aria-hidden":213},[206,6882,822],{"class":296},[206,6884,814],{"class":230},[206,6886,6887,6889,6891,6893,6895,6898,6900,6902,6904,6907,6910,6912,6915],{"class":208,"line":862},[206,6888,214],{"class":212,"aria-hidden":213},[206,6890,822],{"class":296},[206,6892,457],{"class":230},[206,6894,872],{"class":226},[206,6896,6897],{"class":360},"\"the quantum run took about ",[206,6899,878],{"class":300},[206,6901,6671],{"class":230},[206,6903,653],{"class":296},[206,6905,6906],{"class":230}," classical_s",[206,6908,6909],{"class":226},":,.0f",[206,6911,887],{"class":300},[206,6913,6914],{"class":360}," times as long,\"",[206,6916,494],{"class":230},[206,6918,6919,6921,6923,6925,6928],{"class":208,"line":927},[206,6920,214],{"class":212,"aria-hidden":213},[206,6922,822],{"class":296},[206,6924,457],{"class":230},[206,6926,6927],{"class":360},"\"almost all of it queue and round trip rather than computation.\"",[206,6929,494],{"class":230},[989,6931,6932,6939,6946,6953],{"class":991},[993,6933,6934,6936],{"data-cue":304},[206,6935,304],{"class":308},[206,6937,6938],{"class":999},"the whole classical solution",[993,6940,6941,6943],{"data-cue":319},[206,6942,319],{"class":308},[206,6944,6945],{"class":999},"the same distribution, prepared as an amplitude",[993,6947,6948,6950],{"data-cue":340},[206,6949,340],{"class":308},[206,6951,6952],{"class":999},"poll every second, so the timing below has 1s resolution",[993,6954,6955,6957],{"data-cue":444},[206,6956,444],{"class":308},[206,6958,6959],{"class":999},"from the binomial, not from this run",[12,6961,6962,6963,6965],{},"The classical side is one call to ",[203,6964,1051],{}," with weights. The quantum side is the circuit from lesson 3. Both produce 1,000 draws at the same probability, and the file times each.",[12,6967,1121,6968,1127,6971,1162,6973,1166,6975,1170,6977,6979],{},[37,6969,1932],{"href":6970},"https:\u002F\u002Fqollab.xyz\u002Fu\u002Fqollab\u002Flearn-app-race",[30,6972,1161],{},[30,6974,1165],{},[30,6976,1169],{},[30,6978,1173],{},". Our run on 22 September 2026:",[197,6981,6984],{"className":6982,"code":6983,"language":1103,"meta":193},[1101],"classical  {'rare': 281, 'common': 719}   in 0.20 ms\nquantum    {'rare': 292, 'common': 708}   in 13.8 s\n\nthe two draws differ by 11 out of 1000\ntwo independent 1,000-shot draws land within 40 of each other 95% of the time,\nso anything up to about 40 here is the two methods agreeing.\n\nthe quantum run took about 69,044 times as long,\nalmost all of it queue and round trip rather than computation.\n",[203,6985,6983],{"__ignoreMap":193},[12,6987,6988],{},"The two columns hold the same answer. Two samples of one distribution land within about 40 of each other at this many shots, and these are 11 apart, so neither column is more correct than the other.",[16,6990],{"alt":6991,"caption":6992,"no":20,"src":6993},"A bell-shaped curve of the difference between two independent 1,000-shot draws at probability 0.3, centred on zero, with a shaded band from minus 40 to plus 40 covering 95 percent of pairs, and a marker at plus 11 for the gap in the recorded race, sitting well inside the band.","The spread of the gap between two independent 1,000-shot draws at 0.3: 95% of pairs fall inside the shaded band, and the recorded race's 11 sits well inside it.","\u002F_content\u002Fimages\u002Freal-app\u002Feleven-apart.svg",[12,6995,6996,6997,6999],{},"That 40 is the figure for ",[203,6998,3965],{},", and the listing prints it whatever probability you set. The true window is widest near 0.5, about 44, and shrinks toward zero as the probability moves toward 0 or 1.",[12,7001,7002],{},"The two timings differ by about 69,000 times, which no tuning of the circuit would change: nearly all of that time is the round trip to IonQ's cloud.",[23,7004,7006],{"id":7005},"the-quantum-column-came-from-a-simulator","The quantum column came from a simulator",[12,7008,7009],{},"You ran on a simulator. The IonQ simulator is a program on a server, so the numbers in the quantum column were produced by classical hardware doing arithmetic, with no physical measurement involved.",[12,7011,7012],{},"So the race you just ran compares one classical method against another classical method that took 69,000 times longer. On real hardware the quantum column would come from a physical process. The timing gap would grow, because a QPU has a queue in front of it, and each run would cost credits.",[23,7014,7016],{"id":7015},"a-measured-draw-has-no-seed","A measured draw has no seed",[12,7018,7019,7020,7022],{},"On hardware, the draw comes from a measurement rather than from an algorithm. ",[203,7021,1051],{}," is a deterministic function of a seed. Given that seed you can reproduce every draw it will ever make. A measured qubit has no seed.",[12,7024,7025],{},"A loot box does not need an unpredictable draw. A lottery or an encryption key does, because someone has an incentive to predict the next draw, and hardware random number generators are sold on unpredictability.",[23,7027,7029],{"id":7028},"quantum-couriers-five-races","Quantum Courier's five races",[12,7031,7032,7036],{},[37,7033,7035],{"href":7034},"\u002Fexplore\u002Fquantum-courier","Quantum Courier"," is a browser game by Dr. Siti Fariya that races classical and quantum solvers across five logistics problems and publishes which won.",[12,7038,7039],{},"Quantum Courier's published results:",[2982,7041,7042,7052],{},[2985,7043,7044],{},[2988,7045,7046,7049],{},[2991,7047,7048],{},"stage",[2991,7050,7051],{},"who won",[2997,7053,7054,7062,7070,7078,7086],{},[2988,7055,7056,7059],{},[3002,7057,7058],{},"Pizza assignment",[3002,7060,7061],{},"Classical, with the Hungarian algorithm.",[2988,7063,7064,7067],{},[3002,7065,7066],{},"Single-vehicle routing",[3002,7068,7069],{},"Tied at small sizes, classical scales better.",[2988,7071,7072,7075],{},[3002,7073,7074],{},"Multi-vehicle with time windows",[3002,7076,7077],{},"Classical, annealing beating QAOA at 25 customers.",[2988,7079,7080,7083],{},[3002,7081,7082],{},"Graph cutting (MaxCut)",[3002,7084,7085],{},"Quantum, over a random-cut baseline, per the write-up.",[2988,7087,7088,7091],{},[3002,7089,7090],{},"Combined planning",[3002,7092,7093],{},"Depends on the instance.",[12,7095,7096],{},"Siti kept the stage 3 loss in the game deliberately, having tested four QAOA variants on Forte against classical simulated annealing. The write-up explains why: MaxCut has a cost function that counts cut edges, and that lines up with what a shallow parameterized circuit can express. Vehicle routing has no such property at the scales we can run today, and it is measured against classical heuristics that are decades mature.",[1363,7098,7103],{"avatar":7099,"name":7100,"role":7101,"username":7102},"\u002F_content\u002Fimages\u002Fbuilders\u002Fsiti-fariya.webp","Dr. Siti Fariya","Creator, Quantum Courier","Sitifar",[12,7104,7105],{},"Operators making real decisions need to know where quantum helps and where classical methods still win.",[23,7107,7109],{"id":7108},"qubits-error-rate-latency-and-cost-as-of-september-2026","Qubits, error rate, latency and cost, as of September 2026",[12,7111,7112],{},"For almost anything you build this year, conventional code is the right answer. That verdict is dated September 2026, and it depends on four quantities you can look up.",[12,7114,7115,7118],{},[30,7116,7117],{},"Qubit count."," The IonQ machines on this platform run 25 to 36 qubits. Your laptop solves a problem over 36 binary variables exactly by trying all 2^36 assignments, which takes about a minute.",[12,7120,7121,7124],{},[30,7122,7123],{},"Error rate."," Gates and measurements are imperfect, so a deep circuit's signal degrades as it runs. Regime Radar's own similarity score shows that degradation. Pressed at 2,048 shots on 22 September 2026, its twelve-qubit inversion test read 0.1768 on the noise-free built-in simulator and 0.0337 on the Aria 1 noise model, the same circuit both times, against an exact offline value of 0.1779.",[12,7126,7127,7130],{},[30,7128,7129],{},"Queue latency."," Your race measured 13.8 seconds against 0.20 milliseconds, on a simulator with no hardware queue in front of it.",[12,7132,7133,7136],{},[30,7134,7135],{},"Cost per run."," Simulators are free on Qollab. QPU time is metered.",[23,7138,7140],{"id":7139},"five-steps-for-the-comparison","Five steps for the comparison",[12,7142,7143,7146],{},[30,7144,7145],{},"Write the thresholds before you run anything."," Decide what the feature needs: how close the answer has to be, how long a user will wait, and what you are willing to spend per call. Write those numbers down before either implementation exists, because a threshold chosen after seeing the result can be chosen to fit it.",[12,7148,7149,7152],{},[30,7150,7151],{},"Solve it the ordinary way first."," The classical version is your baseline and often your answer. The classical version also tells you what \"correct\" looks like, which you need before you can judge the quantum one.",[12,7154,7155,7158],{},[30,7156,7157],{},"Solve it the quantum way, at the same task."," Give the quantum version the same inputs, output format and scoring function. The race listing puts both in one file so that a single function scores both.",[12,7160,7161,7164],{},[30,7162,7163],{},"Compare each result against the thresholds."," A relative comparison is not enough: \"quantum was only a little worse\" says nothing about whether you can ship it. Record whether each requirement was met or missed, and by how much. Our run would pass any reasonable accuracy threshold, since the two tallies were 11 apart, and fail any reasonable latency threshold, at 13.8 seconds against 0.20 milliseconds.",[12,7166,7167,7170],{},[30,7168,7169],{},"Write down the date and the backend."," A comparison with no date on it can mislead once qubit count, error rate, latency or cost have changed.",[1110,7172,7174,7178,7217],{"check":7173},"you have two rare counts whose gap fits the 95% window for your probability, two timings that differ by orders of magnitude, and a written answer to step 6.",[23,7175,7177],{"id":7176},"assignment-race-a-probability-your-own-app-would-use","Assignment: race a probability your own app would use",[989,7179,7180,7190,7195,7198,7208,7214],{},[993,7181,1121,7182,1127,7186,1131,7188,1135],{},[37,7183,7184],{"href":6970},[203,7185,6215],{},[30,7187,1130],{},[30,7189,1134],{},[993,7191,4426,7192,7194],{},[203,7193,1258],{}," to a probability something you have built would use.",[993,7196,7197],{},"Predict whether the two columns will still agree, and predict which will be faster.",[993,7199,1158,7200,1162,7202,1166,7204,1170,7206,1174],{},[30,7201,1161],{},[30,7203,1165],{},[30,7205,1169],{},[30,7207,1173],{},[993,7209,7210,7211,7213],{},"Write down the gap between the two ",[203,7212,5056],{}," counts and the two timings.",[993,7215,7216],{},"Decide, in one sentence, whether you would ship the quantum version of that feature.",[1179,7218,7219,7224,7227],{"label":1181},[12,7220,7221,7222,1174],{},"The two columns agree at any probability, because both are sampling the same distribution. The window that holds 95% of the gaps depends on the probability: about 44 at 0.5, 40 at 0.3, 26 at 0.1 and 19 at 0.05, so compare your gap with the window for your own ",[203,7223,1258],{},[12,7225,7226],{},"The classical side stays in fractions of a millisecond. The quantum side stays in seconds.",[12,7228,7229],{},"The one-sentence answer is almost certainly no, because of the timing gap your own two numbers show.",[23,7231,1294],{"id":1293},[12,7233,7234],{},"Answer whether quantum is worth it with a race on the backend you would ship on. Write the accuracy, latency and cost the feature needs before building either version, then pass or fail both results against those thresholds, and date the verdict with its backend. As of September 2026, the classical version wins that race for almost any feature you would ship.",[12,7236,7237],{},"Lesson 6 sorts ideas by the output the application needs, before either version is built.",[1299,7239,7240],{},"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 .sjrmR, html code.shiki .sjrmR{--shiki-default:#56B6C2}html pre.shiki code .sVC51, html code.shiki .sVC51{--shiki-default:#D19A66}html pre.shiki code .sVbv2, html code.shiki .sVbv2{--shiki-default:#61AFEF}html pre.shiki code .subq3, html code.shiki .subq3{--shiki-default:#98C379}html pre.shiki code .s_ZVi, html code.shiki .s_ZVi{--shiki-default:#E06C75;--shiki-default-font-style:italic}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);}",{"title":193,"searchDepth":221,"depth":221,"links":7242},[7243,7244,7245,7246,7247,7248,7249,7250],{"id":6208,"depth":221,"text":6209},{"id":7005,"depth":221,"text":7006},{"id":7015,"depth":221,"text":7016},{"id":7028,"depth":221,"text":7029},{"id":7108,"depth":221,"text":7109},{"id":7139,"depth":221,"text":7140},{"id":7176,"depth":221,"text":7177},{"id":1293,"depth":221,"text":1294},[1312,1313,1314,6187],[],{"username":7,"name":1317,"role":1318,"avatar":1319},"Run the same thousand draws in quantum and classical code in one press, compare counts and timings, and weigh qubit count, error rate, latency and cost.",{},{"slug":1333,"title":5,"desc":1321},[],{"title":6187,"description":7254},"blog\u002Flearn\u002Fusing-quantum-in-a-real-application\u002Fis-quantum-worth-it",[],"7FNyO1s3kUQE-JUjlwOMGmxdt29FEtkZFmMJScghJ_U",{"id":4,"title":5,"authors":7263,"body":7264,"breadcrumb":8180,"builders":8181,"byline":8182,"category":1320,"categoryName":1320,"challenge":1320,"courseAuthor":1320,"courseLead":1320,"dek":1321,"description":1322,"draft":1323,"extension":1324,"eyebrow":1320,"featured":1323,"finish":1325,"fork":1320,"group":1320,"groupName":1320,"hero":1320,"heroAlt":1320,"heroCta":1320,"heroImage":1320,"homepageFeatured":1323,"kind":1326,"lessonCount":280,"meta":8183,"navigation":1328,"newsItems":1320,"next":8184,"ogImage":1320,"order":280,"outcomes":1320,"path":1333,"prerequisite":1320,"prerequisiteLinks":1320,"publishDate":1334,"readingTime":1320,"related":8185,"relatedProjects":1320,"section":1320,"seo":8186,"stem":1337,"tags":8187,"track":1339,"trackName":1314,"__hash__":1340},[7],{"type":9,"value":7265,"toc":8171},[7266,7268,7270,7272,7276,7284,7290,7300,7302,7312,7322,7324,7326,7328,7332,7336,7340,7344,7346,7348,7350,7352,7354,7356,7358,7360,7996,7998,8010,8024,8032,8038,8043,8045,8117,8165,8167,8169],[12,7267,14],{},[16,7269],{"alt":18,"caption":19,"no":20,"src":21},[23,7271,26],{"id":25},[12,7273,7274,33],{},[30,7275,32],{},[12,7277,7278,41,7280,46,7282,51],{},[37,7279,40],{"href":39},[37,7281,45],{"href":44},[37,7283,50],{"href":49},[12,7285,7286,57,7288,62],{},[30,7287,56],{},[37,7289,61],{"href":60},[12,7291,7292,68,7294,73,7296,78,7298,83],{},[30,7293,67],{},[37,7295,72],{"href":71},[37,7297,77],{"href":76},[37,7299,82],{"href":81},[12,7301,86],{},[12,7303,7304,92,7306,97,7308,102,7310,107],{},[30,7305,91],{},[37,7307,96],{"href":95},[37,7309,101],{"href":100},[37,7311,106],{"href":105},[12,7313,7314,113,7316,118,7318,123,7320,128],{},[30,7315,112],{},[37,7317,117],{"href":116},[37,7319,122],{"href":121},[37,7321,127],{"href":126},[12,7323,131],{},[23,7325,135],{"id":134},[12,7327,138],{},[12,7329,7330,144],{},[30,7331,143],{},[12,7333,7334,150],{},[30,7335,149],{},[12,7337,7338,156],{},[30,7339,155],{},[12,7341,7342,162],{},[30,7343,161],{},[12,7345,165],{},[23,7347,169],{"id":168},[12,7349,172],{},[12,7351,175],{},[12,7353,178],{},[23,7355,182],{"id":181},[12,7357,185],{},[12,7359,188],{},[190,7361,7362],{"name":192,"no-picker":193,"run-href":194,"tag":195},[197,7363,7364],{"className":199,"code":200,"language":201,"meta":193,"style":193},[203,7365,7366,7372,7384,7396,7408,7416,7422,7432,7442,7452,7458,7468,7480,7494,7506,7518,7524,7530,7536,7554,7574,7600,7626,7652,7660,7666,7672,7690,7720,7726,7732,7756,7786,7800,7806,7824,7832,7838,7860,7910,7964],{"__ignoreMap":193},[206,7367,7368,7370],{"class":208,"line":209},[206,7369,214],{"class":212,"aria-hidden":213},[206,7371,218],{"class":217},[206,7373,7374,7376,7378,7380,7382],{"class":208,"line":221},[206,7375,214],{"class":212,"aria-hidden":213},[206,7377,227],{"class":226},[206,7379,231],{"class":230},[206,7381,234],{"class":226},[206,7383,237],{"class":230},[206,7385,7386,7388,7390,7392,7394],{"class":208,"line":240},[206,7387,214],{"class":212,"aria-hidden":213},[206,7389,227],{"class":226},[206,7391,247],{"class":230},[206,7393,234],{"class":226},[206,7395,252],{"class":230},[206,7397,7398,7400,7402,7404,7406],{"class":208,"line":255},[206,7399,214],{"class":212,"aria-hidden":213},[206,7401,227],{"class":226},[206,7403,262],{"class":230},[206,7405,234],{"class":226},[206,7407,267],{"class":230},[206,7409,7410,7412,7414],{"class":208,"line":270},[206,7411,214],{"class":212,"aria-hidden":213},[206,7413,234],{"class":226},[206,7415,277],{"class":230},[206,7417,7418,7420],{"class":208,"line":280},[206,7419,214],{"class":212,"aria-hidden":213},[206,7421,285],{},[206,7423,7424,7426,7428,7430],{"class":208,"line":288},[206,7425,214],{"class":212,"aria-hidden":213},[206,7427,293],{"class":230},[206,7429,297],{"class":296},[206,7431,301],{"class":300},[206,7433,7434,7436,7438,7440],{"class":208,"data-cue":304,"line":305},[206,7435,304],{"class":308},[206,7437,311],{"class":230},[206,7439,297],{"class":296},[206,7441,316],{"class":300},[206,7443,7444,7446,7448,7450],{"class":208,"data-cue":319,"line":320},[206,7445,319],{"class":308},[206,7447,325],{"class":230},[206,7449,297],{"class":296},[206,7451,330],{"class":300},[206,7453,7454,7456],{"class":208,"line":333},[206,7455,214],{"class":212,"aria-hidden":213},[206,7457,285],{},[206,7459,7460,7462,7464,7466],{"class":208,"data-cue":340,"line":341},[206,7461,340],{"class":308},[206,7463,346],{"class":300},[206,7465,349],{"class":296},[206,7467,352],{"class":230},[206,7469,7470,7472,7474,7476,7478],{"class":208,"line":355},[206,7471,214],{"class":212,"aria-hidden":213},[206,7473,361],{"class":360},[206,7475,364],{"class":230},[206,7477,367],{"class":360},[206,7479,370],{"class":230},[206,7481,7482,7484,7486,7488,7490,7492],{"class":208,"line":373},[206,7483,214],{"class":212,"aria-hidden":213},[206,7485,378],{"class":360},[206,7487,364],{"class":230},[206,7489,383],{"class":360},[206,7491,386],{"class":230},[206,7493,389],{"class":217},[206,7495,7496,7498,7500,7502,7504],{"class":208,"line":392},[206,7497,214],{"class":212,"aria-hidden":213},[206,7499,397],{"class":360},[206,7501,364],{"class":230},[206,7503,402],{"class":360},[206,7505,370],{"class":230},[206,7507,7508,7510,7512,7514,7516],{"class":208,"line":407},[206,7509,214],{"class":212,"aria-hidden":213},[206,7511,412],{"class":360},[206,7513,364],{"class":230},[206,7515,417],{"class":360},[206,7517,370],{"class":230},[206,7519,7520,7522],{"class":208,"line":422},[206,7521,214],{"class":212,"aria-hidden":213},[206,7523,427],{"class":230},[206,7525,7526,7528],{"class":208,"line":430},[206,7527,214],{"class":212,"aria-hidden":213},[206,7529,285],{},[206,7531,7532,7534],{"class":208,"line":437},[206,7533,214],{"class":212,"aria-hidden":213},[206,7535,285],{},[206,7537,7538,7540,7542,7544,7546,7548,7550,7552],{"class":208,"data-cue":444,"line":445},[206,7539,444],{"class":308},[206,7541,450],{"class":226},[206,7543,454],{"class":453},[206,7545,457],{"class":230},[206,7547,461],{"class":460},[206,7549,464],{"class":230},[206,7551,467],{"class":460},[206,7553,470],{"class":230},[206,7555,7556,7558,7560,7562,7564,7566,7568,7570,7572],{"class":208,"line":473},[206,7557,214],{"class":212,"aria-hidden":213},[206,7559,478],{"class":230},[206,7561,297],{"class":296},[206,7563,483],{"class":453},[206,7565,457],{"class":230},[206,7567,319],{"class":300},[206,7569,464],{"class":230},[206,7571,319],{"class":300},[206,7573,494],{"class":230},[206,7575,7576,7578,7580,7582,7584,7586,7588,7590,7592,7594,7596,7598],{"class":208,"line":497},[206,7577,214],{"class":212,"aria-hidden":213},[206,7579,502],{"class":230},[206,7581,505],{"class":453},[206,7583,457],{"class":230},[206,7585,319],{"class":300},[206,7587,512],{"class":296},[206,7589,515],{"class":453},[206,7591,457],{"class":230},[206,7593,520],{"class":453},[206,7595,523],{"class":230},[206,7597,526],{"class":300},[206,7599,494],{"class":230},[206,7601,7602,7604,7606,7608,7610,7612,7614,7616,7618,7620,7622,7624],{"class":208,"line":531},[206,7603,214],{"class":212,"aria-hidden":213},[206,7605,502],{"class":230},[206,7607,505],{"class":453},[206,7609,457],{"class":230},[206,7611,319],{"class":300},[206,7613,512],{"class":296},[206,7615,515],{"class":453},[206,7617,457],{"class":230},[206,7619,520],{"class":453},[206,7621,552],{"class":230},[206,7623,304],{"class":300},[206,7625,494],{"class":230},[206,7627,7628,7630,7632,7634,7636,7638,7640,7642,7644,7646,7648,7650],{"class":208,"line":559},[206,7629,214],{"class":212,"aria-hidden":213},[206,7631,502],{"class":230},[206,7633,566],{"class":453},[206,7635,569],{"class":230},[206,7637,526],{"class":300},[206,7639,464],{"class":230},[206,7641,304],{"class":300},[206,7643,578],{"class":230},[206,7645,526],{"class":300},[206,7647,464],{"class":230},[206,7649,304],{"class":300},[206,7651,587],{"class":230},[206,7653,7654,7656,7658],{"class":208,"line":590},[206,7655,214],{"class":212,"aria-hidden":213},[206,7657,595],{"class":226},[206,7659,598],{"class":230},[206,7661,7662,7664],{"class":208,"line":601},[206,7663,214],{"class":212,"aria-hidden":213},[206,7665,285],{},[206,7667,7668,7670],{"class":208,"line":608},[206,7669,214],{"class":212,"aria-hidden":213},[206,7671,285],{},[206,7673,7674,7676,7678,7680,7682,7684,7686,7688],{"class":208,"data-cue":615,"line":616},[206,7675,615],{"class":308},[206,7677,450],{"class":226},[206,7679,623],{"class":453},[206,7681,457],{"class":230},[206,7683,628],{"class":460},[206,7685,464],{"class":230},[206,7687,633],{"class":460},[206,7689,470],{"class":230},[206,7691,7692,7694,7696,7698,7700,7702,7704,7706,7708,7710,7712,7714,7716,7718],{"class":208,"line":638},[206,7693,214],{"class":212,"aria-hidden":213},[206,7695,595],{"class":226},[206,7697,645],{"class":230},[206,7699,346],{"class":300},[206,7701,650],{"class":230},[206,7703,653],{"class":296},[206,7705,656],{"class":230},[206,7707,659],{"class":226},[206,7709,662],{"class":230},[206,7711,665],{"class":226},[206,7713,668],{"class":296},[206,7715,671],{"class":230},[206,7717,674],{"class":453},[206,7719,677],{"class":230},[206,7721,7722,7724],{"class":208,"line":680},[206,7723,214],{"class":212,"aria-hidden":213},[206,7725,285],{},[206,7727,7728,7730],{"class":208,"line":687},[206,7729,214],{"class":212,"aria-hidden":213},[206,7731,285],{},[206,7733,7734,7736,7738,7740,7742,7744,7746,7748,7750,7752,7754],{"class":208,"line":694},[206,7735,214],{"class":212,"aria-hidden":213},[206,7737,699],{"class":230},[206,7739,297],{"class":296},[206,7741,704],{"class":230},[206,7743,707],{"class":453},[206,7745,457],{"class":230},[206,7747,712],{"class":453},[206,7749,715],{"class":230},[206,7751,719],{"class":718},[206,7753,297],{"class":296},[206,7755,724],{"class":230},[206,7757,7758,7760,7762,7764,7766,7768,7770,7772,7774,7776,7778,7780,7782,7784],{"class":208,"line":727},[206,7759,214],{"class":212,"aria-hidden":213},[206,7761,732],{"class":226},[206,7763,735],{"class":230},[206,7765,738],{"class":453},[206,7767,741],{"class":230},[206,7769,744],{"class":226},[206,7771,747],{"class":226},[206,7773,750],{"class":230},[206,7775,753],{"class":300},[206,7777,756],{"class":230},[206,7779,759],{"class":300},[206,7781,756],{"class":230},[206,7783,764],{"class":300},[206,7785,470],{"class":230},[206,7787,7788,7790,7792,7794,7796,7798],{"class":208,"line":769},[206,7789,214],{"class":212,"aria-hidden":213},[206,7791,774],{"class":230},[206,7793,777],{"class":453},[206,7795,457],{"class":230},[206,7797,615],{"class":300},[206,7799,494],{"class":230},[206,7801,7802,7804],{"class":208,"line":786},[206,7803,214],{"class":212,"aria-hidden":213},[206,7805,285],{},[206,7807,7808,7810,7812,7814,7816,7818,7820,7822],{"class":208,"line":793},[206,7809,214],{"class":212,"aria-hidden":213},[206,7811,798],{"class":230},[206,7813,297],{"class":296},[206,7815,735],{"class":230},[206,7817,805],{"class":453},[206,7819,808],{"class":230},[206,7821,811],{"class":453},[206,7823,814],{"class":230},[206,7825,7826,7828,7830],{"class":208,"line":817},[206,7827,214],{"class":212,"aria-hidden":213},[206,7829,822],{"class":296},[206,7831,825],{"class":230},[206,7833,7834,7836],{"class":208,"line":828},[206,7835,214],{"class":212,"aria-hidden":213},[206,7837,285],{},[206,7839,7840,7842,7844,7846,7848,7850,7852,7854,7856,7858],{"class":208,"line":835},[206,7841,214],{"class":212,"aria-hidden":213},[206,7843,659],{"class":226},[206,7845,842],{"class":230},[206,7847,665],{"class":226},[206,7849,668],{"class":296},[206,7851,457],{"class":230},[206,7853,851],{"class":453},[206,7855,854],{"class":230},[206,7857,674],{"class":453},[206,7859,859],{"class":230},[206,7861,7862,7864,7866,7868,7870,7872,7874,7876,7878,7880,7882,7884,7886,7888,7890,7892,7894,7896,7898,7900,7902,7904,7906,7908],{"class":208,"line":862},[206,7863,214],{"class":212,"aria-hidden":213},[206,7865,867],{"class":296},[206,7867,457],{"class":230},[206,7869,872],{"class":226},[206,7871,875],{"class":360},[206,7873,878],{"class":300},[206,7875,881],{"class":230},[206,7877,884],{"class":226},[206,7879,887],{"class":300},[206,7881,645],{"class":300},[206,7883,892],{"class":230},[206,7885,895],{"class":226},[206,7887,887],{"class":300},[206,7889,900],{"class":300},[206,7891,903],{"class":360},[206,7893,512],{"class":296},[206,7895,908],{"class":296},[206,7897,457],{"class":230},[206,7899,913],{"class":300},[206,7901,512],{"class":296},[206,7903,918],{"class":230},[206,7905,887],{"class":300},[206,7907,875],{"class":360},[206,7909,494],{"class":230},[206,7911,7912,7914,7916,7918,7920,7922,7924,7926,7928,7930,7932,7934,7936,7938,7940,7942,7944,7946,7948,7950,7952,7954,7956,7958,7960,7962],{"class":208,"line":927},[206,7913,214],{"class":212,"aria-hidden":213},[206,7915,822],{"class":296},[206,7917,457],{"class":230},[206,7919,872],{"class":226},[206,7921,938],{"class":360},[206,7923,878],{"class":300},[206,7925,311],{"class":230},[206,7927,945],{"class":296},[206,7929,948],{"class":230},[206,7931,895],{"class":226},[206,7933,887],{"class":300},[206,7935,955],{"class":360},[206,7937,878],{"class":300},[206,7939,457],{"class":230},[206,7941,304],{"class":300},[206,7943,964],{"class":296},[206,7945,967],{"class":230},[206,7947,945],{"class":296},[206,7949,972],{"class":230},[206,7951,304],{"class":300},[206,7953,964],{"class":296},[206,7955,979],{"class":230},[206,7957,895],{"class":226},[206,7959,887],{"class":300},[206,7961,875],{"class":360},[206,7963,494],{"class":230},[989,7965,7966,7972,7978,7984,7990],{"class":991},[993,7967,7968,7970],{"data-cue":304},[206,7969,304],{"class":308},[206,7971,1000],{"class":999},[993,7973,7974,7976],{"data-cue":319},[206,7975,319],{"class":308},[206,7977,1007],{"class":999},[993,7979,7980,7982],{"data-cue":340},[206,7981,340],{"class":308},[206,7983,1014],{"class":999},[993,7985,7986,7988],{"data-cue":444},[206,7987,444],{"class":308},[206,7989,1021],{"class":999},[993,7991,7992,7994],{"data-cue":615},[206,7993,615],{"class":308},[206,7995,1028],{"class":999},[12,7997,1031],{},[12,7999,8000,1037,8002,1041,8004,1045,8006,1048,8008,1052],{},[30,8001,1036],{},[203,8003,1040],{},[203,8005,1044],{},[203,8007,505],{},[203,8009,1051],{},[12,8011,8012,1037,8014,1060,8016,464,8018,464,8020,1041,8022,1073],{},[30,8013,1057],{},[203,8015,346],{},[203,8017,1063],{},[203,8019,1066],{},[203,8021,1069],{},[203,8023,1072],{},[12,8025,8026,1079,8028,1083,8030,1087],{},[30,8027,1078],{},[203,8029,1082],{},[203,8031,1086],{},[12,8033,1090,8034,1041,8036,1097],{},[203,8035,1093],{},[203,8037,1096],{},[197,8039,8041],{"className":8040,"code":1102,"language":1103,"meta":193},[1101],[203,8042,1102],{"__ignoreMap":193},[12,8044,1108],{},[1110,8046,8047,8049,8087],{"check":1112},[23,8048,1116],{"id":1115},[989,8050,8051,8061,8065,8071,8073,8075,8085],{},[993,8052,1121,8053,1127,8057,1131,8059,1135],{},[37,8054,8055],{"href":1124},[203,8056,194],{},[30,8058,1130],{},[30,8060,1134],{},[993,8062,1138,8063,1141],{},[203,8064,346],{},[993,8066,1144,8067,1041,8069,1149],{},[203,8068,1040],{},[203,8070,1044],{},[993,8072,1152],{},[993,8074,1155],{},[993,8076,1158,8077,1162,8079,1166,8081,1170,8083,1174],{},[30,8078,1161],{},[30,8080,1165],{},[30,8082,1169],{},[30,8084,1173],{},[993,8086,1177],{},[1179,8088,8089,8107,8113],{"label":1181},[12,8090,1184,8091,464,8093,464,8095,1041,8097,1197,8099,464,8101,464,8103,464,8105,1174],{},[203,8092,1187],{},[203,8094,1190],{},[203,8096,1193],{},[203,8098,1196],{},[203,8100,1063],{},[203,8102,1066],{},[203,8104,1069],{},[203,8106,1072],{},[12,8108,1208,8109,1211,8111,1214],{},[203,8110,1066],{},[203,8112,1069],{},[12,8114,1217,8115,1221],{},[203,8116,1220],{},[1110,8118,8119,8121,8123,8153],{"check":1224},[23,8120,1228],{"id":1227},[12,8122,1231],{},[989,8124,8125,8127,8129,8137,8141,8151],{},[993,8126,1236],{},[993,8128,1239],{},[993,8130,1242,8131,1249,8135,1253],{},[37,8132,8133],{"href":1245},[203,8134,1248],{},[203,8136,1252],{},[993,8138,1144,8139,1259],{},[203,8140,1258],{},[993,8142,1158,8143,1162,8145,1166,8147,1170,8149,1174],{},[30,8144,1161],{},[30,8146,1165],{},[30,8148,1169],{},[30,8150,1173],{},[993,8152,1272],{},[1179,8154,8155,8161,8163],{"label":1181},[12,8156,1277,8157,1281,8159,1284],{},[203,8158,1280],{},[203,8160,505],{},[12,8162,1287],{},[12,8164,1290],{},[23,8166,1294],{"id":1293},[12,8168,1297],{},[1299,8170,1301],{},{"title":193,"searchDepth":221,"depth":221,"links":8172},[8173,8174,8175,8176,8177,8178,8179],{"id":25,"depth":221,"text":26},{"id":134,"depth":221,"text":135},{"id":168,"depth":221,"text":169},{"id":181,"depth":221,"text":182},{"id":1115,"depth":221,"text":1116},{"id":1227,"depth":221,"text":1228},{"id":1293,"depth":221,"text":1294},[1312,1313,1314,5],[],{"username":7,"name":1317,"role":1318,"avatar":1319},{},{"slug":1330,"title":1331,"desc":1332},[],{"title":5,"description":1322},[],[],1790341763412]