1 Introduction

Ordinary differential equations (ODEs) arise in many problems related to physics and engineering (particularly complex problems arising from vibrations and dynamic systems). Generally, numerical, analytical, and approximate methods are used to solve complex linear and nonlinear ODEs [15]. Exact solutions to these equations play an essential role in adequately understanding qualitative features of many phenomena and processes. However, even if a solution exists, only for a few special ODEs, it is possible to determine this exact solution in closed form by analytical methods. It means that there is not a general analytical approach to evaluate analytical solutions [20]. Therefore, numerical and approximate solutions are used. In most numerical methods, the rule of solution function is not specified, but a numerical sequence (data pairs) of approximate values is produced. Methods such as Euler, RK4, Adams-Bashforth, Etc. are in this category [4]. One of the strongest and most practical approximation methods for solving nonlinear ODEs is perturbation-based methods [25]. These methods are used to solve ODEs arising from vibrations and dynamics. Since these ODEs are abundantly observed in various branches of science and have also recently been focused on solving them, they can be used to evaluate the effectiveness of new methods. Methods such as Homotopy Perturbation Method (HPM) [13, 16, 19], Optimal Homotopy asymptotic method (OHAM) [35, 38], Variational Iteration Method (VIM) [17], Energy Balance Method (EBM) [10, 18, 26], Differential transform method (DTM) [41], Najjar-Ismail perturbation technique (NIPT) [12], are in perturbation-based category. Each method is used for a specific type of ODEs; the mentioned studies have shown that they offer an acceptable approximation of the ODE’s solution. On the other hand, with the impressive advent of the virtual world and the expansion of powerful processors, mathematicians are trying to use these hardware technologies and artificial intelligence (especially evolutionary algorithms) as automated computing systems to manage complex and time-consuming problems. A process of mathematical modeling with evolutionary algorithms involves the model generation, interpretation of numerical results, and development and control of numerical algorithms by computers. These activities are not entirely independent, and researchers must provide some preliminaries as inputs. Also, they are not purely user-centric. Genetic Programming (GP) is widely regarded as one of the most useful evolutionary algorithms. It is a branch of artificial intelligence research that involves the evolution of computer codes, with the term "evolution" referring to Darwin’s concept of natural evolution [2, 7]. Despite the fact that there is a vast amount of literature on both GP and numerical methods for solving ODEs, the majority of research uses both techniques separately [43]. Additionally, studies have demonstrated that GP can solve some ODEs when combined with automatic differentiation and least mean square [21, 36]. However, no combination of a numerical method with GP has been reported to solve ODEs. Numerical methods have a strong mathematical foundation, whereas GP has characteristics like educability, processing power, and relative independence from the user. Thus, the fundamental objective of this study is to introduce a new hybrid method (GPN) and determine the potential of evolutionary algorithms constructed by combining GP and a numerical method for getting a good approximation of analytical solutions to ODEs such that GPN can compete with existing powerful methods in terms of flexibility and accuracy. GPN does not depend on the numerical method used for the combination. It requires a numerical method that produces very accurate input data. The RK4 technique is a more often used numerical method for solving ODEs than other similar methods [5]. RK4 is quite flexible. Recent studies have demonstrated that it is capable of generating high-precision data pairs from the solutions of complicated differential equations, including chaotic equations, delayed equations, fractional order equations, stochastic equations, and nonlinear equations [3, 6, 27, 49, 52]. Therefore, we use the RK4 method for combination operations and develop algorithms to solve various problems caused by vibrations and dynamic systems problems using the Matlab programming environment. Among these efforts, we emphasize [10, 12, 18, 26, 37, 45] which provided a benchmark for comparing our algorithms’ performance. In general, our findings are positive because we could obtain a good approximation of exact solutions to the problems, indicating that the proposed method could be a viable alternative for solving ODEs. In the following sections, we establish the methodology, and structure of GPN, error function and accuracy of GPN, test problems (the method’s good performance through various practical examples), discussion and conclusion respectively.

2 Methodology and structure of GPN

This section discusses the methodology used to construct the GPN algorithm to solve ODEs. GPN has the following overview structure: A set of models (individuals) is produced using a random combination of mathematical equations and relations, consisting of operators, mathematical functions, random numbers, and design variables as an initial population. Each individual in the population is assessed using a fit criterion established by the type of problem and given a fitness index depending on how well it fits into the desired aim or objectives. A new population of models is generated using GP operators (selection, crossover, mutation, reproduction and alteration operators) [24, 51]. The next generation is created based on more appropriate with higher quality models. Individuals with better quality have an increased possibility of being picked as the parents to produce offspring. This process is continued until a specified number of generations is reached or the objective is achieved. In the last generation, a genetic algorithm-based procedure [9] among the created models delivers an optimal solution in terms of the number of nodes and the fit criterion which enters the error analysis step. The details of GPN are discussed below. GPN is designed in the Matlab programming environment and uses two parallel algorithms: The first is in charge of GP, whereas the latter is in charge of producing RK4 data pairs \((x_i, y_i)\). RK4 has three primary roles. First, a duplicate of all the data is used to examine the approximate behavior of the solution function, leading to an initial guess for determining the set of GP functions and terminals. Second, 90% of data pairs are selected randomly and used to train models across all generations. Third, 10% of the data pairs are utilized to validate the final model. The testing data pairs determine the precision of the final model’s match with RK4 data pairs that did not participate in the generations training process. GP is recognized by its tree structure, where each tree is a combination of some leafs (nodes) and branches, and these nodes involve some functions and terminals [30, 33]. For example, if \(F=\{\times , \div , +, -,sin,cos\}\) and \(T=\{x_1, x_2, 1\}\) one simple arithmetic expression can be generated as \(cos(x_1\times x_2)+ (x_1 - x_2)\). Equivalently, Fig. 1 displays this type of tree structure. Generally, based on the problem quiddity, these functions (F) and terminals (T) should be selected. By considering the special problem, a function set may be a set of arithmetic operations, boolean operations, or mathematical functions. The terminal set could be constant values or design variables. Additionally, if the problem is an ODE, then RK4 is an appropriate algorithm for determining the function and terminal set. The fundamental principle of GPN is that an initial population (trees) is generated randomly from a set of initial solutions to an ODE problem. Due to the vast search space, the effectiveness of GPN is heavily dependent on the diversity and structure of the initial population. The ODE’s solution function’s linear, nonlinear, oscillating, and exponential states can be determined by conceptually examining the ODE structure [36] and analyzing the behavior of RK4 data pairs (in graph state). This is a good way to guess the initial population’s base set (functions, mathematical operators, number of variables, and terminals) and determine the initial GP configurations. This process starts with a set of base elements and adds or changes them, and it is repeated until the desired result is achieved.

Fig. 1
figure 1

Tree of the equation \(cos(x_1\times x_2)+ (x_1 - x_2)\)

After determining the training and testing data, it is necessary to create the initial population. In the implementation of GP, the user can control the program execution process by changing various parameters. John Koza et al. have classified population size and the number of generations as main parameters and others as secondary parameters [32]. As a general rule, the population size should be as large as possible in order for the computer system to do computations effectively and in a reasonable amount of time [32]. This parameter’s minimum value is 1000 [51]. In addition, the optional range for the number of generations is between 10 and 150. Also, the maximum depth of trees is usually considered to be 8 [32, 51]. Koza proposed three methods for creating the initial population. The full method, the grow method, and the ramped half-and-half (RHH) combines the aforementioned methods. RHH results in a more uniform and diverse range of tree sizes and shapes. RHH generates half of the starting population using the full procedure and the other half via the growth method [30, 33]. RHH is usually used to improve the diversity of the initial population (structural diversity) [51]. Jackson proposes modifying the RHH algorithm in which structural or behavioral duplicates are removed from the population to promote population diversity [23]. Furthermore, due to the reduction of computing costs, this process is only suggested for use in the first generation [22, 42]. Therefore, by using the modified RHH method only in the first generation (MRHH), it has been tried to achieve maximum population diversity by removing duplicate individuals. On the other hand, it has been demonstrated that recombination operators (using sub-tree crossover) have no significant effect on regression problems during the remainder of the evolutionary process (from the second generation onward) [23]. For more effectiveness, a real-value alternation operator is used in this study, which adds new structures to the population by slightly perturbing the terminals, leading to an increase in semantic diversity [24]. The performance of this operator will be described in detail in the rest of this section. Following the initial population’s creation, it is the RK4 reliable input–output data’s time to play a critical part in training them. A regression multi-fit program (RMF) is a user-friendly, adaptable nonlinear regression application that can fit data to various functions [48]. Using the RK4 training data pairs, the RMF assigns each member of the initial population a numeric value called the fitness criteria. Those who are more data-compatible or trainable are tested and coded. After establishing the initial population and analyzing the equivalent fitness values, the initial population is subjected to evolutionary processes (by GP operators) such as selection, reproduction, crossover (sexual recombination), mutation, and alteration. This process continues for a specific number of generations. As with other evolutionary algorithms, operators are applied to units in GP that are selected based on probability and fitness. The tournament selection is the most often used selection method [40]. The tournament determines which unit is superior to the other without specifying how much. Hence, the chances of being elected remain constant for the entire population automatically and effectively. One of the tournament’s significant advantages is that units that behave inappropriately in initial generations are not immediately removed since they may represent proper attributes in future generations where this pattern is derived from nature [29, 30]. To choose individuals for genetic operations, tournament selection is employed with a max size of seven [31]. After the selection stage, other genetic operations are applied to the selected individuals. The crossover operation used in GP introduces variety into the population by generating new offspring composed of components from both parents. The crossover process begins with two parental expressions and terminates with the generation of two offspring expressions. The operation starts by selecting a random point within each parent as the parent’s crossover point. After that, the crossover operator swaps the copies of two sub-trees rooted at these points, resulting in the formation of two new individuals, and they will be put into the new population. Copies are used to preserve the original trees. Repeating this process can lead to multiple offspring [24, 30]. The mutation operation introduces random changes in structures in the population. Mutation can be beneficial in reintroducing diversity in a population that may be tending to converge prematurely. Mutation begins by selecting a point at random within the tree. This mutation point can be an internal (i.e., function) point or an external (i.e., terminal) point of the tree. The mutation operation then removes whatever is currently at the selected position and below the selected point. It uses the grow method to insert a randomly-generated sub-tree at that point. This operation is controlled by a parameter that determines the newly generated sub-tree’s maximum size (measured by depth). This parameter also controls the crossover operator. The reproduction operator creates offspring by directly copying the selected individuals into the next generation. The selection procedure will be used to select an individual, who will then be directly copied into the new population. This operator ensures that the best individuals are not lost when new populations are generated [31]. Moreover, we apply a real-value alteration operator to promote local ability by randomly (using normal distribution) changing the values of real numbers (terminals) in tree structures. This operator could be considered a special case of the mutation operation, as it inserts a single terminal at a randomly selected terminal point of the tree. Similarly, this could be a special case of the crossover operation as exchanging two randomly selected sub-trees, which here are two selected terminals. This operator changes the selected terminals according to the Eq.(1) where numpop is the number of the initial population, \(T_{s,i}\) and \(T_{e,i}\) are selected and exchange terminals (\(1\le i\le numpop\)), \(\kappa \in\) span[0, 1], and \(UB_r ,\, LB_r\) are upper and lower bounds of the interval in which the new terminal value is going to be produced, and rand[0,1] is a random number selected from normal distribution in the range 0–1 [24].

$$\begin{aligned} \begin{aligned}&T_{e,i}=(1-\kappa )\times \vartheta +\kappa \times T_{s,i},\\&\quad \vartheta =rand[0,1]\times (UB_r - LB_r)+LB_r \end{aligned} \end{aligned}$$
(1)

The objective of these GP operators is to generate a new population by passing on valuable materials from the parent population. Crossover, mutation, reproduction, and alternation operators are used at rates of 85%, 10%, 4%, and 1%, respectively [51]. When a termination criterion is met (last generation), the NSGA-II optimization algorithm (by using a non-dominated sorting procedure) [9] determines the optimal model in terms of the expressional complexity and the fit criterion, where the sum of the complexities of the tree structure and all its subtrees is the complexity metric, and the complexity is defined as the number of nodes (branch points plus leaves) [44]. This form of metric has the advantage of placing simpler solutions on the Pareto front when two different genotypes lead to the expression of the same phenotype. The obtained model enters the evaluation and error analysis step. The proposed GPN’s schematic design is depicted in Fig. 2.

Fig. 2
figure 2

Diagram of the proposed method

Now assume that the ODE with the used initial conditions is as follows:

$$\begin{aligned} \begin{aligned} u^{(n)}=f(t,u,u',u'',...,{u^{(n - 1)}}),\,\,\,\,\ t \in \left[ {a,b} \right] \\ u(a) = {\alpha _0},\,u'(a) = {\alpha _1},...,\,{u^{(n - 1)}}(a) = {\alpha _{n - 1}} \end{aligned} \end{aligned}$$
(2)

A mathematical model \(u_{_{GPN}}\left( t \right)\) is determined for Eq.(2) as an appropriate approximation of the solution function \(y=u(t)\) by using GPN, where \(u(t)\approx u_{_{GPN}}\left( t \right)\). Regarding the GPN mechanism, \(u_{_{GPN}}\left( t \right)\) is the output of the "apply NSGA-II & set optimal model" block; therefore, it undergoes testing and error analysis. \(u_{_{GPN}}\left( t \right)\) is tested by RK4 testing data pairs and replaced in the ODE. The \(\lambda (t)\) function and other criteria outlined in the next section determine the model’s accuracy. The mathematical model that can provide the best precision for ODE is considered an appropriate approximation of the solution function u(t). Since GPN is a stochastic method, its average behavior must be considered (experiments should be run at least ten times independently). The number of the initial population and the depth of the trees (\(d\_t\)) are two key parameters in controlling the computational times and the simplicity of the output models. we consider \(numpop=5000\) and \(max(d\_t)=6\). In Section 4, GPN will be tested on different ODEs.

3 Error function and accuracy

Two criteria \(\phi\), and \(\xi\) represent the model’s accuracy in initial conditions, and the model’s total accuracy in Eq. (2), respectively. The continuous function of \(\lambda _{_{GPN}}(t)\) indicates the error function. \(\lambda _{_{GPN}}(t)\) is obtained by inserting the model and its derivatives into Eq. (2) at all continuous points along the interval in which the ODE is defined. Further, The accuracy of predicting or fitting the obtained model (\(u_{_{GPN}}\left( t \right)\)) with RK4 testing data pairs is assessed using (\(T_{error}\)) and Pearson’s correlation coefficient (PCC) [47]. These criteria are defined to assess the accuracy of the model obtained by GPN as an appropriate approximation of the solution function of Eq. (2).

$$\begin{aligned} \lambda _{_{GPN}}(t)= & {} {u_{_{GPN}}^{\left( n \right) }} - f(t,u_{_{GPN}}',u_{_{GPN}}'',...,{u_{_{GPN}}^{(n - 1)}}) \end{aligned}$$
(3)
$$\begin{aligned} \phi= & {} \frac{{\mathop \sum \nolimits _{k = 0}^{n - 1} \left| {{u_{_{GPN}}^{(k)}}\left( a \right) - {\alpha _k}} \right| }}{{n - 1}} \end{aligned}$$
(4)
$$\begin{aligned} \xi= & {} \int _a^b {\left| {\lambda _{_{GPN}}(t)} \right| } \;dt \end{aligned}$$
(5)
$$\begin{aligned} {T}_{error}= & {} \frac{1}{N}\sum \limits _{i = 1}^N {{{\left( {{y_i} - {{\hat{y}}_i}} \right) }^2}} \end{aligned}$$
(6)

Where, N, \(y_i\) and \(\hat{y}_i\) are the number of RK4 testing data pairs, the value of RK4 testing data in time \(t_i\) and the value of \(u_{_{GPN}}\left( t \right)\) in time \(t_i\) respectively. If PCC \(\rightarrow 1\), \(\lambda _{_{GPN}}(t)\cong zero function\), and other criteria are small enough, then \(u_{_{GPN}}\left( t \right)\) can be considered a reasonable approximation to the exact solution of Eq. (2).

4 Test problems

In this section, the GPN is implemented for five selected Problems of ODEs arising in physics and engineering. According to [10, 12, 18, 26, 37, 45], to achieve the desired result, problems 2–5 can only be solved in a specific method; in other words, a unique approximation method can not solve all the expressed problems. Problem 1 contains a linear ODE whose exact solution can be calculated by an analytical method. Problems 2–5 involve complex nonlinear ODEs with approximate solutions derived from the aforementioned semi-analytical methods. Since these methods rely heavily on pure mathematics, it typically takes months (or years) to discover a formula that can solve a particular set of ODEs. Therefore, these methods cannot be compared to algorithmic methods such as GPN in execution time. However, the flexibility (in terms of functions used in the model structure and the number of them) and, more importantly, the accuracy of the obtained models are significant and comparable. GPN performance is acceptable when it achieves an approximation similar to or better than the results obtained by existing powerful methods.

4.1 Problem 1

The following equation is applied to analyze the vibration of a single-degree-of-freedom system [45, 50]:

$$\begin{aligned} \begin{aligned} mu'' + bu' + ku = 0\,\,\,\,\,,\,\,u\left( 0 \right) = A\,\,,\,\,\,u'(0) = B \end{aligned} \end{aligned}$$
(7)

General solution of the problem 1: For \(m=4\), \(b=16\), \(k=16\) and \(A=1, B=0\) the general solution of Eq. (7) is obtained by Eq.(8) [45].

$$\begin{aligned} \begin{aligned} u_{_{GS}}\left( t \right) = {e^{ - 2t}} + 2t {e^{ - 2t}} \end{aligned} \end{aligned}$$
(8)

Solving the problem 1 by the GPN method: The configuration and parameters used in GPN are summarized in Table 1. Here, RK4 with time steps \(h=0.001\) in the distance of \([0\,, 10]\) is considered to train and test in GPN and the mathematical model derived from GPN and its accuracy are shown by Eq. (9) and in Fig. 3.

$$\begin{aligned} \begin{aligned} u_{_{GPN}}\left( t \right) = { {e^{ - 2t}} + 2 t{e^{ - 2t}} +4.28\times {10^{-15}}\simeq {e^{ - 2t}} + 2 t{e^{ - 2t}}} \end{aligned} \end{aligned}$$
(9)
Table 1 GPN configuration and Parameters for problems

The accuracy criteria of GPN and the comparison between GPN and other methods are demonstrated in Tables 23 respectively.

Fig. 3
figure 3

The results and accuracy of methods in Problem 1

4.2 Problem 2

The motion of a particle on a rotating parabola is governed by the following equation:

$$\begin{aligned} \begin{aligned} \left( {1 + 4{q^2}{u^2}} \right) \frac{{{d^2}u}}{{d{t^2}}} + \Lambda u + 4q{\left( {\frac{{du}}{{dt}}} \right) ^2}u = 0 \end{aligned} \end{aligned}$$
(10)

with the conditions \(u\left( 0 \right) = A\;,\,u'\left( 0 \right) = 0\) where q and \(\Lambda\) are known constants and need not to be small [39]. For q=1, \(\Lambda = 1\) and A=1 the results of the OHAM and GPN method are shown below.

Solving the problem 2 by the OHAM: The approximate solution of Eq. (10) is obtained using the OHAM method [38] by Eq. (11).

$$\begin{aligned} \begin{aligned} u_{_{OHAM}}\left( t \right) =&\,1.08140204\cos \Omega t - 0.100837908\cos 3\Omega t + 0.025163334\cos 5\Omega t \\&- 0.008262879\cos 7\Omega t + 0.006681164\cos 9\Omega t - 0.004145751\cos 11\Omega t \end{aligned} \end{aligned}$$
(11)

where \(\Omega =0.596087918\).

Solving the problem 2 by the GPN method: The configuration and parameters used in GPN are summarized in Table 1. Here, RK4 with time steps \(h=0.001\) in the distance of \([0\,, 10]\) is considered to train and test in GPN. The mathematical model derived from GPN and its accuracy are shown by Eq. (12) and in Fig. 4.

$$\begin{aligned} \begin{aligned} u_{_{GPN}}\left( t \right) =&\,0.009481\sin \left( 9.641\psi \right) -0.003499\sin \left( 7.856\sin \left( \cos \left( 0.6039t\right) \right) \right) -\\&17.65\sin \left( \psi \right) +12.65\sin \left( \sin \left( \psi \right) \right) -0.1475\sin \left( \sin \left( \sin \left( \cos \left( 0.6068t\right) \right) \right) \right) \\&+6.739\psi +7.828\times 10^{-6}. \,\,\,\, where: \psi = \sin \left( \cos \left( 0.5971t\right) \right) \end{aligned} \end{aligned}$$
(12)
Fig. 4
figure 4

The results and accuracy of methods in Problem 2

4.3 Problem 3

A Duffing equation can describe various nonlinear physical phenomena such as a system consisting of the pendulum and nonlinear stiffness, Snap-through mechanism, nonlinear isolator, large deflection of a beam with nonlinear stiffness, nonlinear cable vibrations and nonlinear electrical circuit [28]. A Duffing oscillator with nonlinearity of fifth-order in the case of forced term is considered as in the following equation:

$$\begin{aligned} \begin{aligned} u'' + u + \varepsilon {u^5} = p\cos \Omega t,\;\,u\left( 0 \right) = A,\;\,u'\left( 0 \right) = 0,\,\,\,0<\epsilon <\infty \end{aligned} \end{aligned}$$
(13)

where \(\epsilon\) indicates the nonlinear arbitrary constants in the restoring force, which is not required to be very small in the present study. In addition, \(\Omega\) is the angular frequency of the periodic driving force and p represents the amplitude of the external periodic force. hereafter, Eq. (13) is referred to briefly as the Duffing equation [12]. For \(\epsilon =100\), \(P=1\), \(\Omega =5\), \(\beta =1.00137\) and \(A=0.01\) the results of the NIPT and GPN method are shown below.

Solving the problem 3 by the NIPT: The approximate solution of Eq. (13) is obtained using NIPT by Eq. (14)

$$\begin{aligned} \begin{aligned} u_{_{NIPT}}\left( t \right) ={u_0} + \alpha {u_1} \end{aligned} \end{aligned}$$
(14)

Where \(\alpha\), \({u_0}\), \({u_1}\) and other parameters are determined by Naggar and Ismail by Eqs. (15)–(20) in [12].

$$\begin{aligned} \alpha= & {} \frac{\varepsilon }{{1 + \varepsilon }} \end{aligned}$$
(15)
$$\begin{aligned} {u_0}= & {} m\cos \beta t + n\cos \Omega t \end{aligned}$$
(16)

Where \(\beta\) is the angular frequency, which is unknown to be future determined by Eq. (20).

$$\begin{aligned}{} & {} {u_1} = \frac{{\left( {8\eta n + 5{n^5} + 30{m^2}{n^3} + 15{m^4}n} \right) }}{{8\left( {{\beta ^2} - {\Omega ^2}} \right) }}\left( {\cos \beta t - \cos \Omega t} \right) - \frac{{\left( {5{m^5} + 20{m^3}{n^2}} \right) }}{{128{\beta ^2}}} \nonumber \\{} & {} \quad \left( {\cos \beta t - \cos 3\beta t} \right) + \frac{{\left( {5{n^5} + 20{m^2}{n^3}} \right) }}{{16\left( {{\beta ^2} - 9{\Omega ^2}} \right) }}\left( {\cos \beta t - \cos 3\Omega t} \right) - \frac{{{m^4}}}{{384{\beta ^2}}} \nonumber \\{} & {} \quad \left( {\cos \beta t - \cos 5\beta t} \right) + \frac{{{n^5}}}{{16\left( {{\beta ^2} - 25{\Omega ^2}} \right) }}\left( {\cos \beta t - \cos 5\Omega t} \right) + \nonumber \\{} & {} \quad \frac{{5{m^5}n}}{{16\left[ {{\beta ^2} - \left( {4\beta + {\Omega ^2}} \right) } \right] }}\left( {\cos \beta t - \cos \left( {4\beta + \Omega } \right) t} \right) + \frac{{20{m^4}n}}{{16\left[ {{\beta ^2} - {{\left( {2\beta + \Omega } \right) }^2}} \right] }} \nonumber \\{} & {} \quad \left( {\cos \beta t - \cos \left( {2\beta + \Omega } \right) t} \right) + \frac{{20{m^4}n}}{{16\left[ {{\beta ^2} - {{\left( {2\beta + \Omega } \right) }^2}} \right] }}\left( {\cos \beta t - \cos \left( {2\beta - \Omega } \right) t} \right) + \nonumber \\{} & {} \quad \frac{{5{m^4}n}}{{16\left[ {{\beta ^2} - {{\left( {4\beta - \Omega } \right) }^2}} \right] }}\left( {\cos \beta t - \cos \left( {4\beta - \Omega } \right) t} \right) + \frac{{5{m^3}{n^2}}}{{8\left[ {{\beta ^2} - {{\left( {5m3\beta + 2\Omega } \right) }^2}} \right] }} \nonumber \\{} & {} \quad \left( {\cos \beta t - \cos \left( {3\beta + 2\Omega } \right) t} \right) + \frac{{15{m^3}{n^2}}}{{8\left[ {{\beta ^2} - {{\left( {\beta + 2\Omega } \right) }^2}} \right] }}\left( {\cos \beta t - \cos \left( {\beta + 2\Omega } \right) t} \right) + \nonumber \\{} & {} \quad \frac{{15{m^3}{n^2}}}{{8\left[ {{\beta ^2} - {{\left( {\beta - 2\Omega } \right) }^2}} \right] }}\left( {\cos \beta t - \cos \left( {\beta - 2\Omega } \right) t} \right) + \frac{{5{m^3}{n^2}}}{{8\left[ {{\beta ^2} - {{\left( {3\beta - 2\Omega } \right) }^2}} \right] }} \nonumber \\{} & {} \quad \left( {\cos \beta t - \cos \left( {3\beta - 2\Omega } \right) t} \right) + \frac{{5{m^2}{n^3}}}{{8\left[ {{\beta ^2} - {{\left( {2\beta + 3\Omega } \right) }^2}} \right] }}\left( {\cos \beta t - \cos \left( {2\beta + 3\Omega } \right) t} \right) + \nonumber \\{} & {} \quad \frac{{15{m^2}{n^3}}}{{8\left[ {{\beta ^2} - {{\left( {2\beta + \Omega } \right) }^2}} \right] }}\left( {\cos \beta t - \cos \left( {2\beta + \Omega } \right) t} \right) + \frac{{15{m^2}{n^3}}}{{8\left[ {{\beta ^2} - {{\left( {2\beta - \Omega } \right) }^2}} \right] }} \nonumber \\{} & {} \quad \left( {\cos \beta t - \cos \left( {2\beta - \Omega } \right) t} \right) + \frac{{5{m^2}{n^3}}}{{8\left[ {{\beta ^2} - {{\left( {2\beta - \Omega } \right) }^2}} \right] }}\left( {\cos \beta t - \cos \left( {2\beta - 3\Omega } \right) t} \right) + \nonumber \\{} & {} \quad \frac{{5m{n^4}}}{{16\left[ {{\beta ^2} - {{\left( {\beta + 4\Omega } \right) }^2}} \right] }}\left( {\cos \beta t - \cos \left( {\beta + 4\Omega } \right) t} \right) + \frac{{20m{n^4}}}{{16\left[ {{\beta ^2} - {{\left( {\beta + 2\Omega } \right) }^2}} \right] }} \nonumber \\{} & {} \quad \left( {\cos \beta t - \cos \left( {\beta + 2\Omega } \right) t} \right) + \frac{{20m{n^4}}}{{16\left[ {{\beta ^2} - {{\left( {\beta - 2\Omega } \right) }^2}} \right] }}\left( {\cos \beta t - \cos \left( {\beta - 2\Omega } \right) t} \right) + \nonumber \\{} & {} \quad \frac{{5m{n^4}}}{{16\left[ {{\beta ^2} - {{\left( {\beta - 4\Omega } \right) }^2}} \right] }}\left( {\cos \beta t - \cos \left( {\beta - 4\Omega } \right) t} \right) . \end{aligned}$$
(17)
$$\begin{aligned}{} & {} m = \frac{p}{{{\beta ^2} - {\Omega ^2}}},\,\,n = A - \frac{p}{{{\beta ^2} - {\Omega ^2}}},\,\,\alpha = \frac{\varepsilon }{{1 + \varepsilon }}\, \end{aligned}$$
(18)
$$\begin{aligned}{} & {} \eta = - \left( {\frac{5}{8}{m^4} + \frac{{30}}{8}{m^2}{n^2} + \frac{{15}}{8}{n^4}} \right) \end{aligned}$$
(19)
$$\begin{aligned}{} & {} {\beta ^2} + \varepsilon \eta = 1,\,\varepsilon \eta < 1 \end{aligned}$$
(20)

Solving the problem 3 by the GPN method: The configuration and parameters used in GPN are summarized in Table 1. Here, RK4 with time steps \(h=0.0015\) in the distance of \([0\,, 15]\) is considered to train and test in GPN and the mathematical model derived from GPN and its accuracy are shown by Eq. (21) and in Fig. 5.

$$\begin{aligned} \begin{aligned} u_{_{GPN}}\left( t \right) =&\,0.156\sin \left( \cos \left( t\right) \right) -0.5212\sin \left( \sin \left( \cos \left( t\right) \right) \right) +0.157\sin ^{2}\left( 2t\right) \cos \left( t\right) +\\&0.299\cos \left( \sin \left( \cos \left( \cos \left( t\right) \right) \right) \right) \cos \left( t\right) -6.63\times 10^{-5}t\sin \left( t\right) -5.79\times 10^{-8} \\&t\cos \left( t\right) \left( t+\sin \left( 2t\right) \right) +5.59\times 10^{-9} \end{aligned} \end{aligned}$$
(21)
Fig. 5
figure 5

The results and accuracy of methods in Problem 3

4.4 Problem 4

The Van der Pol oscillator is an example of self-oscillatory systems. Recently, it has been proposed as fundamental tools for control and reduction of friction [37, 46]. The Van der Pol oscillator for every nonnegative value of the parameter \(\epsilon\) is described by the following equation:

$$\begin{aligned} \begin{aligned} u'' + \varepsilon \left( {{u^2} - 1} \right) u' + u = 0\,\,\,\,\,,\,\,u\left( 0 \right) = A\,\,,\,\,\,u'(0) = 0 \end{aligned} \end{aligned}$$
(22)

For \(\epsilon =0.1\), and \(A=1\) the results of the VIM and GPN method are shown below.

Solving the problem 4 by the VIM: The approximate solution of Eq. (22) is obtained using VIM by Eq. (23) [26].

$$\begin{aligned} \begin{aligned} u_{_{VIM}}\left( t \right) =&\, \cos \left( t \right) + \varepsilon \left( {\frac{3}{8}t\cos \left( t \right) - \frac{1}{8}\sin t{{\cos }^2}t - \frac{1}{4}\sin t} \right) + {\varepsilon ^2}\left( {\frac{{ - 11}}{{256}}t\sin t}\right) +\\&{\varepsilon ^2}\left( \frac{3}{{128}}{t^2}\cos t-\frac{5}{{192}}{{\cos }^5}t -\frac{{83}}{{768}}{{\cos }^3}t - \frac{9}{{64}}t\sin t{{\cos }^2}t + \frac{{103}}{{768}}\cos t \right) \end{aligned} \end{aligned}$$
(23)

Solving the problem 4 by the GPN method: The configuration and parameters used in GPN are summarized in Table 1. Here, RK4 with time steps \(h=0.001\) in the distance of \([0\,, 15]\) is considered to train and test in GPN and the mathematical model derived from GPN and its accuracy are shown by Eq. (24) and in Fig. 6.

$$\begin{aligned} \begin{aligned} u_{_{GPN}}\left( t \right) =&\, 7.64\times {10^{-5}}t-0.3321\sin \left( \sin \left( t\right) \right) -0.001457\sin \left( 3t\right) +0.9936\cos \left( t\right) -\\&\frac{8.365\times {10^{15}}t}{2.306\times {10^{18}}t+1.582\times {10^{19}}}+9.16\times {10^{-4}}\sin \left( \cos \left( t\right) \right) \left( 2t+6.86\right) -\\&8.8\times {10^{-6}}t^{3}\sin \left( \sin \left( t\right) \right) +0.0369t\cos \left( t\right) -6.98\times {10^{-7}}t^{4}\cos \left( t+6.86\right) -\\&0.00203t\cos ^{2}\left( t\right) \sin \left( t\right) +0.00121 \end{aligned} \end{aligned}$$
(24)
Fig. 6
figure 6

The results and accuracy of methods in Problem 4

4.5 Problem 5

This problem is aimed to investigate the dynamic response of a rocking rigid rod over a circular surface, considering a pure rolling, without slipping. The governing equation on the mentioned system is given below [11].

$$\begin{aligned} \begin{aligned} u'' + Mu''{u^2} + Nu{\left( {u'} \right) ^2} + \alpha u - W{u^3} = 0 \end{aligned} \end{aligned}$$
(25)

with the initial conditions \(u\left( 0 \right) = A\;,\,u'\left( 0 \right) = 0\) where \(M=N=\frac{{12{r^2}}}{{{l^2}}}\), \(W = \frac{{6\,g{r^2}}}{{{l^2}}}\) and \(\alpha = \frac{{12gr}}{{{l^2}}}\) and r, l, g are known constants. For l=1, \(\frac{r}{l} = \frac{{\sqrt{6} }}{6}\) and A=0.1 the results of the EBM and GPN method are shown below.

Solving the problem 5 by the EBM: The approximate solution of Eq. (25) is obtained using the EBM [10, 18] by Eq. (26).

$$\begin{aligned} \begin{aligned} u_{_{EBM}}\left( t \right) = A\cos \left( {\frac{1}{2}\frac{{\sqrt{ - \left( {1 + {A^2}} \right) \left( { - 4\alpha + 3W{A^2}} \right) } }}{{1 + {A^2}}}\,\,\,t} \right) \end{aligned} \end{aligned}$$
(26)

Solving the problem 5 by the GPN method: The configuration and parameters used in GPN are summarized in Table 1. Here, RK4 with time steps \(h=0.0001\) in the distance of \([0\,, 2.3]\) is considered to train and test in GPN. The mathematical model derived from GPN and its accuracy are shown by Eq. (27) and in Fig. 7.

$$\begin{aligned} \begin{aligned} u_{_{GPN}}\left( t \right) =&\, 0.01552\cos \left( {6.854t} \right) - 6.46 \times {10^{ -6}}\cos \left( 20.57 t\right) - 8.05 \times {10^{ -7}} \\&\sin \left( \cos \left( 7.033 t\right) \right) + 0.08449\cos \left( {6.856t} \right) - 1.129 \times {10^{ -10}} \end{aligned} \end{aligned}$$
(27)
Fig. 7
figure 7

The results and accuracy of methods in Problem 5

Table 2 Accuracy criteria of GPN for each problem
Table 3 Comparison of \(\xi\) criterion between GPN and other methods

5 Discussion and conclusion

In this study, GP and its combination with the RK4 method have been employed to propose a new GPN method for solving linear and complicated nonlinear ODEs in physics and engineering. Since GPN is a stochastic method, the optimal determination of the initial parameters (especially the set of functions and terminals) significantly impacts its performance and maintains the structural diversity of the initial population. Two factors are considered to determine the set of functions and terminals in the GPN method. First, the study of the physical structure of the ODE and, more importantly, second, the behavior of RK4 data pairs. The graph obtained from Rk4 data pairs has helped to make an initial guess about the type of functions and terminals used in the structure of the ODEs solution. The graph of the RK4 data pairs in problem 1 (Fig. 3-a) clearly shows that the structure of the approximate solution consists of an exponential function, and in problems 2–5 (Figs. 4-a, 5-a, 6-a, and 7-a), there is a periodic and trigonometric structure. Additionally, the terminal set is determined based on the RK4 graph’s range. Other parameters, such as the number of generations, the size of the initial population, the depth of the trees, the method of selection (and its size), the rate of applying genetic operators, and the number of GPN executions, have been determined according to the criteria described in Sect. 3. After selecting the initial parameters, the MRHH method has been employed to create the initial population, improving the diversity. On the other hand, 90% of the Rk4 data pairs have been considered for the training population in all generations. Genetic operators admit models that have shown more compatibility with these data before the evolution process. In addition to the traditional GP operators, a real-valued alternation operator (described in Sect. 3) is added to the evolution process since the input problem of the GPN is an ODE, so the terminals (function coefficients) are sensitive. Sometimes, slight changes in the terminals can lead to an unexpected solution. That is, a model that does not have good compatibility with the training data in generation i may become a compatible solution in generation \(i+1\) just by changing some coefficients (terminals). After the completion of the evolutionary processes (the end of the final generation), the individuals (produced models) have been evaluated by the NSGA-II multi-objective optimization algorithm in terms of the expressional complexity (simplicity compared to other models) and fitness values. In multi-objective optimization problems, it is not possible to find points that simultaneously maximize (minimize) all objective functions; hence, non-dominated design points (Pareto points) have been presented as a candidate for the final solution (green points in Figs. 3-c-, 4-c, 5-c, 6-c, and 7-c). Each member of the set of Pareto points is superior to the other design points (at least from the perspective of an objective function). Among the Pareto points, the trade-off point of the objective functions (green point with a red border) has been selected, and its corresponding model has gone to the error analysis and testing step. The placement and arrangement of the all points in Figs. 3-c-, 4-c, 5-c, 6-c, and 7-c demonstrate the fitness (semantic) diversity. In other words, the strategy used in the GPN method has led to the production of models that tend to solve ODEs with an acceptable approximation. The method’s validity has been shown for five ODEs (one linear and four complex nonlinear equations). As mentioned in section 4, the amount of conformity of the model obtained with 10% of the RK4 testing data pairs for each problem has been measured by the \(T_{error}\) criterion and Pearson’s correlation coefficient. The first and second rows of Table 2 show that the final model of each problem is entirely compatible with these data, despite the fact that the RK4 testing data pairs were not included in the training of the models. Moreover, the third row of Table 2 (\(\phi\) criterion) shows the model’s behavior in the initial conditions of ODEs. For each of the five problems, two initial conditions are given. The calculated values have shown that the final models obtained by GPN are compatible with the initial conditions of the ODEs. Also, the \(\phi\) criterion can be considered a special case of the total accuracy of the model in initial conditions point(s). The total accuracy of the model (\(\xi\)) is a reliable criterion in evaluating the performance of methods for solving ODEs because it is obtained by putting the solution produced by the methods and its derivatives into the equation. The values of this criterion for GPN and other comparative methods are listed in Table 3. According to the theory of ODEs, the exact solution of an ODE is unique if it exists (problem 1). If the exact solution is unavailable (especially in nonlinear equations), approximate solutions can be produced with different methods (problems 2–5). Powerful methods produce solutions with sufficient accuracy and a different structure for a problem. The difference between the model errors can describe this structural difference. There is no difference in Fig. 1-d because GPN has converged to the exact solution. In addition, in Figure 6-d, this difference is more prominent in the interval \([6\,, 15]\), while in Figs. 4-d, 5-d, and 7-d, this difference is evident throughout the distance. It is possible to conclude that GPN has achieved an accuracy comparable to that of the powerful methods despite producing different structures compared to the existing solutions. The results show that GPN accuracy is equivalent to or better than existing methods in all cases. GPN can be developed in future work to solve other ODEs, such as chaotic, delayed, fractional order, stochastic, and partial equations. Also, mathematical and physical systems based on input–output data can be modeled and described by developing the idea implemented in the GPN method.