Next Article in Journal
Enhanced Key Node Identification in Complex Networks Based on Fractal Dimension and Entropy-Driven Spring Model
Previous Article in Journal
Entropy Reduction Across Odor Fields
Previous Article in Special Issue
Scaling Invariance: A Gateway to Phase Transitions
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Numerical Integration of Stochastic Differential Equations: The Heun Algorithm Revisited and the Itô-Stratonovich Calculus

by
Riccardo Mannella
Dipartimento di Fisica, Università di Pisa, 56126 Pisa, Italy
Entropy 2025, 27(9), 910; https://doi.org/10.3390/e27090910
Submission received: 14 August 2025 / Accepted: 26 August 2025 / Published: 28 August 2025

Abstract

The widely used Heun algorithm for the numerical integration of stochastic differential equations (SDEs) is critically re-examined. We discuss and evaluate several alternative implementations, motivated by the fact that the standard Heun scheme is constructed from a low-order integrator. The convergence, stability, and equilibrium properties of these alternatives are assessed through extensive numerical simulations. Our results confirm that the standard Heun scheme remains a benchmark integration algorithm for SDEs due to its robust performance. As a byproduct of this analysis, we also disprove a previous claim in the literature regarding the strong convergence of the Heun scheme.

1. Introduction

Stochastic Differential Equations (SDEs) are an indispensable tool for modeling complex systems across a vast range of scientific disciplines, including physics, chemistry, biology, and finance [1,2]. These equations provide a powerful framework for describing systems that are subject to random fluctuations, or “noise,” which is often an intrinsic feature of the underlying dynamics. Unlike Ordinary Differential Equations (ODEs), which have deterministic solutions, the solution to an SDE is itself a stochastic process, representing a collection of possible trajectories.
A central challenge in working with SDEs is that most non-trivial cases cannot be solved analytically. Consequently, their analysis relies heavily on numerical integration schemes to approximate solutions [3]. The development of robust and efficient numerical algorithms is therefore of paramount importance. An ideal scheme must balance several competing factors: it should be accurate, converging to the true solution as the integration time step decreases; it must be stable, avoiding divergence even for large time steps or stiff problems; and it should be computationally efficient.
Among the many algorithms developed for this purpose, the Heun scheme has emerged as a widely used and reliable method. As a stochastic extension of the classic Runge–Kutta predictor-corrector method, it is known for its favorable balance of simplicity, stability, and accuracy. Its structure naturally handles the Itō-Stratonovich dilemma, converging to the Stratonovich interpretation of the SDE, which is often preferred in physical modeling where the noise represents a smoothed, physical process rather than a purely mathematical construct [4,5].
Despite its widespread use, the standard Heun scheme is built upon the Euler–Maruyama method, a scheme with a relatively low order of strong convergence. This fact motivates a critical re-examination: Could the performance of the Heun method be improved by incorporating higher-order building blocks? How do its stability and accuracy compare to other, more complex Taylor-based or Runge–Kutta-type schemes?
This paper addresses these questions through a systematic investigation of the Heun algorithm and its variants. We critically evaluate several alternative implementations, comparing their performance in terms of strong convergence, numerical stability, and their ability to reproduce the correct long-time equilibrium distributions of a non-trivial SDE. Our findings confirm that the standard Heun scheme remains a benchmark algorithm for its robustness and reliability. As a byproduct of this analysis, we also re-evaluate and ultimately disprove a previous claim in the literature regarding the strong convergence order of the Heun scheme.

2. The Heun Algorithm and Itô-Stratonovich Calculus

The Heun algorithm for the numerical integration of Stochastic Differential Equations (SDEs) is a stochastic extension of an integrator first introduced by Heun in 1900 [6]. That paper addressed the then-nascent field of Runge–Kutta schemes for integrating Ordinary Differential Equations (ODEs) [7].
Given the ODE:
x ˙ = f ( x , t ) ,
the Heun scheme calculates the next step, x n + 1 x ( t + h ) , from the current step, x n x ( t ) , as follows:
x ˜ = x n + h f ( x n , t ) x = x n + h f ( x ˜ , t + h ) x n + 1 = 1 2 ( x ˜ + x ) = x n + h 2 [ f ( x n , t ) + f ( x ˜ , t + h ) ] .
Equation (2) shows that the Heun scheme is a predictor-corrector method. It first predicts a value with an explicit Euler step and then corrects it by averaging this explicit step with an implicit Euler step.
One of the earliest papers to mention a stochastic version of the Heun algorithm is [8], where this name was used to refer to a stochastic Runge–Kutta scheme derived in [9]. Given the one-dimensional SDE:
d x = f ( x , t ) d t + g ( x , t ) d W ,
where W is a standard Wiener process, the well-known Euler–Maruyama (in the following, Euler) scheme in the Itô sense is:
x n + 1 = x n + h f ( x n , t ) + g ( x n , t ) Z 1 ,
where Z 1 = Z 1 ( h ) t t + h d W = h Y 1 , with Y 1 N ( 0 , 1 ) , is a Gaussian random variable with zero mean and variance h. In [8], the Heun scheme for SDEs was written as:
x n + 1 = x n + h 2 [ f ( x n , t ) + f ( x ˜ , t + h ) ] + 1 2 [ g ( x n , t ) + g ( x ˜ , t + h ) ] Z 1 ,
where the predictor step is:
x ˜ = x n + h f ( x n , t ) + g ( x n , t ) Z 1 ,
and the same random variable Z 1 is used in both stages. Much like its deterministic counterpart, the stochastic Heun scheme can be seen as the average of an explicit and an implicit stochastic Euler step.
It is well known (see, for example, [8,9,10]) that the stochastic evolution described by Equation (5) converges to the evolution of Equation (3) interpreted in the Stratonovich sense. This is equivalent to the following SDE in the Itô sense:
d x = f ( x , t ) + 1 2 g ( x , t ) d g ( x , t ) d x d t + g ( x , t ) d W .
It was claimed in [9] that the Heun scheme is a scheme with a strong convergence order O ( h 3 / 2 ) (See Section 4.1 for a definition of strong convergence. Also, we will loosely use O ( h α ) and o ( h α ) when terms proportional to h α are kept or discarded, respectively). Furthermore, in [11], it was demonstrated that for a potential V ( x ) bounded from below (i.e., inf x V ( x ) > ), with f ( x ) = V ( x ) and g ( x ) = 2 D , the scheme in Equation (5) yields the correct equilibrium distribution for x up to order o ( h 2 ) .
In the following sections, we will consider only single-step algorithms with a time step h. For simplicity, we will use the notation x ( h ) x n + 1 and x ( 0 ) x n . When there is no ambiguity, we will use shorthand such as f f ( x , t ) and g d g ( x , t ) d x . Subscripts will be added when necessary to avoid confusion (e.g., f 0 f ( x 0 , t 0 ) ).
Although it may seem unsurprising that the Heun scheme yields a Stratonovich evolution—given that its elementary step averages quantities evaluated at the beginning and end of the time interval, which mirrors the definition of Stratonovich calculus [5]—several questions naturally arise:
  • The Heun scheme produces a Stratonovich evolution by combining two Euler schemes that use the Itô prescription. Should one instead use Euler schemes derived from the Stratonovich prescription?
  • The standard stochastic Euler scheme has a strong convergence order of O ( h 1 / 2 ) [3], unlike the deterministic Euler scheme. Would it be beneficial to replace it in the Heun scheme with an integrator that has a strong convergence order of O ( h ) ?
  • How does the Heun scheme compare with other Taylor-based higher-order schemes?
To address these points, some background is necessary (see also [5]).

2.1. The Stochastic Euler Scheme and Stochastic Calculus

An elementary O ( h ) scheme for Equation (3), obtained via a Taylor expansion around x 0 , is given by (see, for example, [12]):
x ( h ) = x ( 0 ) + g 0 Z 1 + h f 0 + g 0 g 0 0 h W ( s ) d W ( s ) .
If Itô calculus is used, the integral is 0 h W ( s ) d W ( s ) = 1 2 ( Z 1 2 h ) , which leads to the Milstein scheme (see Equation (11) below). If this term is approximated as zero, the standard Euler scheme (Equation (4)) is recovered. If Stratonovich calculus is used, the integral is 0 h W ( s ) d W ( s ) = 1 2 Z 1 2 , which yields the Euler–Stratonovich scheme:
x ( h ) = x ( 0 ) + g 0 Z 1 + h f 0 + 1 2 g 0 g 0 Z 1 2 .
The Heun algorithm requires an Euler step involving the final point, x ( h ) . For Itô calculus, this step corresponds to Equation (4), replacing x n with x n + 1 in the arguments of f ( x ) and g ( x ) . In contrast, when using Stratonovich calculus, expanding around x ( h ) results in:
x ( h ) = x ( 0 ) + g h Z 1 + h f h 1 2 g h g h Z 1 2 .

2.2. Strong Approximation O ( h ) : The Milstein Scheme

A strong approximation O ( h ) for integrating Equation (3) was proposed by Milstein [13]:
x ( h ) = x ( 0 ) + g 0 Z 1 + h f 0 + 1 2 g 0 g 0 ( Z 1 2 h ) .
Comparing this to Equation (7), the Milstein scheme corresponds to applying the Euler–Stratonovich scheme (Equation (9)) to the following SDE (The symbol ∘ indicates that this SDE is to be interpreted in the Stratonovich sense):
d x = f ( x , t ) 1 2 g ( x , t ) d g ( x , t ) d x d t + g ( x , t ) d W .

2.3. Higher-Order Taylor-Based Schemes

A Taylor-based scheme of order O ( h 2 ) using Itô calculus was derived in [14], and a revised version using Stratonovich calculus was developed in [12]. Even higher-order Taylor-based schemes were derived in [3], leveraging a chain rule for higher-order multiple stochastic integrals.
As shown both analytically and numerically in [11], care must be taken when deriving higher-order schemes. Specifically, if the terms containing stochastic integrals are computed to a certain order, the deterministic terms must be kept at the same order. One should not include higher-order deterministic terms, even if they are easy to derive (The deterministic terms are often simpler to compute, which might tempt one to include them regardless of the order achieved in the stochastic part). Doing so can result in a scheme that performs worse than one where all terms—both stochastic and deterministic—are consistently maintained at the same order of accuracy.
In the following, we will use the results of [12,15], which are reproduced here for convenience:
x ( h ) = x ( 0 ) + g 0 Z 1 + h f 0 + 1 2 g 0 g 0 Z 1 2 O ( h 1 / 2 ) + O ( h ) + g 0 f 0 f 0 g 0 Z 2 + h f 0 g 0 Z 1 + 1 3 ! g 0 g 0 g 0 + g 0 g 0 Z 1 3 O ( h 3 / 2 ) + h 2 2 f 0 f 0 + 1 2 f 0 g 0 g 0 Z 1 Z 2 Z 3 + 1 2 f 0 g 0 g 0 Z 1 Z 2 Z 3 O ( h 2 ) + g 0 g 0 f 0 f 0 g 0 Z 3 + g 0 g 0 f 0 1 2 h Z 1 2 1 2 Z 1 Z 2 + 1 2 Z 3 O ( h 2 ) + 1 4 ! g 0 g 0 2 g 0 + g 0 ( g 0 g 0 ) Z 1 4 + h 4 g 0 g 0 f 0 Z 1 2 1 2 ( Z 1 Z 2 Z 3 ) O ( h 2 )
where two additional stochastic integrals appear: Z 2 = Z 2 ( h ) 0 h Z 1 ( s ) d s = 0 h 0 s d W d s and Z 3 = Z 3 ( h ) 0 h Z 2 ( s ) d W ( s ) . A suitable representation for Z 2 is easily found, as it is Gaussian [12,14]:
Z 2 = Z 2 ( h ) = h Z 1 2 + h 2 3 Y 2 ,
where Y 2 N ( 0 , 1 ) is independent of Y 1 . Finding a representation for Z 3 is much harder, as a number of constraints must be satisfied. Considering the lowest orders in h, the following moments are found:
Z 3 ( h ) = 0 , [ Z 3 ( h ) ] 2 = h 4 12 Z 1 ( h ) Z 3 ( h ) = 0 , Z 2 ( h ) Z 3 ( h ) = 0 [ Z 1 ( h ) ] 2 Z 3 ( h ) = 1 4 h 3 , Z 1 ( h ) Z 2 ( h ) Z 3 ( h ) = h 4 12 [ Z 2 ( h ) ] 2 Z 3 ( h ) = h 5 15 ,
where denotes an average over stochastic realizations. The number of conditions to satisfy exceeds the number of unknown quantities, so an arbitrary choice must be made. In [12], the representation
Z 3 ( h ) = h 2 6 { Y 1 2 h + Y 3 }
was used (A misprint in Ref. [12] has been corrected here.), where Y 3 N ( 0 , 1 ) is independent of Y 1 and Y 2 . In preparation for this manuscript, an alternative representation was derived:
Z 3 = Z 1 Z 2 h 2 2 1 + Y 3 3 .

3. Algorithms and Dynamical System

The numerical schemes studied here are typically used to integrate SDEs to derive equilibrium or quasi-equilibrium properties. These include calculating the mean first passage time to a boundary, deriving reaction rate constants, and determining the long-time equilibrium distribution.
It is therefore relevant to test these approaches using a non-trivial SDE with a known equilibrium distribution. Verifying agreement with the full distribution is a more stringent test than merely checking the behavior of a few moments or cumulants. This focus on long-time accuracy is at odds with the typical analysis of integration schemes, which often investigates the behavior of stochastic trajectories over short time scales.
However, it is possible in some cases to connect these two regimes. Using the formalism of [16], one can infer the equilibrium distribution generated by a given numerical scheme from its short-time properties [11,17]. This connection demonstrates that schemes with more accurate short-time behavior also produce numerical equilibrium distributions that are closer to the theoretical one.
The dynamical system used for the test is one of the simplest non-trivial models:
d x = x ( 1 + x 2 ) d t + 2 D ( 1 + x 2 ) d W = f ( x ) d t + g ( x ) d W .
This model has the equilibrium distribution
P e q ( x ) = N ( 1 + x 2 ) 1 + α + n ,
where α = 1 / ( 2 D ) , n is 0 for Stratonovich calculus and 1 for Itô calculus, and N = Γ ( 1 + n + α ) / ( Γ ( 3 / 2 + α ) π ) is a normalization constant. It is noteworthy that the presence of a power-law tail makes the comparison with the numerical schemes particularly interesting because the different schemes must be able to integrate correctly even when the variable x becomes large.
The algorithms tested are as follows, where the labels will be used for identification below:
  • Euler: The standard Euler scheme, Equation (4).
  • Heun: The standard Heun scheme, Equation (5).
  • Stra: The Euler–Stratonovich scheme, Equation (9).
  • Miln: A modified Heun scheme where the Milstein algorithm (Equation (11)) is used as the basic block for both the predictor and corrector steps: in the corrector step, f ( x ) and g ( x ) are evaluated at the x found in the predictor step.
  • HeSt: A modified Heun scheme using the Euler–Stratonovich scheme of Equation (9) for the predictor step and Equation (10) for the corrector step.
  • HePC: An iterated Heun scheme. First, Equation (5) is used to obtain a tentative final point. This point is then re-inserted into Equation (5) in place of x ˜ . In our simulations, this loop was iterated four times.
  • Mil-: A modified Heun scheme similar to Miln, where for the corrector step the − sign in front of the term 1 2 g g is used (this resembles what is done in Equation (10) for the Euler–Stratonovich scheme)
  • T3/2: The scheme of Equation (13), including terms up to the ones marked O ( h 3 / 2 )
  • HPC-: An iterated Heun scheme similar to HePC but using Stratonovich schemes Equations (9) and (10) rather than Euler.
  • CUP1: The scheme of Equation (13) using Equation (15)
  • CUP2: The scheme of Equation (13) using Equation (16)
  • RK: The efficient RK scheme of [18].

4. Numerical Results and Discussion

All codes were written in Fortran 90 and parallelized using the MPICH [19] library on machines with 24, 30, or 40 cores. The random number generator used was RAN2 [20] from Numerical Recipes.

4.1. Convergence

We assessed the convergence rate of the different schemes following the approach of [21], where further details can be found. The core idea is that if x f is the final point of a trajectory integrated with a time step h from an initial point x 0 , and x l i m i t is the “true” final point obtained in the limit of h 0 starting from the same x 0 , the expected error satisfies E | x f x l i m i t | A h α for an algorithm with a strong convergence of order α .
In the case studied in [21], x l i m i t was found by solving the SDE analytically. However, since the exact solution to the SDE in Equation (17) is not known, we adopted the following procedure for each algorithm:
  • A random initial point was chosen from the Stratonovich equilibrium distribution Equation (18).
  • The trajectory was integrated from the initial point up to time t = 1.0 with a very small time step h s = 1 / 2 17 7.63 × 10 6 , storing the random variates generated at each step. This trajectory serves as the “reference” trajectory, and its final point x r e f was stored.
  • The integration was repeated from the same initial point but with a larger integration time step h n = 2 n h s , for 1 n 13 , and the final point x f ( h n ) was stored. To generate the noise for these larger time steps, the random increments from the reference trajectory were summed. For example, if the noise increments for the reference trajectory from t to t + h s and from t + h s to t + 2 h s were w 1 and w 2 , respectively, and the noise increment for a trajectory with time step h 1 = 2 h s from t to t + 2 h s was taken as w 1 + w 2 . This procedure was extended straightforwardly for cases requiring multiple random terms.
  • The absolute error | x f ( h n ) x r e f | was computed and stored.
  • The procedure was repeated for N = 4 × 10 6 trajectories, and the average error, E [ | x f ( h n ) x r e f | ] , was computed.
  • Finally, a fit of the average error versus h was performed using MINUIT2 [22] to determine the parameters A and α .
For integration time steps where h h s , it is reasonable to consider x r e f a proxy for the true value x l i m i t . The fit was performed using simulation data in the range 10 4 h 10 2 .
A typical case is shown in Figure 1. Note that the values of h used in the fit are significantly larger than h r e f . The results of the fit are summarized in Table 1. The points marked with light blue circles were excluded from the fit but are shown to verify the expected linear relationship on a log-log plot within the fitting range. To validate our method, we first tested the standard Euler scheme. As expected, the fit yields α = 0.53 ± 0.02 , which is consistent with the theoretical convergence order of 0.5 for the Euler scheme.
Figure 1. Typical data used for the convergence fit, showing E | x f ( h ) x r e f | vs. h. The data shown are for the Heun algorithm. The solid line is the fit to the model f ( h ) = A h α . The symbols are the results of simulations: the red diamonds were used for the fit, while the light blue circles were excluded. The arrow labeled h r e f marks the h used for the reference trajectory. The statistical error due to the finite number of averages is smaller than the symbol size.
Figure 1. Typical data used for the convergence fit, showing E | x f ( h ) x r e f | vs. h. The data shown are for the Heun algorithm. The solid line is the fit to the model f ( h ) = A h α . The symbols are the results of simulations: the red diamonds were used for the fit, while the light blue circles were excluded. The arrow labeled h r e f marks the h used for the reference trajectory. The statistical error due to the finite number of averages is smaller than the symbol size.
Entropy 27 00910 g001
Table 1. Table summarizing strong convergence and stability for each scheme. The convergence order is in the form A h α , and the table shows the value of the parameters A and α found in the fit; in the simulations for the convergence, D = 0.05 . The column “Stability” reports the number of red dots appearing on each plate of Figure 2.
Table 1. Table summarizing strong convergence and stability for each scheme. The convergence order is in the form A h α , and the table shows the value of the parameters A and α found in the fit; in the simulations for the convergence, D = 0.05 . The column “Stability” reports the number of red dots appearing on each plate of Figure 2.
AlgorithmA α Stability
Euler ( 1.8 ± 0.3 ) × 10 2 0.53 ± 0.02
Heun ( 5.4 ± 0.5 ) × 10 2 1.00 ± 0.01 191
Stra ( 9.6 ± 0.9 ) × 10 2 1.01 ± 0.01 115
Miln ( 1.8 ± 0.2 ) × 10 2 0.52 ± 0.01 91
HeSt ( 5.9 ± 0.6 ) × 10 2 1.00 ± 0.01 172
HePC ( 5.4 ± 0.5 ) × 10 2 1.00 ± 0.01 169
Mil- ( 5.6 ± 0.5 ) × 10 2 1.00 ± 0.01 165
HPC- ( 6.2 ± 0.6 ) × 10 2 1.00 ± 0.01 132
T3/2 ( 9.2 ± 0.9 ) × 10 2 1.01 ± 0.01 134
CUP1 ( 7.7 ± 0.7 ) × 10 2 1.01 ± 0.01 117
CUP2 ( 7.7 ± 0.7 ) × 10 2 1.01 ± 0.01 117
RK ( 2.4 ± 0.2 ) × 10 2 0.85 ± 0.01 135
Figure 2. Stability regions for the different algorithms, as function of D and h. The red dots mark the parameters for which the given scheme did not blow up.
Figure 2. Stability regions for the different algorithms, as function of D and h. The red dots mark the parameters for which the given scheme did not blow up.
Entropy 27 00910 g002
Most schemes show strong convergence of order O ( h ) . The simple Stratonovich scheme (Stra, Equation (9)) also has O ( h ) convergence. This may seem surprising given that the Euler scheme is only O ( h 1 / 2 ) , but it is consistent with the fact that the Stratonovich scheme includes terms up to O ( h ) from the Taylor expansion in Equation (13).
Interestingly, the Heun scheme variant that uses the Milstein algorithm (Miln) as its building block achieves only O ( h 1 / 2 ) strong convergence. However, O ( h ) convergence is recovered in the Mil-scheme, where the sign of the 1 2 g g term is changed in the corrector step, a modification made in the spirit of the derivation of Equation (10). Note, however, that the Heun scheme has a strong convergence O ( h ) , contrary to the claim of [9]: a similar result was found in [18].
On the other hand, the strong convergence found for the higher-order Taylor-based schemes is rather surprising. The T3/2 algorithm shows strong convergence of only O ( h ) , despite being based on a Taylor expansion that includes terms up to O ( h 3 / 2 ) . This issue is even more acute for the CUP1 and CUP2 schemes, which also exhibit strong convergence of only O ( h ) , despite their Taylor expansion (Equation (13)), including terms up to O ( h 2 ) . We also examined the Runge–Kutta scheme of [23], which includes terms O ( h 2 ) and was believed to have a strong convergence O ( h 3 / 2 ) , and found its strong convergence to be only O ( h ) . To rule out possible numerical artifacts or coding errors, we repeated the assessment of the Taylor-based schemes using SDE d x = x d t + D x d W , which can be solved analytically: it was possible to confirm that the integration routines were integrating correctly and the overall numerical approach was sound.

4.2. Stability

To establish the parameter regions where the integration remains stable, the system was simulated by varying the parameters D and h: 20 values for D and 20 values for h were selected, as shown in Figure 2. For all simulations and algorithms, 3 × 10 4 trajectories, each starting from a random point drawn from the equilibrium distribution, were tracked up to a time of 10 4 . Thus, if h = 10 2 , each trajectory was integrated for 10 4 / h = 10 6 elementary time steps. If | x | > 100 at any point during the integration for any of the trajectories, we marked that parameter set as unstable for the given algorithm.
The results of these simulations are shown in Figure 2. The “Stability” column in Table 1 reports the number of ( D , h ) parameter pairs for which the simulations remained stable (i.e., did not diverge) for each algorithm.
The Heun scheme proved to be the most stable, followed by HeSt, HePC, and Mil-. Conversely, the Taylor-based schemes performed worse, particularly CUP1 and CUP2. This result is not surprising, as the introduction of a corrector step in a numerical integration scheme is known to improve stability.

4.3. Stationary Distributions

To study the stationary distributions, we performed simulations across a grid of parameters, using 20 values for h in the range [ 0.01 ,   0.2 ] and 10 values for D in the range [ 0.01 ,   0.25 ] . For each integration scheme and for each ( D , h ) pair, we computed 4 × 10 5 trajectories with initial conditions drawn from the Stratonovich theoretical equilibrium distribution. Each trajectory was integrated up to a time T = 10 4 and sampled at intervals of Δ T = 1.0 . The value of x at each sample was accumulated to construct the equilibrium probability density, hereafter denoted as P ( x ) . In total, each P ( x ) is constructed from 4 × 10 9 data points.
Typical results are shown in Figure 3 for a small D value, in Figure 4 for a large D value, and for two different values of h.
These figures show that for small h, the agreement between theory and simulation is good for both values of D. As h increases, the agreement deteriorates, with the magnitude of the deviation depending on the integration scheme. For instance, the results for D = 0.25 and h = 0.2 (Figure 4, right) show the emergence of spurious structures for some schemes. Overall, the Stra scheme is the first to deviate from the theoretical distribution. At h = 0.2 , the HePC scheme appears to yield the distribution closest to the theory, followed by CUP2, CUP1, and Heun, for both values of D.
To quantitatively assess the deviation of the simulated distribution P ( x ) from the theoretical one P e q ( x ) , we introduced two metrics. The first, which we term the “distance,” is defined as | P e q ( x ) P ( x ) | d x . The second, the “ratio,” is defined as | ( P e q ( x ) P ( x ) ) / P e q ( x ) | d x = | 1 P ( x ) / P e q ( x ) | d x , where this integral is restricted to the region where P e q ( x ) 10 4 P e q ( 0 ) . The distance metric emphasizes discrepancies near the origin where the probability density is large and statistics are robust, but it is less sensitive to differences in the tails. Conversely, the ratio metric places more weight on the tails, a region where statistics may be less reliable. For both metrics, a smaller value indicates better agreement between the simulated and theoretical distributions.
Figure 5, Figure 6, Figure 7 and Figure 8 show the behavior of the two metrics as h is increased, for four D values.
As expected, both the distance and ratio metrics typically increase with h. For the smallest value of D considered (Figure 5), the distance between simulation and theory is small for most schemes at small h, with the Stra and T3/2 schemes being notable exceptions. As h increases, the distance for the HePC scheme remains roughly constant, while it grows for the others. At the largest h considered, HePC performs best, followed by CUP1, CUP2, and Heun. The behavior of the ratio metric is similar, with only minor changes in the relative performance of CUP1, CUP2, and Heun at large h.
The evolution of the metrics for the largest D considered (Figure 8) shows some interesting differences. At small h, the HePC scheme no longer stands out. It emerges as the best performer in terms of distance only as h increases, and its advantage is less pronounced than for smaller D. In terms of the ratio, the Heun scheme performs best, followed by HePC.
The results for intermediate values of D, shown in Figure 6 and Figure 7, exhibit transitional behavior between these two extremes for both metrics.

5. Conclusions

In this work, we have conducted a critical re-examination of the Heun algorithm and several of its variants for the numerical integration of Stochastic Differential Equations. Motivated by the fact that the standard Heun scheme is based on the low-order Euler method, we systematically evaluated a dozen different algorithms, assessing their performance based on three key criteria: strong convergence, numerical stability, and the ability to reproduce correct long-time equilibrium distributions.
Our extensive numerical simulations lead to several key conclusions. First, despite its simplicity, the standard Heun scheme demonstrates remarkable robustness. It was found to be the most stable of all tested algorithms across a wide range of parameters and consistently produced accurate equilibrium distributions, especially when considering metrics that weight the tails of the distribution. This confirms its status as a reliable benchmark for SDE integration. There are some rare cases when HePC fared better, but given that this scheme requires several evaluations of the quantities f ( x ) and g ( x ) it should be weighted carefully whether to prefer HePC to an integration carried out with Heun and a smaller h.
Second, a surprising and significant finding is the underperformance of theoretically higher-order schemes. Taylor-based schemes, such as T3/2 and CUP, which include terms up to O ( h 3 / 2 ) and O ( h 2 ) , respectively, failed to achieve a strong convergence order beyond O ( h ) . This suggests that simply including more terms from a Taylor expansion does not guarantee improved strong convergence in practice and highlights the complex relationship between theoretical order and numerical performance. These higher-order schemes also proved to be significantly less stable than the predictor-corrector type methods.
Third, our analysis of strong convergence has clarified a point of confusion in the literature. We have shown conclusively that the Heun scheme has a strong convergence of order O ( h ) , disproving an earlier claim that suggested an order of O ( h 3 / 2 ) .

Funding

Support is acknowledged from the “National Centre for HPC, Big Data, and Quantum Computing”, under the National Recovery and Resilience Plan (PNRR), Mission 4, Component 2, Investment 1.4, funded from the European Union—NextGenerationEU.

Data Availability Statement

Data are available upon reasonable request. F90 codes are available at https://github.com/dundacil/heun_extension, accessed on 10 August 2025.

Acknowledgments

We thank the Green Data Center of University of Pisa for providing the computational power needed for the present paper. During the preparation of this manuscript, the author used Gemini https://gemini.google.com/app (accessed on 10 August 2025), for the purposes of improving the English and readability of some of the textual content. The author has reviewed and edited the output and takes full responsibility for the content of this publication.

Conflicts of Interest

The author declares no conflicts of interest.

References

  1. Gardiner, C.W. Stochastic Methods: A Handbook for the Natural and Social Sciences; Springer Series in Synergetics; Springer: Berlin/Heidelberg, Germany, 2009. [Google Scholar]
  2. Øksendal, B. Stochastic Differential Equations: An Introduction with Applications; Springer: Berlin/Heidelberg, Germany, 2003. [Google Scholar] [CrossRef]
  3. Kloeden, P.E.; Platen, E. Numerical Solution of Stochastic Differential Equations; Springer: Berlin/Heidelberg, Germany, 1992. [Google Scholar] [CrossRef]
  4. Van Kampen, N.G. Stochastic Processes in Physics and Chemistry; Elsevier: North Holland, The Netherlands, 2007. [Google Scholar] [CrossRef]
  5. Mannella, R.; McClintock, P.V.E. Itô versus Stratonovich: 30 years later. Fluct. Noise Lett. 2012, 11, 1240010. [Google Scholar] [CrossRef]
  6. Heun, K. Neue Methode zur approximativen Integration der Differentialgleichungen einer unabhängigen Veränderlichen. Z. Math. Phys. 1900, 45, 23–38. [Google Scholar]
  7. Butcher, J. A history of Runge-Kutta methods. Appl. Numer. Math. 1996, 20, 247–260. [Google Scholar] [CrossRef]
  8. Rümelin, W. Numerical treatment of stochastic differential equations. SIAM J. Numer. Anal. 1982, 19, 604–613. [Google Scholar] [CrossRef]
  9. Kloeden, P.E.; Pearson, R.A. The numerical solution of stochastic differential equations. J. Aust. Math. Soc. Ser. B Appl. Math. 1977, 20, 8–12. [Google Scholar] [CrossRef]
  10. Klauder, J.R.; Petersen, W.P. Numerical Integration of Multiplicative-Noise Stochastic Differential Equations. SIAM J. Numer. Anal. 1985, 22, 1153–1166. [Google Scholar] [CrossRef]
  11. Mannella, R. Integration of Stochastic Differential Equations on a Computer. Int. J. Mod. Phys. C (IJMPC) 2002, 13, 1177–1194. [Google Scholar] [CrossRef]
  12. Mannella, R. Computer experiments in non-linear stochastic physics. In Noise in Nonlinear Dynamical Systems; Moss, F., McClintock, P.V.E., Eds.; Cambridge University Press: Cambridge, UK, 1989; pp. 189–221. [Google Scholar]
  13. Mil’shtejn, G.N. Approximate integration of stochastic differential equations. Theory Probab. Appl. 1975, 19, 557–562. [Google Scholar] [CrossRef]
  14. Rao, N.J.; Borwanker, J.D.; Ramkrishna, D. Numerical Solution of Ito Integral Equations. SIAM J. Control 1974, 12, 124–139. [Google Scholar] [CrossRef]
  15. Mannella, R.; Palleschi, V. Fast and precise algorithm for computer simulation of stochastic differential equations. Phys. Rev. A Gen. Phys. 1989, 40, 3381–3386. [Google Scholar] [CrossRef] [PubMed]
  16. Sancho, J.M.; Miguel, M.S.; Katz, S.L.; Gunton, J.D. Analytical and numerical studies of multiplicative noise. Phys. Rev. A 1982, 26, 1589–1609. [Google Scholar] [CrossRef]
  17. Mannella, R. Quasisymplectic integrators for stochastic differential equations. Phys. Rev. E 2004, 69, 041107. [Google Scholar] [CrossRef] [PubMed]
  18. Bogoi, A.; Dan, C.I.; Strătilă, S.; Cican, G.; Crunteanu, D.E. Assessment of Stochastic Numerical Schemes for Stochastic Differential Equations with “White Noise” Using Itô’s Integral. Symmetry 2023, 15, 2038. [Google Scholar] [CrossRef]
  19. MPICH. Available online: https://mpich.org (accessed on 10 August 2025).
  20. Press, W.H.; Flannery, B.P.; Teukolsky, S.A.; Vetterling, W.T. Numerical Recipes in FORTRAN 77: The Art of Scientific Computing, 2nd ed.; Cambridge University Press: Cambridge, UK, 1992. [Google Scholar]
  21. Higham, D.J. An Algorithmic Introduction to Numerical Simulation of Stochastic Differential Equations. SIAM Rev. 2001, 43, 525–546. [Google Scholar] [CrossRef]
  22. James, F.; Roos, M. Minuit: A System for Function Minimization and Analysis of the Parameter Errors and Correlations. Comput. Phys. Commun. 1975, 10, 343–367. [Google Scholar] [CrossRef]
  23. Honeycutt, R.L. Stochastic Runge-Kutta algorithms. I. White noise. Phys. Rev. A 1992, 45, 600–603. [Google Scholar] [CrossRef] [PubMed]
Figure 3. Simulation results, carried out for D = 0.1 × 10 1 , h = 0.01 (left), and h = 0.2 (right). Top row shows P ( x ) , bottom row P e q ( x ) P ( x ) . Different symbols are the different schemes.
Figure 3. Simulation results, carried out for D = 0.1 × 10 1 , h = 0.01 (left), and h = 0.2 (right). Top row shows P ( x ) , bottom row P e q ( x ) P ( x ) . Different symbols are the different schemes.
Entropy 27 00910 g003
Figure 4. Simulation results, carried out for D = 2.5 × 10 1 , h = 0.01 (left), and h = 0.2 (right). Top row shows P ( x ) , bottom row P e q ( x ) P ( x ) . Different symbols are the different schemes.
Figure 4. Simulation results, carried out for D = 2.5 × 10 1 , h = 0.01 (left), and h = 0.2 (right). Top row shows P ( x ) , bottom row P e q ( x ) P ( x ) . Different symbols are the different schemes.
Entropy 27 00910 g004
Figure 5. The distance | P e q ( x ) P ( x ) | d x (left) and the ratio | 1 P ( x ) / P e q ( x ) | d x (right) for different hs and D = 0.01 . Note the log scale on the ordinates. Different symbols are the different schemes.
Figure 5. The distance | P e q ( x ) P ( x ) | d x (left) and the ratio | 1 P ( x ) / P e q ( x ) | d x (right) for different hs and D = 0.01 . Note the log scale on the ordinates. Different symbols are the different schemes.
Entropy 27 00910 g005
Figure 6. The distance | P e q ( x ) P ( x ) | d x (left) and the ratio | 1 P ( x ) / P e q ( x ) | d x (right) for different hs and D = 0.09 . Note the log scale on the ordinates. Different symbols are the different schemes.
Figure 6. The distance | P e q ( x ) P ( x ) | d x (left) and the ratio | 1 P ( x ) / P e q ( x ) | d x (right) for different hs and D = 0.09 . Note the log scale on the ordinates. Different symbols are the different schemes.
Entropy 27 00910 g006
Figure 7. The distance | P e q ( x ) P ( x ) | d x (left) and the ratio | 1 P ( x ) / P e q ( x ) | d x (right) for different hs and D = 0.17 . Note the log scale on the ordinates. Different symbols are the different schemes.
Figure 7. The distance | P e q ( x ) P ( x ) | d x (left) and the ratio | 1 P ( x ) / P e q ( x ) | d x (right) for different hs and D = 0.17 . Note the log scale on the ordinates. Different symbols are the different schemes.
Entropy 27 00910 g007
Figure 8. The distance | P e q ( x ) P ( x ) | d x (left) and the ratio | 1 P ( x ) / P e q ( x ) | d x (right) for different hs and D = 0.25 . Note the log scale on the ordinates. Different symbols are the different schemes.
Figure 8. The distance | P e q ( x ) P ( x ) | d x (left) and the ratio | 1 P ( x ) / P e q ( x ) | d x (right) for different hs and D = 0.25 . Note the log scale on the ordinates. Different symbols are the different schemes.
Entropy 27 00910 g008
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Mannella, R. Numerical Integration of Stochastic Differential Equations: The Heun Algorithm Revisited and the Itô-Stratonovich Calculus. Entropy 2025, 27, 910. https://doi.org/10.3390/e27090910

AMA Style

Mannella R. Numerical Integration of Stochastic Differential Equations: The Heun Algorithm Revisited and the Itô-Stratonovich Calculus. Entropy. 2025; 27(9):910. https://doi.org/10.3390/e27090910

Chicago/Turabian Style

Mannella, Riccardo. 2025. "Numerical Integration of Stochastic Differential Equations: The Heun Algorithm Revisited and the Itô-Stratonovich Calculus" Entropy 27, no. 9: 910. https://doi.org/10.3390/e27090910

APA Style

Mannella, R. (2025). Numerical Integration of Stochastic Differential Equations: The Heun Algorithm Revisited and the Itô-Stratonovich Calculus. Entropy, 27(9), 910. https://doi.org/10.3390/e27090910

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop