Angle Encoding (Rotation Encoding)
Overview
Angle encoding is the simplest quantum data encoding method: each classical feature value becomes a rotation angle. It's hardware-efficient and widely used in variational quantum algorithms.
The Concept
Classical data: x = [x₀, x₁, x₂, x₃]
Quantum encoding: RY(x₀π)|0⟩ ⊗ RY(x₁π)|0⟩ ⊗ RY(x₂π)|0⟩ ⊗ RY(x₃π)|0⟩
Encoding Types
Standard (1 feature per qubit)
CODE┌─────────┐ q_0: ┤ RY(x₀π) ├ ├─────────┤ q_1: ┤ RY(x₁π) ├ ├─────────┤ q_2: ┤ RY(x₂π) ├ └─────────┘
Dense (2 features per qubit)
CODE┌─────────┐┌─────────┐ q_0: ┤ RY(x₀π) ├┤ RZ(x₁π) ├ ├─────────┤├─────────┤ q_1: ┤ RY(x₂π) ├┤ RZ(x₃π) ├ └─────────┘└─────────┘
Running the Circuit
PYTHONfrom circuit import run_circuit # Standard encoding result = run_circuit(data=[0.25, 0.5, 0.75, -0.5]) print(f"Qubits used: {result['n_qubits']}") # Dense encoding result = run_circuit(data=[0.25, 0.5, 0.75, 1.0], encoding_type='dense') print(f"Qubits used: {result['n_qubits']}") # 2 instead of 4
Rotation Effects
For RY(θ)|0⟩:
| θ | State | P(0) | P(1) |
|---|---|---|---|
| 0 | |0⟩ | 100% | 0% |
| π/2 | |+⟩ | 50% | 50% |
| π | |1⟩ | 0% | 100% |
Comparison with Other Encodings
| Encoding | Qubits for N features | Depth |
|---|---|---|
| Angle | N | 1 |
| Dense Angle | N/2 | 1 |
| Amplitude | log₂(N) | O(N) |
| Basis | N | 1 |
Advantages
- Simple: Just rotation gates
- Hardware-efficient: Native gates on most hardware
- Low depth: Single layer of rotations
- Intuitive: Direct mapping of features
Disadvantages
- Linear scaling: One qubit per feature (or 2 with dense)
- Limited expressiveness: Compared to amplitude encoding
- No entanglement: Features encoded independently
Applications
- VQC input: Standard input for variational classifiers
- Quantum kernel: Feature map for kernel methods
- QAOA: Encoding problem parameters