Skip to main content
Log in

Using a Template Engine as a Computer Algebra Tool

  • Published:
Programming and Computer Software Aims and scope Submit manuscript

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.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1.
Fig. 2.
Fig. 3.
Fig. 4.
Fig. 5.
Fig. 6.

Similar content being viewed by others

REFERENCES

  1. Hairer, E., Nørsett, S.P., and Wanner, G., Solving Ordinary Differential Equations I, Berlin: Springer, 2008, 2nd ed.

    MATH  Google Scholar 

  2. Hairer, E. and Wanner, G., Solving Ordinary Differential Equations II: Stiff and Differential-Algebraic Problems, 1996, 2nd ed.

  3. Fortran and Matlab codes. https://www.unige.ch/~hairer/software.html.

  4. 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.

    Article  MathSciNet  Google Scholar 

  5. 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.

    Article  MathSciNet  Google Scholar 

  6. MathWorks, Matlab. https://www.mathworks.com/products/matlab.html.

  7. GNU Octave. https://www.gnu.org/software/octave.

  8. Jones, E., Oliphant, T., and Peterson, P., SciPy: Open source scientific tools for Python. https://www.scipy.org.

  9. Scilab. https://www.scilab.org.

  10. Boost C++ Libraries. https://www.boost.org.

  11. 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.

    Article  Google Scholar 

  12. 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.

  13. 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.

    Google Scholar 

  14. Bezanson, J., Edelman, A., Karpinski, S., and Shah, V.B., Julia: A fresh approach to numerical computing, 2014.

  15. Bezanson, J., Karpinski, S., Shah, V.B., and Edelman, A., Julia: A fast dynamic language for technical computing, 2012.

  16. Kwong, T., Hands-On Design Patterns and Best Practices with Julia, Birmingham: Packt, 2020.

    Google Scholar 

  17. 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.

    Article  MathSciNet  Google Scholar 

  18. Rossum, G., Python Reference Manual, Amsterdam, 1995.

    Google Scholar 

  19. Jinja2 official website. https://http//jinja.pocoo.org.

  20. Butcher, J.C., Numerical Methods for Ordinary Differential Equations, Wiley, 2003, 2nd ed.

    Book  Google Scholar 

  21. 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.

    Article  Google Scholar 

  22. Fehlberg, E., Klassische Runge-Kutta-Formeln fünfter und siebenter Ordnung mit Schrittweiten-Kontrolle, Computing, 1969, vol. 4, no. 2, pp. 93–106.

    Article  MathSciNet  Google Scholar 

  23. 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.

    Article  MathSciNet  Google Scholar 

  24. 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.

    Article  MathSciNet  Google Scholar 

Download references

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

Authors

Corresponding authors

Correspondence to M. N. Gevorkyan, A. V. Korol’kova or D. S. Kulyabov.

Additional information

Translated by Yu. Kornienko

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

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

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1134/S0361768821010047

Navigation