QuantumCore

Hands-on lab · 1 step

Hit three expectation values

Use ⟨X⟩=sin⁡θcos⁡ϕ\langle X\rangle=\sin\theta\cos\phi, ⟨Y⟩=sin⁡θsin⁡ϕ\langle Y\rangle=\sin\theta\sin\phi, ⟨Z⟩=cos⁡θ\langle Z\rangle=\cos\theta to prepare a qubit with ⟨Z⟩=12\langle Z\rangle=\tfrac12, ⟨X⟩=32\langle X\rangle=\tfrac{\sqrt3}{2}, ⟨Y⟩=0\langle Y\rangle=0.

0/1 step passedBest score 0/100

Step 1: Prepare the target expectations

Starting from ∣0⟩\lvert0\rangle, use at most three gates from {RX,RY,RZ,H,S,X,Z}\{R_X, R_Y, R_Z, H, S, X, Z\} to prepare a state with

⟨Z⟩=12,⟨X⟩=32,⟨Y⟩=0.\langle Z\rangle=\tfrac12,\qquad \langle X\rangle=\tfrac{\sqrt3}{2},\qquad \langle Y\rangle=0 .

Each expectation value is graded with absolute tolerance 10−610^{-6}. Recall that for ∣ψ⟩=cos⁡θ2∣0⟩+eiϕsin⁡θ2∣1⟩\lvert\psi\rangle=\cos\tfrac\theta2\lvert0\rangle+e^{i\phi}\sin\tfrac\theta2\lvert1\rangle the Born rule gives ⟨A⟩=⟨ψ∣A∣ψ⟩=∑mm P(m)\langle A\rangle=\langle\psi\vert A\vert\psi\rangle=\sum_m m\,P(m), which evaluates to ⟨X⟩=sin⁡θcos⁡ϕ\langle X\rangle=\sin\theta\cos\phi, ⟨Y⟩=sin⁡θsin⁡ϕ\langle Y\rangle=\sin\theta\sin\phi, ⟨Z⟩=cos⁡θ\langle Z\rangle=\cos\theta.

  • 1 qubit
  • allowed gates: RX, RY, RZ, H, S, X, Z
  • at most 3 gates
  • no measurements

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).

Circuit diagram of your answerEmpty circuitq0
Statevector amplitudes
BasisAmplitude α|α|Phase arg αProbability
|0⟩1
1.0000
0
100.00%
1 basis state with zero amplitude hidden