QuantumCore

Hands-on lab · 1 step

Angle-encode a two-feature datum

Write the angle-encoding feature map ∣ϕ(x)⟩=RY(x0)∣0⟩⊗RY(x1)∣0⟩\lvert\phi(x)\rangle=R_Y(x_0)\lvert0\rangle\otimes R_Y(x_1)\lvert0\rangle for a datum x=(x0,x1)x=(x_0,x_1) as a circuit that uses the data symbols x0,x1x_0,x_1, so that it works for every datum. The grader re-binds the symbols to three data points and checks ⟨Zj⟩=cos⁡xj\langle Z_j\rangle=\cos x_j and ⟨Xj⟩=sin⁡xj\langle X_j\rangle=\sin x_j on both qubits.

0/1 step passedBest score 0/100

Step 1: Encode x = (x0, x1) with one R_Y per qubit

The circuit declares two non-trainable data symbols x0x_0 and x1x_1 (parameters named x0 and x1). Build the angle-encoding feature map

∣ϕ(x)⟩=RY(x0)∣0⟩⊗RY(x1)∣0⟩=(cos⁡x02∣0⟩+sin⁡x02∣1⟩)⊗(cos⁡x12∣0⟩+sin⁡x12∣1⟩)\lvert\phi(x)\rangle=R_Y(x_0)\lvert0\rangle\otimes R_Y(x_1)\lvert0\rangle=\Big(\cos\tfrac{x_0}2\lvert0\rangle+\sin\tfrac{x_0}2\lvert1\rangle\Big)\otimes\Big(\cos\tfrac{x_1}2\lvert0\rangle+\sin\tfrac{x_1}2\lvert1\rangle\Big)

with one RYR_Y per qubit: qubit 00 is rotated by the symbol x0 and qubit 11 by the symbol x1. Use the symbols as the gate angles, not numbers: the circuit must be a function of the datum.

How it is graded. The grader substitutes the three data points (x0,x1)∈{(0.3,1.2), (1.0,0.4), (2.5,−0.7)}(x_0,x_1)\in\{(0.3,1.2),\,(1.0,0.4),\,(2.5,-0.7)\} for the symbols, runs your circuit for each, and compares, with absolute tolerance 10−610^{-6}:

  • check z: ⟨Z0⟩=cos⁡x0\langle Z_0\rangle=\cos x_0 and ⟨Z1⟩=cos⁡x1\langle Z_1\rangle=\cos x_1;
  • check x: ⟨X0⟩=sin⁡x0\langle X_0\rangle=\sin x_0 and ⟨X1⟩=sin⁡x1\langle X_1\rangle=\sin x_1.

For example, at the first datum the targets are ⟨Z0⟩=cos⁡0.3=0.955336\langle Z_0\rangle=\cos0.3=0.955336 and ⟨X0⟩=sin⁡0.3=0.295520\langle X_0\rangle=\sin0.3=0.295520. Only RXR_X, RYR_Y, RZR_Z are available, at most two gates and no two-qubit gates; the parameter list must stay x0, x1 with their values unchanged.

  • 2 qubits
  • allowed gates: RX, RY, RZ
  • at most 2 gates
  • at most 0 two-qubit 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).

Parameters
= 0(fixed)
= 0(fixed)
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