# Quantum Recurrent Neural Networks: Predicting the Dynamics of Oscillatory and Chaotic Systems
## 3 Methodology
### Variational Quantum Circuits (VQCs)
#### 3.1.1 Encoding Layer  
The encoding layer's primary function is to map classical data values into quantum amplitudes. It starts with initializing the circuit in the ground state and applying Hadamard gates to create an unbiased initial state. The state of an \(N\)-qubit quantum system can be represented as:  
\[|\psi\rangle=\sum_{(q_{1},q_{2},\ldots,q_{N})\in\{0,1\}^{N}}c_{q_{1},q_{2}, \ldots,q_{N}}|q_{1}\rangle\otimes|q_{2}\rangle\otimes\ldots\otimes|q_{N}\rangle, \tag{8}\]  
where \(c_{q_{1},\ldots,q_{N}}\in\mathbb{C}\) is the complex amplitude for each basis state and \(\otimes\) stands for tensor product. Again, by the Born's rule, we know that:  
\[\sum_{(q_{1},q_{2},\ldots,q_{N})\in\{0,1\}^{N}}\ \ \|c_{q_{1},\ldots,q_{N}}\|^{2}=1. \tag{9}\]  
Figure 1: An example of VQC architecture with two layers of entanglements for QLSTM and QGRU.  
The encoding layer first transforms the input data into rotation angles to the rotation of each single qubit. We apply the Hadamard gate here and transform the initial state into a superposition, also called the unbiased state. After applying the Hadamard gate \(H\)\(N\) times (once to each qubit), we will obtain:  
\[(H|0))^{\otimes N}=\bigg{(}\frac{1}{\sqrt{2}}(|0)+|1\rangle)\bigg{)}^{\otimes N}. \tag{10}\]  
The resulting state after applying the Hadamard gate \(N\) times is a uniform superposition of all possible states of \(N\) qubits, which can be expressed as:  
\[\frac{1}{\sqrt{2^{N}}}\Big{(}|0\rangle^{\otimes N}+\cdots+|1\rangle^{\otimes N }\Big{)}. \tag{11}\]  
Hence,  
\[\frac{1}{\sqrt{2^{N}}}\sum_{i=0}^{2^{N}-1}|i\rangle. \tag{12}\]  
Here, \(i\) is used as an index to sum over all possible states, where \(i\) represents the decimal equivalent of the binary numbers formed by the qubits. For example, for \(N=2\), the sum would run over \(|00\rangle\), \(|01\rangle\), \(|10\rangle\), and \(|11\rangle\), which correspond to decimal 0, 1, 2, and 3, respectively.  
The encoding process involves using two-angle encoding, where each data value is encoded to a qubit with a series of two gates, \(R_{y}\) and \(R_{z}\). In this study, a template named \(qml.templates.AngleEmbedding\) is used to play the role of \(R_{y}\) and \(R_{z}\).  
The \(qml.templates.AngleEmbedding\) template effectively maps classical information onto the quantum states by applying specific rotation gates to each qubit in the system. This template can be customized for various aspects of the embedding, including selecting the axis of rotation \(R_{x}\), \(R_{y}\), or \(R_{z}\). This adaptability makes the template well-suited for a broad spectrum of applications within the domain of quantum neural networks and other machine learning models.  
After transforming the initial states into unbiased states, we will use \(2N\) rotational angles from an \(N\)-dimensional input vector, \(\vec{v}=(x_{1},x_{2},\ldots,x_{N})\). For each component \(x_{i}\) of \(\vec{v}\), in [PERSON]'s original paper, the two angles are calculated: \(\theta_{i,1}=\arctan(x_{i})\) for \(y\)-axis rotation and \(\theta_{i,2}=\arctan(x_{i}^{2})\) for \(z\)-axis rotation, where the rotations are effected through \(R_{y}(\theta_{i,1})\) and \(R_{z}(\theta_{i,2})\) gates, respectively.  
Despite normalizing the input data before the encoding layer, this work introduces a distinct methodology. Rather than employing arctan functions, we select the \(\sin\) and \(\cos\) functions for the \(R_{y}(\theta_{i,1})\) and \(R_{z}(\theta_{i,2})\) gates, respectively. This entails setting \(\theta_{i,1}=\sin(x_{i})\) for the \(R_{y}\) gate and \(\theta_{i,2}=\cos(x_{i}^{2})\) for the \(R_{z}\) gate, diverging from conventional arctan applications. This method represents a preliminary attempt in practice and it can be improved in future work, which is not covered within this paper. More studies related to this aspect can be found in [PERSON]'s paper [34].