// Cell 2: Problem Generator Logic & Displayproblem = {// Dependency on the button ensures this cell re-runs when clicked generateButton;// Use String.raw so backslashes don't need to be doubled (e.g., \rangle stays \rangle)const phis = [String.raw`|0\rangle`,String.raw`|1\rangle`,String.raw`|+\rangle`,String.raw`|-\rangle`,String.raw`|r\rangle`,String.raw`|l\rangle` ];const Ts = ['I',String.raw`45^\circ \text{ waveplate}`,String.raw`90^\circ \text{ waveplate}`,String.raw`135^\circ \text{ waveplate}`,String.raw`180^\circ \text{ waveplate}`,'rainbow bomb' ];// Helper to pick a random elementconst randomElement = (arr) => arr[Math.floor(Math.random() * arr.length)];const phi =randomElement(phis);const T1 =randomElement(Ts);const T2 =randomElement(Ts);// Observable's tex can also be called as a standard function: tex(string)const formatT = (t) => t.includes('^') || t ==='I'?tex`${t}`: t;// Use SINGLE backslashes inside all tex`...` template literalsreturnhtml` <div> Let ${tex`|\psi\rangle`} be the state ${tex`${phi}_P |H\rangle_D`}. Let ${tex`T_1`} be a ${formatT(T1)}. Let ${tex`T_2`} be a ${formatT(T2)}. Assuming the bomb does not detonate (if there is a bomb) describe the photon that exits the interferometer using <ul> <li>words, and</li> <li>ket notation.</li> </ul> <p>Extra Info:</p> <ul> <li>To describe the photon in words, you should say something like, "a right diagonally polarized photon traveling to the right" or "the photon is in a superposition of traveling right and down, the right traveling photon is vertically polarized, and the down traveling photon is horizontally polarized."</li> <li>A ${tex`45^\circ`} waveplate takes ${tex`|0\rangle_P \rightarrow |+\rangle_P `} and takes ${tex`|1\rangle_P \rightarrow |-\rangle_P `}</li> <li>A ${tex`90^\circ`} waveplate takes ${tex`|0\rangle_P \rightarrow |1\rangle_P `} and takes ${tex`|1\rangle_P \rightarrow |0\rangle_P `}</li> <li>A ${tex`135^\circ`} waveplate takes ${tex`|0\rangle_P \rightarrow |-\rangle_P `} and takes ${tex`|1\rangle_P \rightarrow |+\rangle_P`}</li> <li>A ${tex`180^\circ`} wave plate takes ${tex`|0\rangle_P \rightarrow -|0\rangle_P`} and takes ${tex`|1\rangle_P \rightarrow -|1\rangle_P`}</li> <li>${tex`|r\rangle=\frac{1}{\sqrt{2}}|0\rangle+\frac{i}{\sqrt{2}}|0\rangle`} is right circularly polarized</li> <li>${tex`|l\rangle=\frac{1}{\sqrt{2}}|0\rangle-\frac{i}{\sqrt{2}}|0\rangle`} is left circularly polarized</li> <li>${tex`I`} is the identity</li> </ul> </div> `;}
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.