// Cell 2: Problem Generator Logic & Displayproblem = { generateButton;// Listens to button clicks to re-run cellconst initialStates = ["\\frac{1}{\\sqrt{2}}|0\\rangle + \\frac{1}{\\sqrt{2}}|1\\rangle","\\frac{1}{\\sqrt{2}}|0\\rangle + \\frac{i}{\\sqrt{2}}|1\\rangle","\\frac{1}{\\sqrt{2}}|0\\rangle - \\frac{i}{\\sqrt{2}}|1\\rangle","\\frac{1}{\\sqrt{5}}|0\\rangle + \\frac{2}{\\sqrt{5}}|1\\rangle","\\frac{1}{\\sqrt{5}}|0\\rangle + \\frac{2i}{\\sqrt{5}}|1\\rangle","\\frac{3}{5}|0\\rangle + \\frac{4i}{5}|1\\rangle","\\frac{1}{\\sqrt{3}}|0\\rangle + \\frac{\\sqrt{2}i}{\\sqrt{3}}|1\\rangle","\\frac{2}{3}|0\\rangle - \\frac{\\sqrt{5}i}{3}|1\\rangle" ];const bases = [ ["\\frac{1}{\\sqrt{2}}|0\\rangle + \\frac{1}{\\sqrt{2}}|1\\rangle","\\frac{1}{\\sqrt{2}}|0\\rangle - \\frac{1}{\\sqrt{2}}|1\\rangle" ], ["\\frac{1}{\\sqrt{2}}|0\\rangle + \\frac{i}{\\sqrt{2}}|1\\rangle","\\frac{1}{\\sqrt{2}}|0\\rangle - \\frac{i}{\\sqrt{2}}|1\\rangle" ], ["\\frac{1}{\\sqrt{5}}|0\\rangle + \\frac{2i}{\\sqrt{5}}|1\\rangle","\\frac{2i}{\\sqrt{5}}|0\\rangle + \\frac{1}{\\sqrt{5}}|1\\rangle" ], ["\\frac{3}{5}|0\\rangle + \\frac{4}{5}|1\\rangle","\\frac{4}{5}|0\\rangle - \\frac{3}{5}|1\\rangle" ], ["\\frac{1}{\\sqrt{3}}|0\\rangle + \\frac{\\sqrt{2}i}{\\sqrt{3}}|1\\rangle","\\frac{\\sqrt{2}i}{\\sqrt{3}}|0\\rangle + \\frac{1}{\\sqrt{3}}|1\\rangle" ], ["|0\\rangle","|1\\rangle" ] ];const state = initialStates[Math.floor(Math.random() * initialStates.length)];const basis = bases[Math.floor(Math.random() * bases.length)];const outcome = basis[Math.floor(Math.random() * basis.length)];returnhtml`<p>Suppose you have a qubit in the state ${tex`|\psi\rangle = ${state}`}, and you make a measurement in the basis ${tex`M = \{${basis[0]},${basis[1]}\}`}.</p> <ul> <li>What is the probability of outcome ${tex`${outcome}`}? (Your probability need not be totally simplified, but it should not contain any absolute values or imaginary numbers.)</li> <li>In this case, what does ${tex`|\psi\rangle`} collapse to?</li> </ul>`;}
Gemini was used to assist in generating the code that produces the randomized problems on this page. While AI contributed to this content, it was designed, reviewed, and approved by Prof. Shelby Kimmel.