Next Article in Journal
New Concepts of Vertex Covering in Cubic Graphs with Its Applications
Next Article in Special Issue
Estimating the Performance of Computing Clusters without Accelerators Based on TOP500 Results
Previous Article in Journal
Lightweight Secure Integer Comparison
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Comparison of the Selected Methods Used for Solving the Ordinary Differential Equations and Their Systems

by
Edyta Hetmaniok
and
Mariusz Pleszczyński
*,†
Faculty of Applied Mathematics, Silesian Technical University of Gliwice, 44-100 Gliwice, Slaskie, Poland
*
Author to whom correspondence should be addressed.
These authors contributed equally to this work.
Mathematics 2022, 10(3), 306; https://doi.org/10.3390/math10030306
Submission received: 20 December 2021 / Revised: 13 January 2022 / Accepted: 14 January 2022 / Published: 19 January 2022
(This article belongs to the Special Issue Applications of Symbolic and Soft Computations in Applied Sciences)

Abstract

:
Ordinary differential equations (ODEs), and the systems of such equations, are used for describing many essential physical phenomena. Therefore, the ability to efficiently solve such tasks is important and desired. The goal of this paper is to compare three methods devoted to solving ODEs and their systems, with respect to the quality of obtained solutions, as well as the speed and reliability of working. These approaches are the classical and often applied Runge–Kutta method of order 4 (RK4), the method developed on the ground of the Taylor series, the differential transformation method (DTM), and the routine available in the Mathematica software (Mat).

1. Introduction

Many problems in mathematics, physics or technics are modeled with the use of ordinary differential equations (ODEs) and the systems of such equations. However, these models are sometimes so complex that it is impossible to apply the analytical methods for solving them. In such cases, the only possibility lies in using some approximate methods. In this paper, we intend to compare three selected approaches dedicated for solving the ODEs. The first of them belong to the group of Runge–Kutta methods, very popular because of the ease of implementation and good speed of convergence of the obtained approximate solution. The most often used method, belonging to this family, is the classical Runge–Kutta method of order 4 (RK4), which is applied in the presented elaboration. This method is very popular and described in many sources; therefore, we omit here its detailed description. Instead, we recommend to the interested readers, for example, Ref. [1]. Let us only recall that in order to solve the ODE task with the aid of the RK4 method, we need to present the problem in the form of equation y = f ( x , y ) , x [ a , b ] , with the initial condition y ( a ) = y 0 . Function y ( x ) is the sought function, whereas f is the given function of two variables, defined in some region Ω R 2 . In this method, we obtain the discrete approximate solution from the relation
y i + 1 = y i + h 6 k 1 + 2 k 2 + 2 k 3 + k 4 , k = 0 , 1 , , n 1 ,
where y 0 is known from the initial condition, h = b a n , whereas
k 1 = f x i , y i , k 2 = f x i + h 2 , y i + k 1 h 2 , k 3 = f x i + h 2 , y i + k 2 h 2 , k 4 = f x i + h , y i + k 3 h ,
where x i = a + i h , i = 0 , 1 , , n .
As the second way of solving the ODEs and their systems, we will use the routines available in the Mathematica software of version 12.2 (Mat), based on the implementation of selected methods and numerical treatment of differential equations. Thanks to the instruction DSolve, one can solve analytically the ODE and ODEs tasks, and by applying the instruction NDSolve, these kind of tasks can be solved numerically. We decided to use such an approach in order to confront the solutions calculated by the authors with the solutions delivered by a machine. The methods, built in Mathematica, can be applied for solving the ODE (ODEs) tasks, not necessarily defined in the normal form, as well as the equations of higher orders (with initial boundary conditions given in various forms).
The third method, applied for solving the ODEs tasks in this work, is the differential transformation method (DTM). This is the least known approach, which gives the reason to discuss this method more carefully in the next section. The main motivation of this paper is to show some kind of universality of the DTM method—this method can be applied for various forms of initial conditions and for various forms of the solved equation, including the implicit forms, and what is more, this method often leads to the exact solution of the problem, if it exists. Another essential, often unnoticeable, advantage is the following one: if the considered equation for the given initial conditions has no a unique solution (it has more than one solution), the DTM method very often finds all these solutions.
However, as with every method, the DTM method is not free from disadvantages. One of the disadvantages lies in the fact that the more complex problems, described by means of the more complex equations or their systems, require using the individual approach and constructing “manually” the proper formulas, with the aid of which will be possible to calculate the solution. Another one is the limitation of this method applicability to the equations, the components of which are the originals (explained in the next section); however, in real applications, this limitation has no important matter. The most important disadvantage of the DTM method seems to be the form of the sought solution—the solution is assumed in the form of a (function) power series, which may have a small convergence interval (in some extreme cases, it can be just one point).
Obviously, there exist many other methods, less known and less often applied, dedicated for solving ODEs tasks. Among them, we can specify the Adomian decomposition method [2,3], the homotopy perturbation method [4] and many others.

2. Differential Transformation Method

Since the differential transformation method (DTM) is strictly connected with the expansion of a function into the Taylor series, we assume that we take into consideration only such functions, which can be expanded into the Maclaurin series (we can discuss the Maclaurin series, because the simple transformation x = x α reduces the problem of expanding function f into the Taylor series to the expansion of function f into the Maclaurin series for variable x ). Such functions are called “the originals”. So, if function f is an original, then the following equality holds
f ( x ) = k = 0 f ( k ) ( 0 ) k ! x k ,
which results directly from the theorem about the unique expansion of a function into the Maclaurin power series. This theorem states that any expansion of a function into the power series at point zero is equivalent to the expansion of this function into the Maclaurin power series.
Every original f corresponds to function F with nonnegative, integer arguments k, k = 0 , 1 , 2 , , according to the formula
F ( k ) = f ( k ) ( 0 ) k ! , k = 0 , 1 , 2 , .
Function F is called the T-function of function f, whereas the discussed transformation is called the Taylor transformation.
By having the T-function F, one can find the corresponding original in the form of its expansion into the Maclaurin series, according to the following formula
f ( x ) = k = 0 F ( k ) x k .
The Taylor transformation, introduced in [5], possesses many useful properties. Some of them result directly from the form of the Maclaurin series of the given originals, while the others must be derived in more complicated way. The discussed properties are of great practical importance and make this tool quite simple to apply. In Section 2.1, we present the properties of DTM, which will be used in the current elaboration. Proofs of these properties can be found, among others, in papers [6,7]. The authors of the current paper have also some achievements in this matter, which will be presented in detail in future papers. The DTM method quickly gained recognition and was used for many different problems, such as for solving ODE systems [8], partial differential equations [9], differential-algebraic equations [7], selected types of equations, such as the Schrödinger equation [10], Riccati equation [11] or Bratu problem [12], integral equations and integro-differential equations [13,14], fuzzy differential equations [15], differential–difference equations [16], fractional differential equations [17]. The authors successfully used this method also in the calculus of variations, the difference equation, the difference–differential equation and various types of systems of the equations mentioned above (see, for example, the application of a similar method in [18] for the systems of equations).

2.1. Properties of DTM

In all the investigated examples, we assume that the considered functions are the originals and that k = 0 , 1 , 2 ,
If f ( x ) = e λ x , then
F ( x ) = λ k k ! .
If f ( x ) = sin λ x , then
F ( x ) = λ k k ! sin π k 2 .
If f ( x ) = cos λ x , then
F ( x ) = λ k k ! cos π k 2 .
If f ( x ) = x m , m N { 0 } , then
F ( x ) = δ ( k m ) = 1 , k = m , 0 , k m .
If f ( x ) = λ u ( x ) ± w ( x ) , then
F ( x ) = λ U ( k ) ± W ( k ) .
If f ( x ) = u ( x ) w ( x ) , then
F ( x ) = r = 0 k U ( r ) W ( k r ) = r = 0 k W ( r ) U ( k r ) .
If f ( x ) = u ( m ) ( x ) , m N , then
F ( x ) = ( k + m ) ! k ! U ( k + m ) .
If f ( x ) = g 1 ( x ) g 2 ( x ) g n 1 ( x ) g n ( x ) , then
F ( k ) = r n 1 = 0 k r n 2 = 0 r n 1 r 2 = 0 r 3 r 1 = 0 r 2 G 1 ( r 1 ) G 2 ( r 2 r 1 ) × × G n 1 ( r n 1 r n 2 ) G n ( k r n 1 ) , k = 0 , 1 , 2 , .
If f ( x ) = ln ( a + b u ( x ) ) , a + b u ( x ) > 0 , a , b R , then
F ( x ) = ln ( a + b U ( 0 ) ) , if   k = 0 , b U ( 1 ) a + b U ( 0 ) , if   k = 1 , b a + b U ( 0 ) U ( k ) r = 0 k 2 r + 1 k F ( r + 1 ) U ( k 1 r ) , if   k 2 .

3. Initial Assumptions and Remarks

We investigate the differential equations of order n (or the systems of such equations) possible to present in the form
F x , y ( x ) , y ( x ) , y ( x ) , , y ( n 1 ) ( x ) , y ( n ) ( x ) = 0 ,
where y ( x ) is the sought function of variable x, x X R , F is the function of n + 2 variables defined in some region Ω R n + 2 . Many methods, including the RK method, require Equation (12) to be presented in the normal form, which means the form of Equation (12) that is possible to solve with respect to variable y ( n ) :
y ( n ) ( x ) = f x , y ( x ) , y ( x ) , y ( x ) , , y ( n 1 ) ( x ) .
This is quite a strong requirement since many nonlinear differential equations cannot be presented in the normal form; therefore, the applicability of the RK methods is significantly limited.
The next requirement for applicability of the RK methods is the form of conditions ensuring the uniqueness of solutions. The most frequent form is the form of the Cauchy problem in which the conditions are presented as follows
y ( i ) ( x 0 ) = y 0 i , i = 0 , 1 , , n 1 ,
where x 0 X and y 0 i R for i = 0 , 1 , , n 1 .
It happens, however, that we look for the solution of Equation (12) by having the conditions written in the form
y ( x i ) = y i , i = 0 , 1 , , n 1 ,
where x i X , y i R , i = 0 , 1 , , n 1 , or having the combination of conditions (14) and (15).
The next problem, which can be met while using the RK methods, concerns the differential equations of the higher orders. In a case when such a kind of equation cannot be presented in the normal form, it is possible sometimes to transform it into the system of n differential equations of the first order (the number of equations in the system is equal to the order of input equation).

4. Examples

In this section, we present a few selected examples, on the base of which we compare the investigated approaches.

4.1. Example 1

The first discussed equation is the Riccati equation of the following form
y ( x ) = y 2 ( x ) + y ( x ) + 1 2 ( 1 cosh 2 x ) + e x , y ( 0 ) = 0 , x [ 0 , 2 ] .
One can easy check that the solution of Equation (16) is given by function y ( x ) = sinh x . Mathematica software finds the analytical form of the general solution of this equation, but it contains the integral that is impossible to determine, and therefore, such a solution is useless in practice. However, there is no trouble to obtain the numerical solution in the Mathematica software. Similarly easy is determining the approximate solution with the use of the RK4 method. By applying the DTM method for solving Equation (16), we use the Taylor transformation. For this purpose, we apply, among others, Formulas (3), (6)–(9), and we obtain the relation, given below, thanks to which we can determine recursively the values of the successive coefficients Y k for k 10 :
( k + 1 ) Y k + 1 = i = 0 k Y ( i ) Y ( k i ) + Y k + 1 2 δ ( k 0 ) 2 k + ( 2 ) k 4 ( 1 ) k 4 k ! .
From the initial condition, we have Y ( 0 ) = 0 and by substituting the successive values k 0 to the relation (17), we obtain in turn
Y 1 = 1 , Y 2 = 0 , Y 3 = 1 6 , Y 4 = 0 , Y 5 = 1 120 , Y 6 = 0 , Y 7 = 1 5040 , Y 8 = 0 ,
Thanks to this, we can construct the following approximate solution based on eight components
y 7 ( x ) = i = 0 7 Y i x i = x + x 3 6 + x 5 120 + x 7 5040 ,
or based on ten components as follows
y 9 ( x ) = i = 0 9 Y i x i = x + x 3 6 + x 5 120 + x 7 5040 + x 9 362880 .
In Figure 1, we present the comparison of solutions obtained with the aid of discussed methods together with the absolute errors Δ of the received approximations. In this figure, the solution obtained from the RK4 method with 21 discretization nodes is denoted by the blue dots and from the RK4 method with 41 discretization nodes denoted by brown dots. Solution (18) is denoted by yellow line and solution (19) by the red line, whereas the solution calculated in the Mathematica software is denoted by the green dashed line.
It is worth emphasizing that by using the DTM method, we obtain the exact values of the successive elements of the expansion of function sinh x into the Maclaurin series. Noting this fact, we can easily find the exact solution.

4.2. Example 2

In the second example, we discuss the system of nonlinear differential equations which can be presented in the normal form
y ( x ) = 2 x y ( x ) z ( x ) + y ( x ) + z ( x ) e 2 x x sin 2 x , z ( x ) = z ( x ) y ( x ) e 2 x ,
x [ 0 , π ] , with conditions
y ( 0 ) = 0 , z ( 0 ) = 1 .
One can easily check that the exact solution of this system is represented by functions
y ( x ) = e x sin x , z ( x ) = e x cos x .
It is worth noticing that this exact solution cannot be found by using the Mathematica software; however, there is no problem to obtain the approximate solution of the above defined system in this way.
Since the system (20) is presented in the normal form, we can apply the RK4 method, but before we do that, we have to modify this method properly in order to adapt it to the systems of differential equations. In this case (in the case of systems with more equations, the modification is similar), we have ( y 0 and z 0 are known from the initial condition (21) and h = b a n ):
k 1 f = f x i , y i , z i , k 1 g = g x i , y i , z i , k 2 f = f x i + h 2 , y i + k 1 f h 2 , z i + k 1 g h 2 , k 2 g = g x i + h 2 , y i + k 1 f h 2 , z i + k 1 g h 2 , k 3 f = f x i + h 2 , y i + k 2 f h 2 , z i + k 2 g h 2 , k 3 g = g x i + h 2 , y i + k 2 f h 2 , z i + k 2 g h 2 , k 4 f = f x i + h , y i + k 3 f h , z i + k 3 g h , k 4 g = g x i + h , y i + k 3 f h , z i + k 3 g h ,
where x i = a + i h , i = 0 , 1 , , n . Thus, we obtain
y i + 1 = y i + 1 6 k 1 f + 2 k 2 f + 2 k 3 f + k 4 f , z i + 1 = z i + 1 6 k 1 g + 2 k 2 g + 2 k 3 g + k 4 g ,
for i = 0 , 1 , , n 1 .
Similar to the previous example, the greatest attention should be paid to the DTM method. This time, by using, among others, the properties (3), (4), (6)–(10), we transform the system (20) with conditions (21) into the following system for k = 0 , 1 , 2 , :
( k + 1 ) Y k + 1 = 2 i = 0 k j = 0 i δ ( j 1 ) Y i j Z k i + Y k + + i = 0 k Z i 2 k i ( k i ) ! 0 , k = 0 , 2 k 1 sin ( k 1 ) π 2 ( k 1 ) ! , k 1 , ( k + 1 ) Z k + 1 = Z k i = 0 k Y i ( 2 ) k i ( k i ) ! ,
where
Y 0 = 0 , Z 0 = 1 .
Substituting the successive values k = 0 , 1 , 2 , in the system (22), we obtain
Y 1 = 1 , Y 2 = 1 , Y 3 = 1 3 , Y 4 = 0 , Y 5 = 1 30 , Z 1 = 1 , Z 2 = 0 , Z 3 = 1 3 , Z 4 = 1 6 , Z 5 = 1 30 ,
Generating in this way the successive values of T-functions Y i and Z i , i 13 , we can construct the approximate solution based on eleven components
y 10 ( x ) = i = 0 7 Y i x i = x + x 2 + x 3 3 x 5 30 x 6 90 x 7 630 + x 9 22680 + x 10 113400 .
Figure 2 presents the comparison of solutions for functions y (left figure) and z (right figure) obtained by using all the discussed approaches, whereas Figure 3 displays the absolute errors Δ of these approximate solutions for function y (left figure) and z (right figure). In the plots, the blue dots denote the solutions obtained by using the RK4 method with 51 discretization nodes, brown dots—by using RK4 method with 101 discretization nodes, yellow line—solutions y 15 and z 15 obtained by using the DTM method, red line—solutions y 19 and z 19 received by using the DTM method, and finally the green dashed line represents the solution calculated by applying the Mathematica software.
It should be emphasized that by applying the DTM method, we get the exact values of the successive elements of the expansions of functions y and z into the Maclaurin series. This time, however, it is not easy to notice what the analytical forms of these functions are. Therefore, we use the routine FindGeneratingFunction, implemented in the Mathematica software, thanks to which we can obtain the exact solutions (20) and (21) of the investigated problem.

4.3. Example 3

In this example, we intend to find the solution of the initial problem described by the system of equations
y ( x ) = y ( x ) z ( x ) + sin 2 x , z ( x ) = 2 y ( x ) + z ( x ) 3 sin 2 x 1 ,
for x [ 0 , π 2 ] , with conditions
y ( 0 ) = 0 , y ( 0 ) = 0 , z ( 0 ) = 1 , z ( 0 ) = 2 .
In order to apply the RK4 method for solving problems (23) and (24), we need to transform the discussed problem into the system of equations of the first order. Having the n-order differential equation of the form
y ( n ) ( x ) = f x , y ( x ) , y ( x ) , , y ( n 1 ) ( x ) ,
for x [ a , b ] , with conditions
y ( a ) = y 0 , y ( a ) = y 1 , y ( a ) = y 2 , , y ( n 1 ) ( a ) = y n 1 ,
we can introduce new variables
z 1 ( x ) = y ( x ) , z 2 ( x ) = y ( x ) , z 3 ( x ) = y ( x ) , , z n ( x ) = y ( n 1 ) ( x ) ,
thanks to which the given equation can be written in the form of the system of the first-order differential equations, as follows
z 1 ( x ) = z 2 ( x ) , z 2 ( x ) = z 3 ( x ) , z n 1 ( x ) = z n ( x ) , z n ( x ) = f x , z 1 ( x ) , z 2 ( x ) , , z n ( x ) ,
with conditions
z 1 ( a ) = y 0 , z 2 ( a ) = y 1 , z 3 ( a ) = y 2 , , z n ( a ) = y ( n 1 ) .
By acting in this way, we transform problems (23) and (24) into the form of the system of four differential equations of the first order, and next, similar to example 4.2, we adapt the formulas describing the RK4 method to the dimension of the task.
Again, similar to the previous examples, Mathematica software is not able to give the solution of the investigated problem in the analytical form, but it can easily give the approximate solution.
Solving this problem with the aid of the DTM method, we assume that the functions Y and Z represent the images of functions y and z. Basing on the properties (4)–(7) and (9), we obtain the following system of equations from the system of Equations (23) and conditions (24), for k = 0 , 1 , 2 , :
( k + 1 ) ( k + 2 ) Y k + 2 + ( k + 1 ) Z k + 1 = Y k + 1 2 δ ( k 0 ) + 2 k 1 cos k π 2 k ! , ( k + 1 ) ( k + 2 ) Z k + 2 2 ( k + 1 ) Y k + 1 = Z k δ ( k 0 ) + 3 2 k sin k π 2 k ! ,
where
Y 0 = 0 , Y 1 = 0 , Z 0 = 1 , Z 1 = 2 .
Substituting in the system (25) the successive values k = 0 , 1 , 2 , , we obtain
Y 2 = 1 , Y 3 = 0 , Y 4 = 1 3 , Y 5 = 0 , Y 6 = 2 45 , Z 2 = 0 , Z 3 = 4 3 , Z 4 = 0 , Z 5 = 4 15 , Z 6 = 0 ,
Generating in this way the successive values of T-functions Y i and Z i , for i 16 , and applying next, once again, the routine FindGeneratingFunction, built in the Mathematica software, we receive the exact solution of the examined problem
y 1 = sin 2 x , y 2 = 1 + sin 2 x .
Correctness of this result can be easily verified.
In Figure 4, we show the comparison of solutions for functions y (left figure) and z (right figure) obtained by using all the examined approaches, whereas Figure 5 presents the absolute errors Δ of these approximate solutions for function y (left figure) and z (right figure). In the plots, the blue dots denote the solutions obtained by using the RK4 method with 51 discretization nodes, brown dots—by using the RK4 method with 101 discretization nodes, yellow line—solutions y 15 and z 15 received by using the DTM method, red line—solutions y 19 and z 19 obtained by using the DTM method, and finally the green dashed line represents the approximate solution given by the Mathematica software.

4.4. Example 4

As the next example, in this section, we consider the system of differential equations with the boundary conditions, different from the previous example when the system is completed by the initial conditions.
So, we have the system of differential equations
y ( x ) = y ( x ) e x z ( x ) 1 + z ( x ) + e x + sin 2 x , z ( x ) = y ( x ) + y ( x ) sin x z ( x ) + x sin 2 x ,
with boundary conditions of the first kind
y ( 0 ) = 2 , y ( π ) = e π 1 , z ( 0 ) = 1 , z ( π ) = π 1 .
Because of the form of conditions (27), this problem cannot be solved by means of the RK4 method. It is possible to solve this problem by applying the Mathematica software, no matter the form of conditions (27). In this case, like in the previous examples, the useful analytical solution cannot be found, but there is no problem with obtaining the approximate solution.
In order to use the DTM method, we need to notice that we do not know the values of the first-order derivatives of functions y and z for x = 0 . Therefore, we assume temporarily that y ( 0 ) = α R and z ( 0 ) = β R . Hence, and from the half of conditions (27), we obtain
Y 0 = 2 , Y 1 = α , Z 0 = 1 , Z 1 = β .
If we assume that functions Y k and Z k are the images of functions y ( x ) and z ( x ) , respectively, then from Equation (27), on the basis of properties (3), (4), (6)–(9), we receive the following relations for k = 0 , 1 , 2 , :
( k + 1 ) ( k + 2 ) Y k + 2 = ( k + 1 ) Z k + 1 + ( 1 ) k + 2 k sin k π 2 k ! + + i = 0 k Y i + ( 1 ) i + 1 i ! ( k + 1 i ) Z k + 1 i δ ( k i 0 ) , ( k + 1 ) ( k + 2 ) Z k + 2 = i = 0 k sin ( k i ) π 2 ( k i ) ! ( i + 1 ) Y i + 1 + Y i + + δ ( k 1 ) 2 k sin k π 2 k ! .
Assuming that we determine five successive components from the above relations, that is, by taking 0 k 4 , we obtain
—for k = 0 :
Y 2 = β , Z 2 = 1 2 ,
— for k = 1 :
Y 3 = 1 6 ( α β α + β 2 ) , Z 3 = 1 6 ( α β + 1 ) ,
— for k = 2 :
Y 4 = 1 24 2 β 2 5 β + 2 , Z 4 = 1 24 ( 2 α + 4 β + 1 ) ,
— for k = 3 :
Y 5 = 1 120 3 α 2 + α β 2 5 α β + 11 α + β 2 3 β , Z 5 = 1 120 ( 3 α β 5 α + 10 β 1 ) ,
— for k = 4 :
Y 6 = 1 720 8 α 2 + 30 α β + 2 β 3 19 β 2 + 56 β , Z 6 = 1 720 4 α β 10 α + 8 β 2 28 β 1 .
Thus we have the approximate solution
y 6 ( x ) = i = 0 6 Y i x i , z 6 ( x ) = i = 0 6 Z i x i ,
depending on the unknown parameters α and β . To determine their values we need to use the other half of the defined boundary conditions and solve the system of equations
y 6 ( π ) = e π 1 , z 6 ( π ) = π 1 .
It appears that three solutions of this systems exist:
α 1 = 45.2564 , α 2 = 3.68625 , α 3 = 0.0558998 , β 1 = 53.8154 , β 2 = 1.6918 , β 3 = 0.0109995 .
In order to select the best one from among these solutions, we construct three groups of the approximate solutions, y 6 , i , z 6 , i , and i = 1 , 2 , 3 , and we examine the errors of these solutions, Δ y 6 , i = | y 6 , i P y 6 , i | , Δ z 6 , i = | z 6 , i P z 6 , i | , for i = 1 , 2 , 3 , where P means the right-hand sides of the system (26) of equations.
We can observe that the best solution is the one provided by the third pair of parameters. Figure 6 shows the exact solution and the approximate solution y 6 = y 6 , 3 , z 6 = y 6 , 3 received for the selected pair of parameters together with the errors of these approximations.
If we increase the number of the determined components and create in this way the approximate solution y 8 , z 8 , then we obtain the result displayed in Figure 7 (in this case, we have five groups of solutions and the best one is for α = 0.0028424 and β = 0.000929434 —chosen in the same way as described above).
Figure 6 and Figure 7 could be made on the basis of the known exact solutions, which are the functions
y 1 ( x ) = e x + sin x + cos x and y 2 ( x ) = x + cos x sin x ,
whereas the parameters α and β then take the values α = β = 0 .

4.5. Example 5

As the last example in this section, let us consider the following differential equation
ln y ( x ) + y ( x ) + y ( x ) + 1 e x e x = ln ( e x ) ,
with condition
y ( 0 ) = 0 .
Equation (28) cannot be solved by using the RK method (this equation cannot be presented in the normal form). Mathematica software is also helpless in this case (even the approximate solution cannot be found).
The last hope is the DTM method. In order to apply the DTM method, let us assume that function Y k is the image of function y ( x ) . Then, from Equation (28), basing, among others, on properties (3) and (6)–(10), we obtain for k = 0 , 1 , 2 ,
— for k = 0 :
ln Y 1 = 1 Y 1 = e ,
— for k = 1 :
2 Y 2 Y 1 + ( 1 e + Y 0 + Y 1 ) = 1 e Y 2 = 1 2 ( 1 + e ) ,
— for k 2 :
1 Y 1 ( k + 1 ) Y k + 1 r = 0 k 2 r + 1 k ( k r ) U r + 1 Y k r + 1 e ( k 1 ) ! + r = 0 k ( r + 1 ) Y r + 1 + Y r · 0 , k = r , 1 ( k r 1 ) ! , k > r = 1 k e k .
Solving the equations, described by means of relation (30), for the successive values k 2 , we obtain the sought values Y k for k 3 :
Y 3 = 2 + e 6 , Y 4 = 3 + e 24 , Y 5 = 4 + e 120 , Y 6 = 5 + e 720 , Y 7 = 6 + e 5040 ,
On this ground, we can suppose that
Y k = ( 1 ) k + 1 k 1 + e k ! , k 1 .
Hence we are able to predict the solution of problem (28):
y ( x ) = Y 0 + k = 1 Y k x k = ( 1 e + x ) e x + e 1 .
The above function is in fact the exact solution of task (28), which can be easily verified.

5. Conclusions

In the paper, we have presented the comparison of three approaches used for solving ordinary differential equations of any order, as well as the systems of such equations. The main goal of this elaboration was to indicate and justify the advantages of the differential transformation method (DTM), which is less known and not often applied. For this purpose, we investigated this method on the background of two other popular methods: the Runge–Kutta method (we decided to use the Runge–Kutta method of order 4 to emphasize better the advantages of the DTM method) and the methods built in the Mathematica software (the discussed examples and the figures illustrating the obtained solutions were realized in version 12.2 of the Mathematica program). The choice of these methods was dictated by their popularity (considering especially the RK4 method) or their simplicity—Mathematica software offers the special routines dedicated for solving the differential equations and their systems, based on the implementation of selected methods and numerical treatment of differential equations. The offered routines are the obvious and default tools for Mathematica users. It is worth mentioning that one does not need to purchase the license for using Mathematica because the tools of this software are available freely on the web page https://www.wolframalpha.com (last access date: 18 December 2021).
The exemplary problems, presented in this paper, were not accidentally chosen. The examples describe the problems that are possible to solve by using all the three discussed approaches (Examples 1–3), impossible to solve by using the RK4 method (Example 4—because of the form of conditions; and Example 5—because of the implicit form of the equation) and impossible to solve with the aid of the Mathematica program (Example 5). Despite these problems, all the presented examples could be successfully solved by applying DTM method which shows universality of this method—this method can be used for various forms of initial conditions and for various forms of the solved equation, including the implicit forms. Moreover, the errors of approximate solutions, obtained in the DTM method, are comparable, or very often even lower, than the errors generated by the other methods. What is more and worth emphasizing, the DTM method often leads to the exact solution of the problem, if it exists.
The usefulness of the DTM method, shown in this paper, encourages undertaking a further study on some other applications of this method. At present, the authors are investigating the possibility of applying the discussed method for solving the differential–integral–algebraic equations and the integral equations with retarded argument. Many interesting and important problems are also described by means of the fractional differential equations (see for example [19,20]), possible to solve by applying the DTM method as well.

Author Contributions

Conceptualization, M.P.; methodology, E.H. and M.P.; software, M.P.; validation, E.H. and M.P.; formal analysis, E.H. and M.P.; investigation, E.H. and M.P.; data curation, M.P.; writing—original draft preparation, E.H.; writing—review and editing, E.H.; visualization, M.P.; supervision, E.H. and M.P.; project administration, E.H. and M.P. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Not applicable.

Conflicts of Interest

The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript; or in the decision to publish the results.

References

  1. Gautschi, W. Numerical Analysis, 2nd ed.; Springer Science & Business Media: Boston, MA, USA, 2012. [Google Scholar]
  2. Adomian, G. Solving Frontier Problems of Physics: The Decomposition Method; Kluwer: Dordrecht, The Netherlands, 1994. [Google Scholar]
  3. Hetmaniok, E.; Słota, D.; Wituła, R.; Zielonka, A. Comparison of the Adomian decomposition method and the variational iteration method in solving the moving boundary problem. Comput. Math. Appl. 2011, 61, 1931–1934. [Google Scholar] [CrossRef] [Green Version]
  4. Hetmaniok, E.; Nowak, I.; Słota, D.; Zielonka, A. Solution of the Inverse Heat Conduction Problem with Neumann Boundary Condition by Using the Homotopy Perturbation Method. Therm. Sci. 2013, 17, 643–650. [Google Scholar] [CrossRef]
  5. Zhou, J.K. Differential Transformation and Its Application for Electrical Circuits; Huarjung University Press: Wuhan, China, 1986. [Google Scholar]
  6. Arikoglu, A.; Özkol, I. Solution of boundary value problems for integrodifferential equations by using differential transform method. Appl. Math. Comput. 2005, 168, 1145–1158. [Google Scholar]
  7. Ayaz, F. On the Two-Dimensional Differential Transform Method. Appl. Math. Comput. 2003, 143, 361–374. [Google Scholar] [CrossRef]
  8. Mirzaee, F. Differential Transform Method for Solving Linear and Nonlinear Systems Ordinary Differential Equations. Appl. Math. Sci. 2011, 5, 3465–3472. [Google Scholar]
  9. Ayaz, F. Solutions of the System Partial Differential Equations by Differential Transform Method. Appl. Math. Comput. 2004, 147, 547–567. [Google Scholar]
  10. Kanth, R.; Aruna, K. Two-dimensional differential transform method for solving linear and non-linear Schrödinger equations. Chaos Solitons Fractals 2009, 41, 2277–2281. [Google Scholar] [CrossRef]
  11. Mukherjee, S.; Roy, B. Solution of Riccati Equation with Variable Co-efficient by Differential Transform Method. Int. J. Nonlinear Sci. 2012, 14, 251–256. [Google Scholar]
  12. Abdel-Halim Hassan, I.H.; Erturk, V.S. Applying Differential Transformation Method to the One-Dimensional Planar Bratu Problem. Int. J. Contemp. Math. Sci. 2007, 2, 1493–1504. [Google Scholar] [CrossRef]
  13. Celik, E.; Tabatabaei, K. Solving a Class of Volterra Integral Equation Systems by the Differential Transform Method. Int. J. Nonlinear Sci. 2013, 16, 87–91. [Google Scholar]
  14. Biazar, J.; Eslami, M.; Islam, M.R. Differential Transform Method for Special Systems of Integral Equations. J. King Saud Univ. Sci. 2012, 24, 211–214. [Google Scholar] [CrossRef] [Green Version]
  15. Allahviranloo, T.; Kiani, N.A.; Motamedi, N. Solving fuzzy differential equations by differential transformation method. Inf. Sci. 2009, 179, 956–966. [Google Scholar] [CrossRef]
  16. Liu, B.; Zhou, X.; Du, Q. Differential Transform Method for Some Delay Differential Equations. Appl. Math. 2015, 6, 585–593. [Google Scholar] [CrossRef] [Green Version]
  17. Arikoglu, A.; Özkol, I. Solution of fractional differential equations by using differential transform method. Chaos Solitons Fractals 2007, 34, 1473–1481. [Google Scholar] [CrossRef]
  18. Grzymkowski, R.; Pleszczyński, M. Application of the Taylor transformation to the systems of ordinary differential equations. In Information and Software Technologies 2018, ICIST; Damaševičius, R., Vasiljeviene, G., Eds.; Springer: Cham, Switzerland, 2018; Volume 920, pp. 379–387. [Google Scholar] [CrossRef]
  19. Jafari, H.; Ganji, R.M.; Nkomo, N.S.; Lv, Y.P. A numerical study of fractional order population dynamics model. Results Phys. 2021, 27, 104456. [Google Scholar] [CrossRef]
  20. Ganji, R.M.; Jafari, H.; Moshokoa, S.P.; Nkomo, N.S. A mathematical model and numerical solution for brain tumor derived using fractional operator. Results Phys. 2021, 28, 104671. [Google Scholar] [CrossRef]
Figure 1. Exact solution and the approximate solutions together with the error Δ of these approximations.
Figure 1. Exact solution and the approximate solutions together with the error Δ of these approximations.
Mathematics 10 00306 g001
Figure 2. Exact solution and the approximate solutions.
Figure 2. Exact solution and the approximate solutions.
Mathematics 10 00306 g002
Figure 3. Plot of error Δ of the approximate solutions.
Figure 3. Plot of error Δ of the approximate solutions.
Mathematics 10 00306 g003
Figure 4. Exact solution and the approximate solutions.
Figure 4. Exact solution and the approximate solutions.
Mathematics 10 00306 g004
Figure 5. Plot of error Δ of the approximate solutions.
Figure 5. Plot of error Δ of the approximate solutions.
Mathematics 10 00306 g005
Figure 6. Plots of the solutions of problem (26) and (27): exact ones y 1 and y 2 —solid lines, approximate ones y 1 , 6 and y 2 , 6 —dashed lines, together with the plots of absolute errors Δ .
Figure 6. Plots of the solutions of problem (26) and (27): exact ones y 1 and y 2 —solid lines, approximate ones y 1 , 6 and y 2 , 6 —dashed lines, together with the plots of absolute errors Δ .
Mathematics 10 00306 g006
Figure 7. Plots of the solutions of problem (26) and (27): exact ones y 1 and y 2 —solid lines, approximate ones y 1 , 8 and y 2 , 8 —dashed lines, together with the plots of absolute errors Δ .
Figure 7. Plots of the solutions of problem (26) and (27): exact ones y 1 and y 2 —solid lines, approximate ones y 1 , 8 and y 2 , 8 —dashed lines, together with the plots of absolute errors Δ .
Mathematics 10 00306 g007
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Hetmaniok, E.; Pleszczyński, M. Comparison of the Selected Methods Used for Solving the Ordinary Differential Equations and Their Systems. Mathematics 2022, 10, 306. https://doi.org/10.3390/math10030306

AMA Style

Hetmaniok E, Pleszczyński M. Comparison of the Selected Methods Used for Solving the Ordinary Differential Equations and Their Systems. Mathematics. 2022; 10(3):306. https://doi.org/10.3390/math10030306

Chicago/Turabian Style

Hetmaniok, Edyta, and Mariusz Pleszczyński. 2022. "Comparison of the Selected Methods Used for Solving the Ordinary Differential Equations and Their Systems" Mathematics 10, no. 3: 306. https://doi.org/10.3390/math10030306

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