# Quantum Recurrent Neural Networks: Predicting the Dynamics of Oscillatory and Chaotic Systems
## 4 Numerical Experiments
### Two Coupled Damped Harmonic Oscillators Simulation  
In this experiment, we study the capability the QRNN in learning the patterns in the system of two coupled harmonic oscillators. It is worth pointing out that this experiment actually is an extension of the prediction on a single damped harmonic oscillator by [PERSON] [34; 35]. This experiment extends our understanding not only from a single oscillator, but physical systems by introducing interactions between oscillatory motions. Such systems are paramount in numerous fields, including physics and engineering. The governing differential equations for two coupled damped harmonic oscillators, representing an extended model of the single oscillator, are as follows:  
\[ \begin{split}\frac{d^{2}\theta_{1}}{dt^{2}}&=- \frac{b_{1}}{m_{1}}\frac{d\theta_{1}}{dt}-\frac{g}{l_{1}}\sin(\theta_{1})+\frac {k_{c}}{m_{1}}(\theta_{2}-\theta_{1}),\\ \frac{d^{2}\theta_{2}}{dt^{2}}&=-\frac{b_{2}}{m_{2}} \frac{d\theta_{2}}{dt}-\frac{g}{l_{2}}\sin(\theta_{2})+\frac{k_{c}}{m_{2}}( \theta_{1}-\theta_{2}).\end{split}  \tag{44}\]  
Here, \(\theta_{1}\) and \(\theta_{2}\) represent the angular displacements of the first and second pendulums, respectively. The constants \(g=9.81\) m/s\({}^{2}\) (gravitational acceleration), \(b_{1}=b_{2}=0.15\) (damping factors), \(l_{1}=l_{2}=1.0\) m (lengths of the pendulums), \(m_{1}=m_{2}=1.0\) kg (masses of the pendulums), and \(k_{c}=0.05\) (coupling constant) define the system's characteristics. The initial conditions are set with angular displacements \(\theta_{1}=\theta_{2}=0\) and angular velocities \(\dot{\theta_{1}}=3.0\), \(\dot{\theta_{2}}=0.0\) rad/s. Simulation Results for the Two Coupled Damped Harmonic Oscillators  
Just like the [PERSON] example, we present a comparative analysis of the models' performance in predicting the dynamic behavior of both oscillators (again, with MAE and RMSE), which are summarized in Tables 4 and 5. Like the results from the first experiment, in Tables 4 and 5 all the models successfully learn the dynamics, but the QGRU shows excellent predictive results, especially on the prediction of Oscillator 2. We noticed, first, that the predictions on Oscillator 2 are more accurate than Oscillator 1. Second, we noticed that the GRU models outshine LSTM models in general. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Model** & **Train MAE** & **Test MAE** & **Train RMSE** & **Test RMSE** \\ \hline LSTM & 0.5467 & 0.4371 & 0.7761 & 0.4922 \\ QLSTM & 0.5284 & 0.4763 & 0.6987 & 0.5374 \\ GRU & 0.3648 & 0.4396 & 0.4499 & 0.4941 \\ QGRU & 0.2585 & 0.2411 & 0.3587 & 0.2701 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Comparison of train and test MAE and RMSE for Oscillator 1. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Model** & **Train MAE** & **Test MAE** & **Train RMSE** & **Test RMSE** \\ \hline LSTM & 0.2190 & 0.3597 & 0.2814 & 0.4248 \\ QLSTM & 0.1244 & 0.2591 & 0.1607 & 0.2885 \\ GRU & 0.1160 & 0.0858 & 0.1483 & 0.1006 \\ QGRU & 0.0794 & 0.0482 & 0.0949 & 0.0602 \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Comparison of train and test MAE and RMSE for Oscillator 2. Similar to the [PERSON] case, the GRU models converge faster than the LSTM models and the quantum-based models learn the pattern faster than the classical models (which can be seen by the comparison on the results on epoch 5). The quantum-based RNNs also show stabler decrease in loss. Here, we observe several points of interest: Firstly, there is a minor increase in the test loss in LSTM models from epoch 80 to 100, potentially indicative of mild overfitting. Although adjusting the learning rate could mitigate this, we maintain a constant learning rate to achieve a straightforward comparison between the models. Secondly, spikes are observed in the LSTM model's test loss. Furthermore, at epoch 5, the LSTM model exhibits an undershot in performance, which is not seen in the results of the other models.