An Elementary Solution to a Duffing Equation

In this work, we study the Duffing equation. Analytical solution for undamped and unforced case is provided for any given arbitrary initial conditions. An approximate analytical solution is given for the damped or trigonometrically forced Duffing equation for arbitrary initial conditions. The analytical solutions are expressed in terms of elementary trigonometric functions as well as in terms of the Jacobian elliptic functions. Examples are added to illustrate the obtained results. We also introduce new functions for approximating the Jacobian and Weierstrass elliptic functions in terms of the trigonometric functions sine and cosine. Results are high accurate.


Introduction
Many physical phenomena are modeled by nonlinear systems of ordinary differential equations. e Duffing equation is an externally forced and damped oscillator equation that exhibits a range of interesting dynamic behavior in its solutions. e Duffing oscillator is an important model of nonlinear and chaotic dynamics. It was introduced by Germanic engineer Duffing in 1918 [1]. e Duffing oscillator is described by the differential equation: It differs from the classical forced and damped harmonic oscillator only by the nonlinear term βx 3 , which changes the dynamics of the system drastically. Motivated by potential applications in physics, engineering, biology, and communication theory, the damped Duffing equation is considered. Equation (2) is a ubiquitous model arising in many branches of physics and engineering, such as the study of oscillations of a rigid pendulum undergoing with moderately large amplitude motion [2,3], vibrations of a buckled beam, and so on [3][4][5].
It has provided a useful paradigm for studying nonlinear oscillations and chaotic dynamical systems, dating back to the development of approximate analytical methods based on perturbative ideas [2], and continuing with the advent of fast numerical integration by the computer, to be used as an archetypal illustration of chaos [2,[5][6][7]. Various methods for studying the damped Duffing equation and the forced Duffing equation (1) in feedback control, strange attractor, stability, periodic solutions, and numerical simulations have been proposed, and a vast number of profound results have been established [2]. e Duffing equation has been studied extensively in the literature. However, only few works are devoted to the study of its analytical solutions not using perturbation methods [8,9]. Our aim is to avoid using such perturbation methods.
is study is organized as follows. In the first section, we give exact analytical solution for the undamped and unforced Duffing equation for any given arbitrary initial conditions. In the second section, we provide formulas for obtaining a good approximate analytical solution using a new ansatz. e problems are solved for any arbitrary initial conditions. Finally, in the last section, we give approximate analytical solution to (1) and we compare it with Runge-Kutta numerical solution. Other useful methods are the homotopy perturbation method (HPM) [10][11][12][13][14][15][16][17], the Lindstedt-Poincaré method, and the Krylov-Bogoliubov-Mitropolsky method. e importance of numerical solution of differential equations in different fields of science and engineering is given in [18,19].

Undamped and Unforced Duffing Equation
is is the equation: and given the initial conditions, e general solution to equation (3) may be written in terms of any of the twelve Jacobian elliptic functions [20]. Let, for example, en, Equating to zero, the coefficients of cn j to zero gives an algebraic system whose solution is us, the general solution to the Duffing equation is e values for the constants c 1 and c 2 are determined from the initial conditions. Definition 1.
We will distinguish three cases depending on the sign of the discriminant [20].

First Case
e solution to the i.v.p. (3) and (4) is given by Making use of the addition formula, e solution (9) may be expressed as where Solution (11) is a periodic solution with period Example 1. Let us consider the i.v.p.
2 e Scientific World Journal Using formula (9), the exact solution to (14) is given by According to the relations (11) and (12), the exact solution to the i.v.p. (14) may also be written as e period is given by In Figure 1, the comparison between the exact analytical solution (??) and the approximate numerical RK4 solution is presented. Full compatibility between the two analytical and numerical solutions is observed.

Second Case
Observe that Let where y � y(t) is a solution to Duffing equation with initial conditions Inserting ansatz (21) into the ode x ′′ (t) + px(t) + qx 3 (t) � 0 and taking into account the relation, we get e Scientific World Journal Equating to zero, the coefficients of y j (t) give an algebraic system. A solution to this system is Observe that the Duffing equations (21) and (22) have a positive discriminant given by en, the problem reduces to the first case.
Example 2. Let us assume the following i.v.p.: Comparison between the exact solution and numerical solution is shown in Figure 2. 2.3. ird Case: Δ � 0 and p ≠ 0. If the discriminant vanishes (Δ � 0), then q < 0, and the only solution to problem (??) with which may be verified by direct computation.

Fourth
Case: Δ � 0 and p � 0. e solution is given by Remark 1. e solution to the i.v.p.
is  e Scientific World Journal Remark 3. Using the identity the solution to the Duffing equations (3) and (4) may be written in terms of the Weierstrass elliptic function ℘. More precisely, if Δ > 0, then where e solution (38) is periodic with period  e Scientific World Journal where ρ is the greatest real root to the cubic 4x 3 − g 2 x − g 3 � 0 and On the other hand, where m is a root to the sextic

Approximate Analytical Solution Using Elementary Functions
We define the generalized sine and cosine functions as follows: ese functions are good approximations to the Jacobian elliptic functions sn and cn for − 1 ≤ m ≤ 1/2. For example, let en, For these new approximations, we will have We may write approximate elementary solution to Duffing equations (3) and (4) as follows:  (46) and (47). where e values for the constants in (62) are the same as in (??).
In the case when 0.9 < m ≤ 1.1, we may use the following approximations: Example 3. Let us return to Example 1. x e exact period is given by T � 4.37417. e approximate period is that of (59), and it is given by is value differs from the exact value by 0.00278457. e error of the approximate solution comparted with exact solution is Comparison between the exact solution and the approximate analytical solution is shown in Figure 3.
where m is a root to the sextic (44).

Analytical Solution to a Generalized Duffing Equation
Let us consider the i.v.p. [21]: given that We will say that (75) is a constantly forced Duffing equation. When F � 0, that becomes an undamped and unforced Duffing equation, and we already know how to solve it for arbitrary initial conditions. Let where λ, μ, w, g 2 , g 3 , and t 0 are some constants to be determined. Plugging ansatz (77) into (75) gives where ℘ � ℘(ρ t + t 0 ; g 2 , g 3 ). Equating to zero, the coefficients of ℘ j (j � 0, 1, 2, 3) in the right-hand side of (78) gives an algebraic system. A nontrivial solution to this system is Now, to find the values of t 0 and λ, we make use of the addition formula: We then find that e number λ must be a solution to the quartic Using (75), we also may obtain an approximate analytical solution in terms of the cosine function.
given the initial conditions is a particular case of (75) and (76). Indeed, let x(t) � u(t) − (q/3r). en, problems (83) and (84) reduce to the problem Comparison between the approximate analytical solution and the numerical solution is shown in Figure 6.

Damped and Unforced Duffing Equation
Let us consider the i.v.p.
given that We will suppose that lim t⟶∞ u(t) � 0. Define the residual as (95) en, from results in [22], being e numbers b 1 , b 2 , and ρ are obtained from the following conditions: Solving the two equations in (88) gives 12 e Scientific World Journal e number ρ is a root to the septic R ′ (0) � 0. To avoid solving this, the seventh-degree equation, we may set the default value ρ � ε. Taking this value for ρ, we get the following simplified expressions: Remark 7. In the integrable case, we have ρ � 2ε/3 and then α � 8/9ε 2 From (99) and (100), μ � 0 and m � 1/2. us, our approach covers the only integrable case for the damped Duffing equation.
e error of the approximate analytical solution compared with numerical solution is max 0≤t≤20 u app (t) − u Ruinge− Kutta (t) � 0.00141579. (106) Comparison between the approximate analytical solution and the numerical solution is shown in Figure 7. e Scientific World Journal 13 e error of the approximate analytical solution compared with numerical solution is Comparison between the approximate analytical solution and the numerical solution is shown in Figure 8.
is given by where f(t) and m(t) are given by (98) and (99).

Second Case
Assuming the ansatz [22], we will have en, 14 e Scientific World Journal e number λ is found form the initial condition u ′ (0) � _ u 0 , and its value reads e number ρ is a solution to some decic equation. Default value is ρ � ε.
e error of the approximate analytical solution compared with numerical solution is Comparison between the approximate analytical solution and the numerical solution is shown in Figure 9.

Damped and Forced Duffing Equation
Let us consider the Duffing equation as originally was introduced by Georg Duffing: given the initial conditions Let We will suppose that the function u � u(t) is a solution to the Duffing equation where e numbers c 1 and c 2 are chosen, so that Comparison between the approximate analytical solution and the numerical solution is shown in Figure 10.
Finally, let us compare the accuracy of the obtained results in comparation with the homotopy perturbation method (HPM).

Analysis and Discussion
We have solved the undamped and constantly forced Duffing equation exactly. Trigonometric approximant was also provided. For the damped or forced case, we derived approximate analytical solution. As far as we know, the Duffing equation (1) has not been solved using the tools we employed in this work. For the damped unforced case, author in [8] obtained approximate analytical solution using generalized Jacobian elliptic functions. More exactly, author considered the following equation: e obtained solution in [8] has the form where 16 e Scientific World Journal e constants c 0 and c 1 are determined from the initial conditions as follows: is approach is different from the method we used in this work. Let us compare the solution (136) with the solution we obtained in Example 8: Using formula gives the approximate analytical solution e error of this solution compared with the Runge-Kutta numerical method equals 0.00142148. e error obtained in our method equals 0.00135922. We may try a simpler ansatz in the form with e numbers c 0 and ρ are determined from the system − 8αβ + 8αρ + 16β 2 ρ − 24βρ 2 + 6βc 2 0 ε − 9c 2 0 ερ + 8ρ 3 � 0, − 4αc 2 0 + 8βc 2 0 ρ + 3βc 4 0 ε − 4c 2 0 ρ 2 − 3c 2 0 εx 2 0 + 4αx 2 0 + 8βρx 2 0 + 8ρ 2 Using this ansatz, we obtain the approximate analytical solution:  e error of the trigonometric solution (146) compared with the numerical solution using the Runge-Kutta method equals 0.00195254, so that the trigonometric solution is good as well.

Conclusions and Future Work
e methods employed here may be useful to study other nonlinear oscillators of the form where the function f is odd: f(− x) � − f(x). To this end, we approximate this function on some interval [− A, A] by means of Chebyshev polynomials in the form en, the i.v.p. is replaced with the i.v.p.
e number ρ is a free parameter that is chosen in order to minimize the residual error

Data Availability
No data were used to support this study.

Conflicts of Interest
e authors declare that they have no conflicts of interest.