Abstract
In research problems that involve the use of numerical methods for solving systems of ordinary differential equations (ODEs), it is often required to select the most efficient method for a particular problem. To solve a Cauchy problem for a system of ODEs, Runge–Kutta methods (explicit or implicit ones, with or without step-size control, etc.) are employed. In that case, it is required to search through many implementations of the numerical method and select coefficients or other parameters of its numerical scheme. This paper proposes a library and scripts for automated generation of routine functions in the Julia programming language for a set of numerical schemes of Runge–Kutta methods. For symbolic manipulations, we use a template substitution tool. The proposed approach to automated generation of program code allows us to use a single template for editing, instead of modifying each individual function to be compared. On the one hand, this provides universality in the implementation of a numerical scheme and, on the other hand, makes it possible to minimize the number of errors in the process of modifying the compared implementations of the numerical method. We consider Runge–Kutta methods without step-size control, embedded methods with step-size control, and Rosenbrock methods with step-size control. The program codes for the numerical schemes, which are generated automatically using the proposed library, are tested by solving numerically several well-known problems.
Similar content being viewed by others
REFERENCES
Hairer, E., Nørsett, S.P., and Wanner, G., Solving Ordinary Differential Equations I, Berlin: Springer, 2008, 2nd ed.
Hairer, E. and Wanner, G., Solving Ordinary Differential Equations II: Stiff and Differential-Algebraic Problems, 1996, 2nd ed.
Fortran and Matlab codes. https://www.unige.ch/~hairer/software.html.
Dormand, J.R. and Prince, P.J., A family of embedded Runge–Kutta formulae, J. Comput. Appl. Math., 1980, vol. 6, no. 1, pp. 19–26.
Prince, P.J. and Dormand, J.R., High order embedded Runge–Kutta formulae, J. Comput. Appl. Math., 1981, vol. 7, no. 1, pp. 67–75.
MathWorks, Matlab. https://www.mathworks.com/products/matlab.html.
GNU Octave. https://www.gnu.org/software/octave.
Jones, E., Oliphant, T., and Peterson, P., SciPy: Open source scientific tools for Python. https://www.scipy.org.
Scilab. https://www.scilab.org.
Boost C++ Libraries. https://www.boost.org.
Gevorkyan, M.N., Velieva, T.R., Korolkova, A.V., et al., Stochastic Runge–Kutta software package for stochastic differential equations, Dependability Engineering and Complex Systems, Springer, 2016, vol. 470, pp. 169–179.
Kulyabov, D.S., Gevorkyan, M.N., Demidova, A.V., et al., Implementation difficulties analysis of stochastic numerical Runge–Kutta methods, Proc. 2nd Int. Sci. Conf. Convergent Cognitive Information Technologies, Shneps-Shneppe, M., Sukhomlin, V., and Zubareva, E., Eds., Moscow, 2017.
Gevorkyan, M.N., Demidova, A.V., Korolkova, A.V., and Kulyabov, D.S., Issues in the software implementation of stochastic numerical Runge–Kutta, Distributed Computer and Communication Networks, Vishnevskiy, V.M. and Kozyrev, D.V., Eds., Springer, 2018.
Bezanson, J., Edelman, A., Karpinski, S., and Shah, V.B., Julia: A fresh approach to numerical computing, 2014.
Bezanson, J., Karpinski, S., Shah, V.B., and Edelman, A., Julia: A fast dynamic language for technical computing, 2012.
Kwong, T., Hands-On Design Patterns and Best Practices with Julia, Birmingham: Packt, 2020.
Gevorkyan, M.N., Korolkova, A.V., Kulyabov, D.S., and Sevast’yanov, L.A., A modular extension for a computer algebra system, Program. Comput. Software, 2020, vol. 46, pp. 98–104.
Rossum, G., Python Reference Manual, Amsterdam, 1995.
Jinja2 official website. https://http//jinja.pocoo.org.
Butcher, J.C., Numerical Methods for Ordinary Differential Equations, Wiley, 2003, 2nd ed.
Dormand, J.R. and Prince, P.J., A reconsideration of some embedded Runge–Kutta formulae, J. Comput. Appl. Math., 1986, vol. 15, no. 2, pp. 203–211.
Fehlberg, E., Klassische Runge-Kutta-Formeln fünfter und siebenter Ordnung mit Schrittweiten-Kontrolle, Computing, 1969, vol. 4, no. 2, pp. 93–106.
Fehlberg, E., Klassische Runge-Kutta-Formeln vierter und niedrigerer Ordnung mit Schrittweiten-Kontrolle und ihre Anwendung auf Wärmeleitungsprobleme, Computing, 1970, vol. 6, nos. 1–2, pp. 61–71.
Cash, J. and Karp, A., A variable order Runge–Kutta method for initial value problems with rapidly varying right-hand sides, ACM Trans. Math. Software, 1990, vol. 16, no. 3, pp. 201–222.
Funding
This work was supported by the Program “5-100" of the Peoples’ Friendship University of Russia and the Russian Foundation for Basic Research (project no. 19-01-00645).
Author information
Authors and Affiliations
Corresponding authors
Additional information
Translated by Yu. Kornienko
Rights and permissions
About this article
Cite this article
Gevorkyan, M.N., Korol’kova, A.V. & Kulyabov, D.S. Using a Template Engine as a Computer Algebra Tool. Program Comput Soft 47, 17–24 (2021). https://doi.org/10.1134/S0361768821010047
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1134/S0361768821010047