Angle Encoding (Rotation Encoding)
Overview
Angle encoding is the simplest and most hardware-efficient quantum data encoding: each classical feature value becomes a rotation angle on a dedicated qubit. It is the default input method for variational quantum classifiers, quantum kernels, and most near-term QML algorithms.
The mapping is direct: a feature value x is encoded as a rotation R(x * pi) on the Bloch sphere. No normalization is required, and the circuit depth is just 1.
Bloch Sphere Mapping
For RY encoding, the feature value maps to a point on the Bloch sphere:
CODEx = 0.0 --> |0> (north pole, P(0)=100%) x = 0.5 --> |+> (equator, P(0)=50%, P(1)=50%) x = 1.0 --> |1> (south pole, P(1)=100%)
The angle theta = x * pi determines the latitude on the Bloch sphere. Values in [-1, 1] cover the full sphere.
Encoding Variants
Standard Encoding (1 feature per qubit)
CODE+---------+ q_0: | RY(x0pi)| +---------+ q_1: | RY(x1pi)| +---------+ q_2: | RY(x2pi)| +---------+ q_3: | RY(x3pi)| +---------+
RZ Encoding (phase encoding)
CODE+---+ +---------+ q_0: | H |-| RZ(x0pi)| Requires initial H to create +---+ +---------+ superposition for phase to matter q_1: | H |-| RZ(x1pi)| +---+ +---------+
Dense Encoding (2 features per qubit)
CODE+---------+ +---------+ q_0: | RY(x0pi)|-| RZ(x1pi)| RY for amplitude, RZ for phase +---------+ +---------+ q_1: | RY(x2pi)|-| RZ(x3pi)| 2x compression vs standard +---------+ +---------+
Dense encoding uses two orthogonal rotation axes (RY and RZ) on each qubit, packing 2 features per qubit. This halves the qubit requirement at the cost of slightly more complex readout.
Running the Circuit
PYTHONfrom circuit import ( run_circuit, create_angle_encoding, create_dense_angle_encoding, verify_encoding, ) # Standard RY encoding result = run_circuit(data=[0.25, 0.5, 0.75, -0.5]) print(f"Qubits: {result['n_qubits']}") # 4 # RZ encoding result = run_circuit(data=[0.25, 0.5], encoding_type="rz") # RX encoding result = run_circuit(data=[0.25, 0.5], encoding_type="rx") # Dense encoding (half the qubits) result = run_circuit(data=[0.25, 0.5, 0.75, 1.0], encoding_type="dense") print(f"Qubits: {result['n_qubits']}") # 2 # Verify encoding properties v = verify_encoding() print(f"All checks passed: {v['passed']}")
Rotation Gate Comparison
| Gate | Axis | Effect | Best For |
|---|---|---|---|
| RY | Y-axis | Changes measurement probability | General purpose |
| RZ | Z-axis | Changes phase | Phase-based algorithms |
| RX | X-axis | Changes measurement probability | Alternative to RY |
For RY(theta)|0>:
| Feature x | Angle theta | State | P(0) | P(1) |
|---|---|---|---|---|
| 0.0 | 0 | |0> | 100% | 0% |
| 0.25 | pi/4 | near |0> | 85% | 15% |
| 0.5 | pi/2 | |+> | 50% | 50% |
| 0.75 | 3pi/4 | near |1> | 15% | 85% |
| 1.0 | pi | |1> | 0% | 100% |
Comparison with Other Encodings
| Encoding | Qubits (N features) | Depth | Entanglement | Readout |
|---|---|---|---|---|
| Angle (standard) | N | 1 | None | Easy |
| Angle (dense) | N/2 | 2 | None | Moderate |
| Amplitude | log2(N) | O(N) | Required | Hard |
| Basis | N | 1 | None | Easy |
Advantages
- Simple: Just rotation gates, no multi-qubit operations
- Hardware-efficient: Native gates on all quantum hardware
- Low depth: Single layer (depth 1) for standard encoding
- No normalization: Works with any feature scale
- Intuitive: Direct Bloch sphere geometry
Disadvantages
- Linear qubit scaling: N features need N qubits (or N/2 dense)
- No entanglement: Features are encoded independently
- Limited expressiveness: Less rich than amplitude encoding
- Feature interaction: Requires variational layers to create correlations
Applications
- VQC input: Standard input layer for variational quantum classifiers
- Quantum kernel: Feature encoding for kernel-based methods
- QAOA: Encoding problem parameters as rotation angles
- Hybrid models: Quantum layer input in classical-quantum networks
Learn More
- Robust Data Encodings for Quantum Classifiers (LaRose & Coyle, 2020)
- Data Encoding Patterns for Quantum Computing (Weigold et al., 2020)
- Expressibility of Data Encoding Strategies (Schuld et al., 2021)