# Quantum Recurrent Neural Networks: Predicting the Dynamics of Oscillatory and Chaotic Systems
## 4 Numerical Experiments
### Van der Pol Oscillator Simulation  
In the first experiment, we consider the Van der Pol oscillator, a classical example of a non-conservative oscillator with nonlinear damping. The oscillator is modeled by the following second-order differential equation:  
\[\frac{d^{2}x}{dt^{2}}-\mu(1-x^{2})\frac{dx}{dt}+x=0. \tag{40}\]  
The parameter \(\mu\), representing the nonlinearity and strength of the damping, is set to 1.0 in our simulations. This choice of \(\mu\) provides a balance between linear and nonlinear dynamical behaviors, also making the system ideal for predicting a wide range of oscillatory patterns. The initial conditions for the oscillator are chosen as \(x_{0}=2.0\) and \(y_{0}=0.0\), where \(x_{0}\) and \(y_{0}\) represent the initial position and velocity, respectively. To numerically solve the Van der Pol differential equation, we convert it into a system of first-order equations:  
\[\frac{dx}{dt} =y, \tag{41}\] \[\frac{dy}{dt} =\mu(1-x^{2})y-x.\]  
The numerical solution is obtained over a time span of 0 to 50 s, discretized into 250 time steps. Following the numerical solution of the differential equations, the resultant time series data of \(x\) and \(y\) are normalized and prepared for analysis. The data are reshaped to fit the input requirements of RNN models, enabling us to predict the Van der Pol oscillator's dynamics. Simulation Results for the Van der Pol Oscillator  
The behavior of the Van der Pol oscillator was examined through the LSTM, QLSTM, GRU, and QGRU models by evaluating their performance on the Mean Absolute Error (MAE) and Root Mean Square Error (RMSE) metrics. Mean Absolute Error (MAE) is a measure of errors between paired observations. It is calculated as the average of the absolute differences between the predicted values and the actual values, disregarding the direction of the error. The MAE is given by the formula:  
\[MAE=\frac{1}{n}\sum_{i=1}^{n}\lvert y_{i}-\hat{y}_{i}\rvert. \tag{42}\]  
Root Mean Square Error (RMSE) is a quadratic scoring rule that also measures the average magnitude of the error. It is the square root of the average of squared differences between prediction and actual observation. The RMSE is given by the formula: \begin{table}
\begin{tabular}{c c c} \hline \hline
**Hyperparameter** & **QRNNs Value** & **RNNs Value** \\ \hline Optimizer & RMSprop & Adam \\ Loss Function & MSE & MSE \\ Backend & default.qubit & - \\ Number of Qubits & 4 & - \\ Layer of Entanglements & 4 & - \\ Number of Data Points & 250 & 250 \\ Percentage of Train Set & 67\% & 67\% \\ Percentage of Test Set & 33\% & 33\% \\ Learning Rate & 0.01 & 0.01 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Hyperparameter configuration. \[RMSE=\sqrt{\frac{1}{n}\sum_{i=1}^{n}(y_{i}-\hat{y}_{i})^{2}}, \tag{43}\]  
where:  
* \(n\) is the number of observations;
* \(y_{i}\) is the actual value of the \(i\)th observation;
* \(\hat{y}_{i}\) is the predicted value of the \(i\)th observation. Data from the numerical solution of the Van der Pol differential equations formed the basis for training and testing these models. A comparative analysis of the models' performance is summarized in Tables 2 and 3. Table 2 shows that quantum-based models exhibit superior predictive performance on \(x\) value over classical models. Among the models compared, the GRU models also outshine the LSTM models in accuracy and QGRU model gives us the most accurate predictions. Table 3 compares model performances on the \(y\) value. It is very interesting to see that the models produced more error on the prediction of the \(y\) values compared to the \(x\) values. Moreover, GRU models surpass LSTM models in terms of results, with the QGRU model achieving the highest accuracy among the evaluated models. The example predictive results over epochs by the different models are shown in Figures 6-10. Figure 8: GRU predictions over 100 Epochs for the Van der Pol oscillator. Up: x; down: y; epoch: 5, 50, 70, 100; green dashed line: actual values; blue solid line: training predictions; red solid line: testing predictions.