QuantumCore

Hands-on lab · 1 step

Build X from H and S

Implement the bit flip X=(0110)X=\begin{pmatrix}0&1\\1&0\end{pmatrix} on one qubit, up to a global phase, using only the Hadamard gate HH and the phase gate S=diag(1,i)S=\mathrm{diag}(1,i), with at most four gates.

0/1 step passedBest score 0/100

Step 1: X from H and S

Build a one-qubit circuit whose unitary equals X=(0110)X=\begin{pmatrix}0&1\\1&0\end{pmatrix} up to a global phase, using only H=12(111−1)H=\tfrac1{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix} and S=(100i)S=\begin{pmatrix}1&0\\0&i\end{pmatrix}, at most four gates in total. The grader compares the circuit unitary UU with XX through FU=∣Tr(X†U)∣/2F_U=\lvert\mathrm{Tr}(X^\dagger U)\rvert/2, which equals 11 exactly when U=eiγXU=e^{i\gamma}X for some real γ\gamma. Gates placed left to right on the wire multiply right to left in the formula: the wire AA then BB implements BABA.

  • 1 qubit
  • allowed gates: H, S
  • at most 4 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