1. Introduction
Ordinary differential equations are classified into initial value problems (IVP) and boundary value problems (BVP) based on the form of the given conditions. For example,
and
where
stands for
.
Among them, IVP and BVP differ in that the conditions for IVP (initial conditions) are set at the same location, while the conditions for BVP (boundary conditions) are set at two different locations. Many practical problems are described using differential equations, but only a few types can be solved analytically. The numerical methods for solving IVP and BVP in ordinary differential equations have significant differences and require entirely different approaches.
For clarity, let us first consider the simplest initial value problem.
Euler’s Method is one of the simplest approaches for solving ordinary differential equations and serves as an excellent example to illustrate the principles of numerical methods [
1]. We first consider a first-order ordinary differential equation of the form (3) and divide the interval
into
equally spaced subintervals. Therefore,
and
where
is called the step size. Let
and
. According to the mean value theorem for integration, we obtain
and
This method is known as Euler’s Method. The significance of using Euler’s Method, as represented by (6), is that it enables calculating
. We use the function value
at the previous point and add the product of the slope
at the previous point and the step size
. This method leads to a gradual accumulation of integration errors and less accurate computation. The Runge–Kutta method improves upon the shortcomings of Euler’s Method, enhancing the accuracy of the calculation [
1,
2,
3].
2. Research Method
The fundamental idea of the Runge–Kutta method is to calculate
using (3). Appropriate corrections must be made in advance when the approximate expression of
in (3) is obtained. Specific points in the interval
must be considered, and their values
multiplied by their corresponding weightings must be calculated to evaluate
This is the Runge–Kutta method, and its general representation is written as
where
is number of points in the interval
and
are the weightings which are undetermined parameters corresponding to
which are the
specific values of function f.
can be written as
and
where
and
are also undetermined parameters. These parameters can be derived by expanding Taylor’s Series and comparing the coefficients. By selecting different parameter values for
and
, we obtain various forms of the Runge–Kutta method’s calculation formulas. In particular, RK4 is the most widely used [
1,
2,
3]. The equations are as follows.
Since calculating each step in the iteration requires evaluating four values of
from (3), it is referred to as RK4. RK4 allows for a numerical accuracy that reaches the fourth order (i.e., the error begins from the fifth order). As for higher-order methods, such as for second-order ordinary differential equation
to solve using RK4, let
and then (16) is rewritten as a system of first-order ordinary differential equations as follows.
and
Thus, the procedure for solving the system of first-order ordinary differential (17a) and (17b) using RK4 is as follows,
The authors implemented the RK4 computation procedure using a Fortran program for analysis.
3. Results and Discussion
A one-degree-of-freedom spring-mass-damper system [
2,
3,
4] is considered to have a nonlinear spring, as shown in
Figure 1. Based on Newton’s second law of motion, the equation of motion for this spring-mass-damper system is expressed as
where
The differential Equation (19) does not have an analytical solution. To obtain a numerical solution
using RK4, we can rewrite (19) in terms of (17a) and (17b) as follows.
and
where
and
represent the displacement
and velocity
of the mass m, respectively.
By taking an appropriate step size and treating and in (17a) and (17b) as and in (20a) and (20b), respectively, and treating in (17b) as in (20b). Thus, the procedure for solving the coupled first-order ordinary differential (20a) and (20b) using RK4 is identical to that of (18a) to (18j).
To obtain the numerical solution for the displacement time response function
of mass m in
Figure 1, the interval from 0 to 1.0 s is divided into
equally spaced subintervals with a step size of
. The values of
are taken as 100, 200, 400, 800, 1600, and 3200, and monitoring points are chosen at times t = 0.1, 0.2,…,1.0 s. The results are listed in
Table 1, and the numerical solution of the displacement
at
= 3200 is illustrated in
Figure 2.
Figure 2 shows that the system exhibits damping, with the displacement time response function of mass m gradually decreasing over time, which is reasonable. Although there is no analytical solution for the displacement time response function of mass m in this system, the comparison of data from the ten monitoring points for
N equal to 400 and 800, respectively, reveals that the first five significant figures are identical, indicating a high level of accuracy in the calculations. Additionally, comparing the data from ten monitoring points for
N equal to 800 and 1600 also shows that the first six significant figures are completely the same. This indicates that the RK4 calculation results do not suffer from significant truncation or propagation error despite the increase in the number of subdivisions.
4. Conclusions
When analyzing data using a Fortran program, it is essential to declare all data types, except for integers, as double precision. This allows for numerical accuracy of up to 15 or 16 significant digits in decimal form, which reduces truncation errors, especially when the step size
is very small. This is evident from the numerical values of the transient displacement time response function of the mass analyzed using RK4 in
Table 1, which shows that as the number of subdivisions increases, the calculated values change only slightly. In particular, when the number of subdivisions is increased to 3200, the corresponding numerical solutions at 3200 and 1600 subdivisions are almost identical for the first six significant figures. Therefore, the computed values do not exhibit significant propagation errors despite a large number of subdivisions.
Additionally, a comparison of (18a) to (18j) with (11) to (15) indicates that the increase in the order of the differential equations merely results in the repeated listing of (11) to (15). This demonstrates that obtaining numerical solutions for higher-order ordinary differential equations or higher-order systems of ordinary differential equations using the Runge–Kutta method is straightforward and effective.