QuantumCore

Hands-on lab · 1 step

Build the inversion test of an angle-encoding kernel

Build the compute–uncompute circuit U(x′)†U(x)U(x')^\dagger U(x) of the two-qubit RXR_X product encoding for x=(0.3,1.2)x=(0.3,1.2) and x′=(1.0,0.4)x'=(1.0,0.4) with RXR_X gates only, and read the kernel value K(x,x′)=cos⁡2(0.35)cos⁡2(0.4)≈0.7486K(x,x')=\cos^2(0.35)\cos^2(0.4)\approx0.7486 off the probability of the outcome 0000.

0/1 step passedBest score 0/100

Step 1: Build U(x′)† U(x) for the R_X product encoding

The feature map encodes x=(x0,x1)x=(x_0,x_1) on two qubits with one RXR_X rotation per qubit,

U(x)=RX(x0)⊗RX(x1),RX(θ)=e−iθX/2=(cos⁡θ2−isin⁡θ2−isin⁡θ2cos⁡θ2),U(x)=R_X(x_0)\otimes R_X(x_1),\qquad R_X(\theta)=e^{-i\theta X/2}=\begin{pmatrix}\cos\frac\theta2&-i\sin\frac\theta2\\-i\sin\frac\theta2&\cos\frac\theta2\end{pmatrix},

with feature x0x_0 on qubit 00 (the most significant bit) and x1x_1 on qubit 11. Starting from ∣00⟩\lvert00\rangle, build the inversion test circuit

V=U(x′)† U(x)forx=(0.3, 1.2),x′=(1.0, 0.4),V=U(x')^\dagger\,U(x)\qquad\text{for}\qquad x=(0.3,\,1.2),\quad x'=(1.0,\,0.4),

so that the probability of the outcome 0000 is the fidelity kernel K(x,x′)=∣⟨ϕ(x′)∣ϕ(x)⟩∣2K(x,x')=\lvert\langle\phi(x')\vert\phi(x)\rangle\rvert^2. First prepare ∣ϕ(x)⟩=U(x)∣00⟩\lvert\phi(x)\rangle=U(x)\lvert00\rangle, then apply the inverse of the circuit that prepares ∣ϕ(x′)⟩\lvert\phi(x')\rangle.

How it is graded. Only RXR_X gates are available, at most 44 of them, on 22 qubits. The grader simulates your circuit and compares, with absolute tolerance 10−610^{-6}:

  • check probabilities: the distribution (P(00),P(01),P(10),P(11))=(0.748605, 0.133816, 0.099748, 0.017830)\big(P(00),P(01),P(10),P(11)\big)=(0.748605,\ 0.133816,\ 0.099748,\ 0.017830) of measuring both qubits;
  • check p00: the expectation value of the projector ∣00⟩⟨00∣=14(II+ZI+IZ+ZZ)\lvert00\rangle\langle00\rvert=\tfrac14(II+ZI+IZ+ZZ), which equals P(00)=K(x,x′)=0.748605P(00)=K(x,x')=0.748605.
  • 2 qubits
  • allowed gates: RX
  • 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 circuitq0q1
Statevector amplitudes
BasisAmplitude α|α|Phase arg αProbability
|00⟩1
1.0000
0
100.00%
3 basis states with zero amplitude hidden