Dicrete gradient method for ODEs  was developed for carying numeric calculations in which essential part was played by preserving a first integral or Lyapunov-type behavior of some quantity. Typically it was used on Hamiltonian systems
where function was the one to be preserved by the algorithm.
Of course, Hamiltonian systemss, due to their analytic properties , are quaitatively well discretized by the symplectic schemes (e.g. textbook , classical papers[13, 24], and for more modern geometric approach ) even when they admit some perturbation . However, it would be useful to have at our disposal gradient scheme that would be efficient in general, non-conservative case, what this paper aims to deliver.
To convey the main principle on which the method is based, we concentrate exclusively on one-dimensional systems. Then the scheme looks as follows
where we choose one of possible discrete gradient forms , this one called coordinate increment discrete gradient (also one of its versions - may even be symmetric!).
Slightly rearranging and cross-multiplying above equations shows
that is, Hamiltonian will be conserved at every step up to machine accuracy.
This brief article is organized as follows: In sec. 2 we use the test-bench example of damped harmonic oscillator, as one with accessible exact solution to measure parameters (local and global error, energy decrementation rate etc,) in our new scheme, then, in sec. 3 we use modified gradient method on van der Pol oscillator - system well described in literature in many different contexts (e.g. [22, 9] and  for FitzHugh-Nagumo generalization), of course here we perform only some basic tests. Sec. 4 is the last in the paper and is devoted to concluding remarks and possibilities the new method offers.
2 Modified discrete gradient scheme for non-conservative systems
Now we consider a little more general system
An obvious remark is that energy is non-constant for this system, actually it obeys
hence if we would find quantity with exactly opposite time behavior, sum of the energy and this new quantity would be conserved.
Let us introduce new artificial reservoir variable (which, from point of view of solving (2.1), is completely redundant (however numerically situation is completely defferent)
from what we see their possess proper time derivative (here there matters only numerical values at each moment). The quantity
will be referred to as effectively conserved, as numerically it should stay constant, in other words
as follows from (2.1).
Strikingly simple physical interpretation of (initial energy), makes it pretty natural guess for conserved quantity associated with dissipative system. This simple effect is obtained by considering dissipative forces as contained in the system.
Coming to an example of damped oscillator
where is the damping constant, we put
where we are able to express evolution of in quite arbitrary way - its flow should only obey the condition of becoming in the continuous limit. Note that we change every time we change .
Above scheme guarantees that
as declared before. Note that in this way we provided global effective invariant for numerical scheme, hence our reasoning is of huge practical importance.
In the following, we will solve implicit equations with tolerance , time-step will take the value . The system on which we will test the new approach will be damped harmonic oscillator. For reservoir variable we will use method
In order to check how our new approach works, we perform numerical experiment, consisting in executing few different algorithms on the same set of initial data. We compare our modification of discrete gradient method (modDG, blue) with symplectic leap-frog scheme (pqpLF, red) and the implicit midpoint rule (IMR, magenta). Note that all schemes used here are of order two.
We use initial conditions .
Continuous system is
where is the damping constant and we have already included reservoir in the description.
The leap-frog scheme as indicating by equations of motion, is
so it is an explicit scheme (because equations of motion are linear).
To compare with modGR scheme, we adjoin the reservoir obeying numerical evolution
Despite the classical features (order, errors behavior, etc.) we will care about the energy decrement at each step
where we made use of definition of the effectively conserved quantity.
It occurs modGR scheme is of order two for variables, but fortunately of order three for . hence it is wiser to use this variable, whenever possible. We note that for value of we used midpoint approximation.
Combination of previously stated remarks leads to fig. 4.2. IMR and pqpLF perform equally poor when compared with our modGR scheme.
Figure 4.1.: Deviation from initial value of . We adjoined reservoir to pqpLF to see, how it conserves .
Figure 4.2.: Comparison of deviation from theoretical value of energy decrement. modGR is better through six orders of magnitude.
Figures below center around behavior of and modulus maxima for different vlues of . We are not able to perform tests for larger values since the damped system finally comes to rest, and the bigger is, the faster it comes. If numerical scheme admits this kind of behavior, when continuous system does, we call corresponding numerical method A-stable. In the next section we will be able to perform more tests since van der Pol oscillator is alternately damped and stimulated.
Below, continuous lines with circles denote , dashed lines with circles are for and continuous lines with asterisks is .
We use also .
Figure 4.3.: Deviation from initial value of . Surprising is the fact, that (in reasonable interval) gradient performs better with bigger time step, but LF goes worse.
Figure 4.4.: for different schemes with different time steps. Nearly unprecedented winner is the modGR scheme.
3 Practical test: van der Pol oscillator
Van der Pol oscillator is a widely used physical systems in many contexts (e.g. [8, 9]). Since it is non-integrable, we are forced to study only its numerical properties and could examine how our method work in this particular case. Equations of motion are
which means for it is a perturbative system (see e.g.  , especially in numerical context).
Modified discrete gradient works as usual, but we choose midpoint approximation to define evolution of artificial variable :
Figure 4.4.: On the left showing perturbative behavior and on the right picture being sstrongly non-linear. All the phase-trajectories admit stable limit cycles.
Proper phase curves behavior for a certain range of values of gives basic confirmation of our idea being reasonable. Next trial is to check how initial value of is conserved, when the dynamics is generated by van der Pol term with all the sifferent ’s.
We use and for every value we search for maximum modulus of deviation from initial value of . Fig. 4.5 is qualitative in nature, since it illustrates only the search during units of time evolution. It does not follow from it that for huge simulation does not break down for longer times - usually cumulation of errors has this effect. One obvious remark we get from this experiment is that the bigger we consider, the smaller time step is needed for safe usage of gradient scheme.
Figure 4.5.: Deviations for different values of . Blue line represents simulation with , red-, green- and magenta-.
Effectively conserved quantity increases stability of the scheme (as any conserved quantity always does). In the former case of damped harmonic oscillator it guaranteed conditional A-stability (A-stability for some specified range of time-steps). As shown on the right, the same effect occurs for van der Pol oscillator, e.g. line for (red) completely fails at the values of , where iss not being kepr constant properly.
This simple experiment ends our brief survey of finding dissipative analogue of discrete gradient scheme. Nonlinear systems, as stiff by nature, will certainly benefit from such improved numerical treatment.
4 Concluding remarks
Goal of this paper was to show that modified gradient scheme with computational invariant works, and it was achieved. Of course further investigation has to be proceeded concerning technical details of implementation. Also higher-dimensional systems need to be inspected under the treatment, and non-atonomous systems are to be given a closer look (not speaking obout other interesting autonomous cases).
Scheme we proposed is of order two, but rising accuracy is not so easy like in the case of conservative systems. Ideas given in  has led to rising order for the method without improving accuracy even a bit. This weird effect is closely related to the form of dissipative systems.
Existence of a conserved quantity opens possibilities for geometric treatment of non-conservative systems in general, along the lines of GNI (e.g. [18, 16]) approach. Especially when combined with higher-dimensions it may be useful to confront our modification of gradient scheme with ideas of local invariants  and local exactness .
-  W.I.Arnold: “Mathematical methods of classical mechanics”, PWN 1981 (in Polish),
R.Belousov, F.Berger, A.J.Huspeth: “
Volterra-series approach to stochastic nonlinear dynamics: The Duffing oscillator driven by white noise”, Phys.Rev.E, 99, 042204 (2019),
-  S.Blanes, F.Casas: “A Concise Introduction to Geometric Numerical Integration”, CRC Press, 2016,
-  T.Botari, E.D.Leonel: “One-dimensional Fermi accelerator model with moving wall described by a nonlinear van der Pol oscillator”, Phys.Rev.E, 87, 012904 (2013),
-  Z.Chen, B.Raman, A.Stern: “Structure preserving numerical integrators for Hodgkin-Huxley-type systems”, arXiv: 181100173v1 [math.NA],
-  J.L.Cieśliński: “Locally exact modifications of numerical schemes”, Computers & Mathematics with Applications, Volume 65, Issue 12, 2013, Pages 1920-1938,
-  J.L.Cieśliński, B.Ratkiewicz: “Long-time behavior of discretizations of the simple pendulum equation”,J.Phys.A: Math.Theor. 42 (2009), 105204 (29pp), IOP Publishing,
-  J.L.Cieśliński, B.Ratkiewicz: “Improving the accuracy of the discrete gradient method in the one-dimensional case”, Phys. Rev. E 81, 016704 (2010),
-  P.J.Channel, C.Scovel: “Symplectic integration of Hamiltonian systems”, Nonlinearity 3(1990), 231-259, IOP Publishing Ltd,
-  A.Gawlik, S.Skurativskyi, V.Vladimirov: “Solitary waves dynamics governed by the modified FitzHugh-Nagumo equation”, arXiv: 1906.01865v1 [nlin.PS], 2019,
-  E.Hairer, C.Lubich: “Invariant tori of dissipatively perturbed Hamiltonian systems under symplectic discretization”, Applied Numerical Mathematics 29 (1999), 57-71, Elsevier,
E.Hairer, C.Lubich, G.Wanner: “
Geometric Numerical Integration: Structure-preserving algorithms for ordinary differential equations”, Springer Verlag, 2006,
-  E.Hairer, C.J.Zbinden: “Conjugate Symplectic B-Series”, AIP Conference Proceedings 2012, DOI: 10.1063/1.4756053
-  A.Iserles: “A first course in the numerical analysis of differential equations”, Cambridge University Press, 2009,
-  T.Matsuda, T.Matsuo: “A new geometric integration approach based on local invariants”, JSIAM Letters Vol.5 (2013), pp. 37-40,
-  R.I.McLachlan, G.R.W.Quispel, N.Robidoux: “Geometric integration sing discrete gradients”, Phil.Trans.R.Soc.Land. A (1999) 357, 1021-1045, The Royal Society Publishing,
-  E.Süli, D.Meyers: “An Introduction to numerical analysis”, Cambridge University Press, 10th printing, 2014,
-  U.Parlitz, W.Lauterborn: “Period-doubling cascades and devil’s staircases of the driven van der Pol oscillator”, Phys.Rev.A, vol 36 (3), 1987,
-  G.R.W.Quispel, H.W.Capel: “Solving ODEs numerically while preserving a first integral”, Phys.Let.A 218 (1996), 223-228, Elsevier,
-  H.Yoshida: “Recent progress in the theory and applications of symplectic integrators”, Celestial Mechanics and Dynamical Astronomy 56 (1993), 27-43, Kluwer Academic Publishers,