Critical analysis for nonlinear oscillations by least square HPM

In this study, a novel adapted homotopy perturbation method (HPM) is used to treat the nonlinear phenomena of free vibration in a system with one degree of freedom. This adaptation involves the integration of HPM with a least-squares optimizer, resulting in a hybrid method called the least square homotopy perturbation method (LSHPM). The LSHPM is tested on various nonlinear problems documented in the existing literature. To evaluate the effectiveness of the proposed approach, the identified problems are also tackled using HPM and the MATLAB built-in function bvp5c, and then the results are compared with those obtained using LSHPM. In addition, a comparative analysis is carried out with the results of the AG method as found in the literature. The results show that LSHPM is a reliable and efficient method suitable for solving more complicated initial value problems in the fields of science and engineering.

www.nature.com/scientificreports/ a nonlinear oscillator.The investigation conducted by Mohammadian and colleagues 24 focused on examining the applicability of the AGM and its enhancement for nonlinear damped oscillators.In 2021, El-Dib 25 utilized the HPM technique in conjunction with a rank-upgrading approach to achieve superior results in nonlinear oscillation.
Oscillation systems, commonly encountered in various scientific and engineering disciplines, are frequently characterized and examined using mathematical models.These models serve as reliable instruments for predicting, understanding, and controlling the dynamic features of oscillatory processes.Researchers and engineers can find notable understandings into the complexities of oscillation systems by explaining physical principles into mathematical formulas.
Oscillation systems, distinguished by their rhythmic and repetitive motion, have a close connection with the language of differential equations.This association between oscillations and differential equations offers a robust framework for articulating and comprehending the dynamic characteristics of these systems across various scientific disciplines.
Differential equations serve as a modeling tool for problems involving diverse independent variables [26][27][28] .This area of study holds significance in mathematics, addressing intriguing issues related to the modeling of various phenomena in physics, biology [29][30][31] , and engineering 32,33 .For instance, phenomena like unsteady squeezing flow of heat and mass transfer 34 and MHD Boundary Layer Flow over a Stretching Sheet 26 find representation through differential equations, as the rate of change is a fundamental expression for describing physical phenomena in scientific investigations 35 .Diverse analytical and numerical methodologies are employed to gain valuable insights into system behavior, unraveling complexities inherent in the study.These approaches encompass the homotopy analysis method [36][37][38] , optimal homotopy asymptotic method [39][40][41] , Adomian decomposition method 42 , extended optimal homotopy asymptotic method 39 , the coupling of Runge-Kutta methods with the MATLAB neural network built-in function nftool 40,43 , the conjunction of the homotopy analysis method with the neural network MATLAB function nftool 40,44 , utilization of artificial neural networks 45 , the coupling of the MATLAB built-in function nftool with the homotopy asymptotic method 46 , and the combination of the Levenberg-Marquardt technique with the MATLAB neural network nftool 35,47 .
The HPM has been extensively examined since 1999, evolving into a valuable mathematical tool due to the collaborative efforts of numerous scientists.Researchers have validated the convergence of the ground breaking HPM across various scenarios 48 , and diverse modifications have surfaced in the scholarly literature.Upon using the phrase "modified homotopy perturbation method" as a search query in Clarivate Analytics' Web of Science, we identified over 400 relevant items.The combination of HPM with other methods has garnered significant attention, such as the Generalized Differential Quadrature Method 49 and the Fourier transform 50 .The LSHPM, a hybrid of the HPM and the least square method 51,52 .It is Remarkably effective for solving ordinary, partial, and fractional differential equations In 2012 GANJI1 and AZIMI 22 applied the Max-Min Approach(MMA) and Amplitude Frequency Formulation (AFF) to derive the approximate analytical solution for motion of nonlinear free vibration of conservative, single degree of freedom systems.The results were compared with the results obtained by forth-order runge-kutta method.In 2022 Sanadi et al. 16 used the Akbari Ganji Method, abbreviated as AGM, and the HPM, to analytically investigate some oscillating systems with nonlinear behavior in a variety of situations and compare the results to the numerical approach to assess the validity and accuracy of these methods.The findings in all situations showed the precision of both the AGM and HPM, with all computations showing an amazing similarity to the RK4 method.In this manuscript, we use the newly developed LSHPM and MATLAB builtin functiobn bvp5c to unfold the problem 22 .This method combines HPM with a least squares minimization step, which minimizes approximation errors and speeds up convergence, therefore increasing the method's effectiveness.Compared to other iterative techniques, it provides accurate solutions with fewer iterations.LSHPM is a priceless instrument in a variety of scientific and technical fields due to its many advantages, which include simplicity in using, accuracy, and computational efficacy.

Methodology
We use the newly developed LSHPM and the bvp5c function integrated in MATLAB to solve the problem.

LSHPM
To understand the main idea about the LSHPM, let's examine the following nonlinear differential equation with the boundary conditions Equation (1) can be expressed in the following format: A denotes a differential operator of general type, B represents a boundary operator, g is a well-defined analytic function and Ŵ denotes the boundary surrounding the domain .We have further divided A into its linear and nonlinear summands, L and N, respectively.Consequently, we can reformulate the Eq.(1) as follows (1) In the Eq. ( 3), our objective is to solve it using the HPM.To achieve this, we establish a homotopy function H : R n × [0, 1] −→ R m , for Eq. ( 3), and this homotopic function H satisfies the convex homotopic property as given below Here, p represents an embedding parameter, while v 0 is an initial approximation of Eq. (1), satisfying the bound- ary conditions (2).Notably, from Eq. ( 4), it is evident that and The progression of the parameter p from 0 to 1 corresponds to the transformation of H(v, p) from v 0 to v. The function H, parametrized by p, establishes a continuous trajectory from the known initial solution v 0 to the desired solution v.This function is identified as a homotopy linking the functions are recognized as homotopic.The symbol R denotes the set of real values.As the parameter p varies within the interval [0, 1], v 0 progressively converges toward the solution v.It is reasonable to posit that the solution to this equation can be represented as a series involving powers of p, as discussed in references 53 .
Taking p → 1 , estimated result that HPM will produce is After introducing the unknown constants c ′ s into the derived series solution ũ given by Eq. ( 8) as coefficients of v ′ s in order to control the convergence, we designate this new series as Ũ = ∞ i=0 c i v i .Subsequently, we substitute the approximate solution Ũ in place of the unknown function v in Eq. ( 3) to construct the residual function.

We now determine the residual sum of squares
The optimal values for the unknown constants c i are established by solving the system of equations ∂J ∂c i = 0 .Afterward, by substituting these determined values of c i back into Ũ , we achieve the desired solution through the application of the Least Square Homotopy Perturbation Method (LSHPM) approach.

bvp5c
The bvp5c code utilizes a finite difference implementation based on the four-stage Lobatto IIIa formula, as described in 54 .This formula, employing collocation, produces a C 1 continuous solution with fifth-order accuracy consistently over the interval [a, b], where a, b ∈ ℜ .The implementation adopts the Lobatto IIIa formula as an implicit Runge-Kutta formula.The MATLAB built-in function bvp5c is specifically crafted to directly solve the associated algebraic equations, ensuring a smooth and efficient solution process. (4)

Oscillating systems
Case 1.In Fig. 1, we assign m 1 as the mass of the horizontal block, and m 2 represents the mass of the vertically displaced block connected to m 1 .The symbol L denotes the length, g stands for the acceleration due to gravity, and k represents the spring constant, as illustrated in Fig. 1.Introducing an additional parameter, denoted as v, defined as v = x L , with the condition that |v| << 1 .With this definition, the differential equation can be expressed in the following manner, as detailed in references 16,22 : In this context, v, v , and v represent the dimensionless displacement, velocity, and acceleration, respectively, of the vibrating system.The initial displacement and velocity are specified as follows: In the presented model, it is apparent that the restoring force of the springs follows a linear pattern.However, the introduction of damping introduces nonlinearity, leading to a mathematical model that deviates from linearity.
Case 2. Figure 2 depicts a simple pendulum with a rod connected to a rotating rigid frame.The rigid frame experiences continuous rotation at an angular velocity represented by around the vertical axis, giving rise to the formulation of the ensuing nonlinear differential equation. 16,22, where, = r 2 g , the variables θ and t are dimensionless and represent displacement and time, respectively.In the context of the Eq. ( 13), the expression −� cos θ sin θ is a result of the movement of the rotating rigid frame.Consider and Substituting ( 15) and ( 16) into (13), we have Given that both problems ( 11) and ( 17) can be viewed as highly nonlinear in nature.We will apply the HPM, LSHPM and the MATLAB built in function bvp5c to solve these problems.

Implementation of LSHPM
Now, we proceed to address problems ( 11) and ( 17) with the help of examples by varying the parameter values.
(  11) as (11) as As previously noted, the initial step in addressing equation ( 18) using the HPM method involves introducing a constant p as the perturbation factor, which is then integrated into Eq.( 18).This results in the formulation of the resultant homotopy equation: Upon substituting Eq. ( 7) into Eq.( 20) and conducting simplifications and rearrangements that are contingent on the powers of p, we can derive the corresponding parameters . . .

By solving
Eqs. ( 21)-( 23) with appropriate initial conditions, we can ascertain the parameters associated with v i for i = 0, 1, 2, . . . .It is noteworthy that, except for Eq. ( 21), the remaining equations are addressed with a zero initial condition.Upon resolving Eqs. ( 21) through (23), we can determine the values for v 0 , v 1 , and v 2 .Through the synthesis of the solutions to Eqs. ( 21) through (23), we obtain the approximate solution for Eq. ( 18) using the HPM in the following manner.
The optimal values for the variables c i , with i ranging from 1 to 5, can be obtained by calculating the partial derivatives ∂J ∂c i using MAPLE 2016 software.Once these optimal values are determined, they can be substituted into the proposed solution as outlined in Eq. ( 25):

Discussion of results of Example 4.1
The numerical results for both the HPM ( 22) and the LSHPM ( 28) are summarized in Table 1, and graphical representations of the HPM solution (22) and the LSHPM solution (28) are presented in Fig. 3.
A comprehensive examination of the results in Table 1 unequivocally demonstrates the superior performance of the LSHPM over AGM 16 .The LSHPM consistently delivers uniform results throughout the entire domain.In stark contrast, the HPM and AGM methods exhibit diminishing convergence as one moves away from the initial point, as illustrated by the data at x = 2.7 and x = 3 in Table 1.
The numerical solution of the problem represented by Eqs. ( 18) and ( 19) was carried out using MATLAB's bvp5c function, as detailed in references 55 .The computed maximum error was found to be on the order of 9.779 × 10 −11 .
Analysis of the results presented in Table 1 clearly indicates the superior performance of the LSHPM over the AGM 16 .LSHPM consistently delivers uniform results throughout the entire domain, in stark contrast to the HPM and AGM, which exhibits diminishing convergence as one moves away from the initial point, as illustrated by the data at x = 2.7 and x = 3 in Table 1.Initially, we formulate a homotopy for Eq. ( 31) as follows 33) and performing some simplification and rear- rangement based on the powers of p, we have the following system of differential equations . . .

Discussion of results of Example 4.2
The numerical solution for the problem described by Eqs. ( 31) and ( 32) was carried out using MATLAB's bvp5c functionality, with reference to 56 .The calculated maximum error was determined to be approximately 2.203 × 10 −14 .A comprehensive assessment of the outcomes outlined in Table 2 unmistakably demonstrates the superior performance of the LSHPM over AGM 16 and the Homotopy Perturbation Method (HPM).LSHPM consistently yields uniform results across the entire domain, in stark contrast to AGM and HPM, which display diminishing convergence as one moves away from the initial point, as evident in the data from x = 1.2 to x = 3 in Table 2.

Analysis of results
It is worth noting that we utilized software, specifically MAPLE 2016, to solve Example 4.1 and Example 4.2.The computational time for these examples was remarkably efficient, taking only 10 seconds for the former and 3166 seconds for the latter.In Eqs. ( 29) and (41), we employed Riemann sums with 250 partitions to approximate the integrals.

Validation
We have validated the three methods, HPM, LSHPM, and the numerical method using MATLAB's builtin function bvp5c for both Examples as illustrated in Table 1 and Table 2.As shown in these tables, it is clear that HPM and LSHPM work better and are more accurate than AGM 16 in this investigation.In "Analysis of results" section, we provide a detailed description of the initial conditions for both scenarios.As this study primarily aims to assess the influence of individual parameters on the system's response, we employ LSHPM with a variety of initial conditions to examine the results.Next, we delve into the analysis of Case 1.The results presented for case 1: • For Fig. 5, we take K = 100Newton/meter 2 , g = 9.8 meter/sec 2 , m 1 = 5 Kg m 2 = 1 Kg , L = 1 meter , A = [ π 24 , π 12 , π 8 , π 6 , π 3 ]meter .Figure 5 reveal that changes in amplitude have no discernible impact on the www.nature.com/scientificreports/period or frequency; nonetheless, they exert a significant influence on the system's behavior.In oscillatory systems, the count and regularity of oscillations are fundamental attributes.It is feasible to scrutinize the motion of the system and ascertain the quantity of oscillations occurring within a defined time frame through the resolution of the equations of motion.• For Fig. 6, we take the values as: K = [50, 100, 300]Newton/meter 2 , g = 9.8 meter/sec 2 , m 1 = 5 Kg m 2 = 1 Kg , L = 1 meter , A = π 6 , π 3 ]meter .Figure 6 depicts that as the stiffness increases, there is a noticeable decrease in the duration of the oscillation's period.Specifically, when the stiffness value is elevated from 50 to 300, In upcoming endeavors, our approach will involve the utilization of LSHPM alongside the MATLAB built-in function bvp5c for the resolution of diverse mathematical models that encompass nonlinear ordinary, partial, and fractional differential equations.

Conclusion
In our investigation, we utilized three different approaches-MATLAB's built-in function bvp5c, HPM, and LSHPM-to explore two distinct oscillating systems, comparing their results against numerical solutions.The comparative error analysis for both cases, as presented in Tables 1 and 2, highlights the effectiveness of these methods in dealing with oscillating systems.Notably, LSHPM demonstrated superior convergence rates and higher accuracy when compared to AGM and HPM, as clearly indicated in Tables 1 and 2. The adaptability of these methods was demonstrated by modifying individual parameters, such as stiffness or length, showcasing LSHPM's ability to deliver highly accurate results closely aligned with numerical values.Furthermore, the exploration of various parameters revealed that stiffness significantly influenced the system's period time, while mass and length had inverse effects.Importantly, variations in length were observed to have a relatively milder impact on the system's temporal response and frequency when compared to changes in stiffness and mass.

Data availibility
All data generated or analyzed during this study are included in this published article.

Figure 6 .Figure 7 .
Figure 6.Case 1. Graph for LSHPM solutions with different values of K.

Figure 8 .
Figure 8. Case 1. Graph for LSHPM solutions with different values of l.