QuantumCore

Hands-on lab · 2 steps

HHL on a 2×2 system

Solve Ax⃗=b⃗A\vec x=\vec b for A=(1−13−131)A=\begin{pmatrix}1&-\tfrac13\\-\tfrac13&1\end{pmatrix} and b⃗=(1,0)T\vec b=(1,0)^T with the HHL algorithm on four qubits: read the clock values produced by phase estimation, then choose the controlled-RYR_Y angles that divide each eigencomponent by its eigenvalue, so that post-selection yields ∣x⟩=(3,1)/10\lvert x\rangle=(3,1)/\sqrt{10}.

0/2 steps passedBest score 0/100

Step 1: Clock values of the two eigenvalues

The matrix AA has eigenvalues λ1=23\lambda_1=\tfrac23 and λ2=43\lambda_2=\tfrac43. Phase estimation with U=eiAtU=e^{iAt}, t=3π4t=\tfrac{3\pi}{4} and tc=2t_c=2 clock qubits writes the integer kj=λjt 2tc/(2π)k_j=\lambda_j t\,2^{t_c}/(2\pi) into the clock register. Enter the two clock values k1,k2k_1,k_2 (in either order). Exact integers are expected (tolerance 10−910^{-9}).

Enter exact expressions or decimals, e.g. 1/sqrt(2), pi/3. Values must be real.

enter a value
enter a value
Fill every field with a valid expression.

Step 2: Eigenvalue inversion

The circuit is fixed: ancilla on qubit 00, clock on qubits 11 (MSB) and 22 (LSB), system on qubit 33 starting in ∣b⟩=∣0⟩\lvert b\rangle=\lvert0\rangle. It runs phase estimation (controlled-UU from qubit 22, controlled-U2=−XU^2=-X from qubit 11, inverse QFT), the rotations CRY(2→0,θ1)\mathrm{CRY}(2\to0,\theta_1) and CRY(1→0,θ2)\mathrm{CRY}(1\to0,\theta_2), and the exact inverse of phase estimation. Set the parameters theta1\texttt{theta1} and theta2\texttt{theta2} so that, conditioned on ancilla =1=1 and clock =00=00, the system qubit is ∣x⟩=A−1b⃗/∥A−1b⃗∥=(3,1)/10\lvert x\rangle=A^{-1}\vec b/\lVert A^{-1}\vec b\rVert=(3,1)/\sqrt{10}. The grader requires fidelity ≥0.9999\ge0.9999 and success probability ≥0.6\ge0.6. Use C=1C=1: the rotation for clock value kk must map ∣0⟩↦1−C2/k2 ∣0⟩+(C/k)∣1⟩\lvert0\rangle\mapsto\sqrt{1-C^2/k^2}\,\lvert0\rangle+(C/k)\lvert1\rangle.

  • 4 qubits
  • no measurements
  • first 18 ops locked
  • structure fixed: change parameters only
  • free parameters: theta1, theta2

Locked prefix (always applied first)

H(1); H(2); U; U_sq; SWAP(1,2); H(2); CP(2,1, -pi/2); H(1); CRY(2,0, theta1); CRY(1,0, theta2); H(1); CP(2,1, pi/2); H(2); SWAP(1,2); U_sq_inv; U_inv; H(1); H(2)

One gate per line or separated by ;, e.g. H(0); CNOT(0,1); RY(1, pi/3); measure(1 -> 0). Qubit 0 is the top wire (most significant bit); controls come first. # starts a comment.

Measure into a classical bit with measure(q -> c); apply a gate only when a bit is set with X(2) if c1==1 (several bits, first = most significant: if c[0,1]==3). Placeholders: U, U_sq, U_sq_inv, U_inv — write the name on its own (e.g. U); it acts on the qubits fixed by the step.

Parameters
= 0
= 0
Circuit diagram of your answerH on q1; H on q2; U on q3 controlled by q2; U_sq on q3 controlled by q1; SWAP on q1, q2; H on q2; P(-π/2) on q1 controlled by q2; H on q1; RY(theta1) on q0 controlled by q2; RY(theta2) on q0 controlled by q1; H on q1; P(π/2) on q1 controlled by q2; H on q2; SWAP on q1, q2; U_sq_inv on q3 controlled by q1; U_inv on q3 controlled by q2; H on q1; H on q2q0q1q2q3HHUUsqHP(-π/2)HRY(theta1)RY(theta2)HP(π/2)HUsq_invUinvHH
Statevector amplitudes
BasisAmplitude α|α|Phase arg αProbability
|0000⟩1
1.0000
0
100.00%
15 basis states with zero amplitude hidden