mirror of
https://github.com/hanzoai/papers.git
synced 2026-10-30 14:58:42 +00:00
82 lines
3.6 KiB
TeX
82 lines
3.6 KiB
TeX
\section{Symplectic Integrators}
|
|
|
|
\label{sec:integrators}
|
|
|
|
In practice, trades arrive as discrete events, not continuous flows. We need numerical integrators that preserve the symplectic structure to ensure long-term stability of the invariant $\mathcal{H} = \kappa$.
|
|
|
|
\subsection{Why Symplecticity Matters}
|
|
|
|
Non-symplectic integrators (e.g., forward Euler) introduce numerical dissipation that causes $\mathcal{H}$ to drift over time. In an AMM context, this drift would manifest as a slow leak of value from the pool---an unacceptable property for a financial protocol.
|
|
|
|
\begin{theorem}[Backward Error Analysis]
|
|
A symplectic integrator of order $r$ with step size $h$ exactly preserves a modified Hamiltonian $\tilde{\mathcal{H}} = \mathcal{H} + O(h^r)$ for exponentially long times $T \sim e^{c/h}$~\cite{hairer2006geometric}.
|
|
\end{theorem}
|
|
|
|
\subsection{Stormer--Verlet Integrator (2nd Order)}
|
|
|
|
The simplest symplectic integrator for HMM is the leapfrog/Stormer--Verlet method:
|
|
|
|
\begin{algorithm}[H]
|
|
\caption{Stormer--Verlet Swap Execution}
|
|
\label{alg:verlet}
|
|
\begin{algorithmic}[1]
|
|
\Require State $(\bm{q}, \bm{p})$, swap vector $\Delta\bm{q}$, step size $h$
|
|
\State $\bm{p}_{1/2} \gets \bm{p} - \frac{h}{2} \nabla_{\bm{q}} \mathcal{H}(\bm{q}, \bm{p})$
|
|
\State $\bm{q}' \gets \bm{q} + h \, \nabla_{\bm{p}} \mathcal{H}(\bm{q}, \bm{p}_{1/2})$
|
|
\State $\bm{p}' \gets \bm{p}_{1/2} - \frac{h}{2} \nabla_{\bm{q}} \mathcal{H}(\bm{q}', \bm{p}_{1/2})$
|
|
\State Apply fee correction: $\bm{p}' \gets \bm{p}' - \bm{f}(\Delta\bm{q})$
|
|
\State Verify $|\mathcal{H}(\bm{q}', \bm{p}') - \kappa| < \epsilon$
|
|
\State \Return $(\bm{q}', \bm{p}')$
|
|
\end{algorithmic}
|
|
\end{algorithm}
|
|
|
|
The Verlet method is time-reversible, preserves the symplectic form to machine precision, and has local error $O(h^3)$, global error $O(h^2)$.
|
|
|
|
\subsection{Ruth's 4th-Order Integrator}
|
|
|
|
For higher accuracy, we employ Ruth's 4th-order symplectic integrator~\cite{ruth1983canonical}:
|
|
|
|
\begin{algorithm}[H]
|
|
\caption{Ruth-4 Swap Execution}
|
|
\label{alg:ruth4}
|
|
\begin{algorithmic}[1]
|
|
\Require State $(\bm{q}, \bm{p})$, coefficients $c_1, \ldots, c_4$, $d_1, \ldots, d_4$
|
|
\For{$k = 1, \ldots, 4$}
|
|
\State $\bm{q} \gets \bm{q} + c_k \, h \, \nabla_{\bm{p}} \mathcal{H}(\bm{q}, \bm{p})$
|
|
\State $\bm{p} \gets \bm{p} - d_k \, h \, \nabla_{\bm{q}} \mathcal{H}(\bm{q}, \bm{p})$
|
|
\EndFor
|
|
\State \Return $(\bm{q}, \bm{p})$
|
|
\end{algorithmic}
|
|
\end{algorithm}
|
|
|
|
The coefficients are:
|
|
\begin{align}
|
|
c_1 &= c_4 = \frac{1}{2(2 - 2^{1/3})}, \quad c_2 = c_3 = \frac{1 - 2^{1/3}}{2(2 - 2^{1/3})}, \\
|
|
d_1 &= d_3 = \frac{1}{2 - 2^{1/3}}, \quad d_2 = \frac{-2^{1/3}}{2 - 2^{1/3}}, \quad d_4 = 0.
|
|
\end{align}
|
|
|
|
This achieves local error $O(h^5)$ and global error $O(h^4)$ while remaining exactly symplectic.
|
|
|
|
\subsection{Invariant Drift Analysis}
|
|
|
|
We quantify the invariant drift $\Delta\mathcal{H} = |\mathcal{H}_T - \kappa|$ after $T$ trading steps:
|
|
|
|
\begin{table}[H]
|
|
\centering
|
|
\begin{tabular}{lccc}
|
|
\toprule
|
|
\textbf{Integrator} & \textbf{Order} & $\Delta\mathcal{H}$ ($10^4$ steps) & $\Delta\mathcal{H}$ ($10^6$ steps) \\
|
|
\midrule
|
|
Forward Euler & 1 & $3.2 \times 10^{-1}$ & Divergent \\
|
|
RK4 (non-sympl.) & 4 & $7.8 \times 10^{-4}$ & $4.1 \times 10^{-2}$ \\
|
|
Stormer--Verlet & 2 & $2.1 \times 10^{-6}$ & $2.3 \times 10^{-6}$ \\
|
|
Ruth-4 & 4 & $8.9 \times 10^{-12}$ & $9.1 \times 10^{-12}$ \\
|
|
\bottomrule
|
|
\end{tabular}
|
|
\caption{Hamiltonian drift comparison. Symplectic integrators maintain bounded drift.}
|
|
\label{tab:drift}
|
|
\end{table}
|
|
|
|
The key observation is that symplectic integrators exhibit \emph{bounded} drift (oscillation around $\kappa$) even over millions of steps, while non-symplectic methods show secular drift that would cause systematic value leakage from the pool.
|
|
|