# Numerical Solution of Duffing Equation by Using an Improved Taylor Matrix Method

Authors: Berna Bülbül; Mehmet Sezer
Journal: Journal of Applied Mathematics
 (2013)

---

## Abstract

We have suggested a numerical approach, which is based on an improved Taylor matrix method, for solving Duffing differential equations. The method is based on the approximation by the truncated Taylor series about center zero. Duffing equation and conditions are transformed into the matrix equations, which corresponds to a system of nonlinear algebraic equations with the unknown coefficients, via collocation points. Combining these matrix equations and then solving the system yield the unknown coefficients of the solution function. Numerical examples are included to demonstrate the validity and the applicability of the technique. The results show the efficiency and the accuracy of the present work. Also, the method can be easily applied to engineering and science problems.


---

## Body

## 1. Introduction

Nonlinear ordinary differential equations are frequently used to model a wide class of problems in many areas of scientific fields: chemical reactions, spring-mass systems bending of beams, resistor-capacitor-inductance circuits, pendulums, the motion of a rotating mass around another body, and so forth [1, 2]. Also, nonlinear equations which can be modeled by the oscillator equations are of crucial importance in all areas of engineering sciences [3–7]. Thus, methods of solution for these equations are of great importance to engineers and scientists. Many new techniques have appeared in the open literature such as homotopy perturbation transform method [8], variational iteration method [9], energy balance method [10], Hamiltonian approach [11], coupled homotopy-variational formulation [12], variational approach [13], and amplitude-frequency formulation [14].In this paper, a new method is introduced for the following model of nonlinear problems:(1)y′′(x)+py′(x)+p1y(x)+p2y3(x)=f(x),
with the initial conditions
(2)y(0)=α,y′(0)=β,
where p,  p1, p2, α, and   β are real constants.Equation (1) has been discussed in many works [15–21], for different systems arising in various scientific fields such as physics, engineering, biology, and communication theory. Recently Wang [19] presented the quasi-two-step method for the nonlinear undamped Duffing equation. Donnagáin and Rasskazov [15] studied a modification of the Duffing equation describing a periodically driven iron pendulum in nonuniform magnetic field. Feng [16] illustrated a connection between the Duffing equation and Hirota equation and obtained two periodic wave solutions in terms of elliptic functions of the Hirota equation, by using the exact solution of Duffing equation. A direct method to find the exact solution to the damped Duffing equation and traveling wave solutions to the reaction-diffusion equation was used by Feng [17]. In addition, the solution of the Duffing equation in nonlinear vibration problem by using target function method was investigated by Chen [18]. The Laplace decomposition method for numerical solution of Duffing equation has been introduced by Yusufoğlu [20] and Khuri [21]. On the other hand, Duffing differential equations have also been effectively dealt in many works [22–29].The aim of this study is to get solution as truncated Taylor series centered about zero defined by(3)yN(x)=∑n=0Nynxn,yn=y(n)(0)n!,0≤x≤b
which is Taylor polynomial of degree N at x=0, where yn, n=0,1,...,N are unknown   Taylor coefficients to be determined.


## 2. Fundamental Relations

In this section we convert the expressions defined in (1) and (2) to the matrix forms by the following procedure. Firstly, the function y(x) defined by (3) can be written in the matrix form
(4)y(x)=X(x)Y,
where
(5)X(x)=[1xx2⋯xN],Y=[y0y1⋯yN]T.On the other hand, it is clearly seen that the relation between the matrixX(x) and its derivative X′(x) is
(6)X′(x)=X(x)B,
where
(7)B=[010⋯0002⋯0⋮⋮⋮⋱⋮000⋯N000⋯0].
From the matrix equations (4) and (6), it follows that
(8)y′(x)=X′(x)Y=X(x)BY,y′′(x)=X′(x)BY=X(x)B2Y,⋮y(k)(x)=X′(x)Bk-1Y=X(x)BkY,k=0,1,….
By using the production of two series, the matrix form of expression y2(x) is obtained as
(9)y2(x)=X~(x)Y~,
where
(10)X~(x)=[X~0(x)X~1(x)⋯X~N(x)]1×(N+1)2,X~i(x)=[xix0xix1⋯xixN]orX~i(x)=xiX(x),Y~=[Y~0Y~1⋯Y~N](N+1)2×1T,Y~i=[yiy0yiy1⋯yiyN]T,i=0,1,...,N.
Similarly, the matrix representation of y3(x) becomes
(11)y3(x)=X~~(x)Y~~,
where
(12)X~~=[X~~0(x)X~~1(x)⋯X~~N(x)]1×(N+1)3,X~~i(x)=xiX~(x),Y~~=[Y~~0Y~~1⋯Y~~N](N+1)3×1T,Y~~i=yiY~(x),Y~~=[Y~~0Y~~1⋯Y~~N](N+1)3×1T5155i=0,1,...,N.
Finally, by substituting the matrix forms (4)–(11) into (1) we have the fundamental matrix equation
(13)X(x)B2Y+pX(x)BY+p1X(x)Y+p2X~~(x)Y~~=f(x).


## 3. Method of the Solution

To obtain the Taylor polynomial solution of (1) in the form (3) we firstly compute the Taylor coefficients by means of the collocation points defined by
(14)xi=bNi,i=0,1,...,N.
By substituting the collocation points into matrix equation (13) we obtain the system of matrix equations
(15)X(xi)B2Y+pX(xi)BY+p1X(xi)Y+p2X~~(xi)Y~~=f(xi),X(xi)BY+p1X(xi)Y+p2X~~(xi)5Y~~=f(xi),i=0,1,...,N,
or compact notation
(16)XB2Y+pXBY+p1XY+p2X~~Y~~=F.
Briefly, we can write the matrix equation
(17)WY+VY~~=F,
which corresponds to a system of (N+1) nonlinear algebraic equations with the unknown Taylor coefficients yn, n=0,1,...,N. The matrices in (17) are as follows:
(18)W=[wi,j]=XB2+pXB+p1X,B2+pXB+2p1Xi,j=0,1,...,N,V=[vm,n]=p2X~~,m=0,1,...,N,n=0,1,...,((N+1)3-1),
where
(19)X=[X(x0)X(x1)⋮X(xN)],X~~=[X~~(x0)X~~(x1)⋮X~~(xN)],F=[f(x0)f(x1)⋮f(xN)].
The augmented matrix for  (17) becomes, clearly,(20)[W;V:F]=[w0,0w0,1⋯w0,N;v0,0v0,1⋯v0,(N+1)3-1;f(x0)w1,0w1,1⋯w1,N;v1,0v1,1⋯v1,(N+1)3-1;f(x0)⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮⋮wN,0wN,1⋯wN,N;vN,0vN,1⋯vN,(N+1)3-1;f(xN)].Next, by means of relations (4) and (8), we can obtain the corresponding matrix forms for the initial conditions (2) as
(21)X(0)Y=αor[10⋯0;00⋯0;α],X(0)BY=βor[01⋯0;00⋯0;β].Consequently, to obtain the solution of (1) under the conditions (2), by replacing the row matrices (21) by the last two rows of the augmented matrix (20), we have the required augmented matrix(22)[W~;V~:F~]=[w0,0w0,1⋯w0,N;v0,0v0,1⋯v0,(N+1)3-1:f(x0)w1,0w1,1⋯w1,N;v1,0v1,1⋯v1,(N+1)3-1:f(x0)⋮⋮⋮⋮⋮⋮⋮⋯⋮⋮⋮w(N-2),0w(N-2),1⋯w(N-2),N;v(N-2),0v(N-2),1⋯v(N-2),(N+1)3-1:f(xN-2)10⋯0;00⋯0:α01⋯0;00⋯0:β]or(23)W~Y+V~Y~~=F~.
By solving the matrix equation (22), the unknown Taylor coefficients yn are determined. Thus we get the Taylor polynomial solution
(24)yN(x)=∑n=0Nynxn.


## 4. Error Bound and Accuracy of the Solution

We can easily check the accuracy of the solutionyN(x) as follows. Since the Taylor polynomial (3) is an approximate solution of (1), then the solution yN(x) is substituted in (1), and the resulting equation must be satisfied approximately; that is, for x=xi∈[a,b], i=0,1,2,…,
(25)EN(xi)=|yN′′(xi)+pyN′(xi)+p1yN(xi)+p2yN3(xi)-f(xi)|≅0
or EN(xi)≤10-ki   (ki positive integer).If max(10ki)=10-k (k positive integer) is prescribed, then the truncation limit N is increased until the difference EN(xi) at each of the points becomes smaller than the prescribed 10-k. On the other hand, the error can be estimated by means of the function
(26)EN(x)=yN′′(x)+pyN′(x)+p1yN(x)+p2yN3(x)-f(x).
If EN(x)→0, when N is sufficiently large enough, then the error decreases.Also if we know the exact solution of problem, we can find error bound of method.Theorem 1 (Lagrange error bound).
Letf be function such that it and all of its derivatives are continuous, and  fn(x) is the nth Taylor polynomial for f(x) centered x=a; then the error is bounded by
(27)|f(x)-fn(x)|=|En(x)|≤M(n+1)!|x-a|n+1,
where   M=max|f(n+1)(ξ)|, ξ∈(a,x).IfyN is approximate solution of the matrix method and fN(x) is the Nth Taylor polynomial for f(x), we can write |fN-yN|=ε, and absolute error function of the method is |f-yN|=eN. To obtain error bound by Theorem 1 we have
(28)M(N+1)!|x-a|N+1≥|fN-f|=|fN-f+yN-yN|≥||fN-yN|-|f-yN||,M(N+1)!|x-a|N+1≥|ε-eN|⟹ε-M(N+1)!|x-a|N+1≤eN≤ε+M(N+1)!|x-a|N+1.
Therefore we can write
(29)eN≤maxx∈[a,b]ε+M(N+1)!|x-a|N+1,
which gives us error bound.


## 5. Numerical Examples

The method of this study is useful in finding the solutions of Duffing equations in terms of Taylor polynomials. We illustrate it by the following examples. Numerical computations have been done using Maple 9.Example 1.
Consider the Duffing equation in the following type [20]:
(30)y′′(x)+3y(x)-2y3(x)=cos(x)sin(2x),
with the initial conditions
(31)y(0)=0,y′(0)=1.We assume that the problem has a Taylor polynomial solution in the form(32)yN(x)=∑n=0Nynxn,whereN=5,8,and10.The solutions obtained forN=5,8,and10 are compared with the exact solution y(x)=sin(x)  [20] (see Table 1 and Figure 1). We calculate the following Lagrange error bound for different values of N, respectively, M5=0.161×10-2 which is 2 decimal places accuracy, M8=0.352×10-5 which is 5 decimal places accuracy, and M10=0.248×10-7 which is 7 decimal places accuracy.Table 1
Comparison of the absolute errors of Example1.
x
r
Exact
Error analysis (|y-yN|)
N
=
5
N
=
8
N
=
10
0
0
0
0
0
0.1
0.9983341665
4.62
E
-
8
3.08
E
-
11
4.33
E
-
14
0.2
0.1986693308
6.12
E
-
7
8.72
E
-
11
1.03
E
-
13
0.3
0.2955202067
4.28
E
-
7
1.45
E
-
11
1.66
E
-
13
0.4
0.3894183423
2.29
E
-
7
1.82
E
-
10
2.21
E
-
13
0.5
0.4794255386
4.23
E
-
7
1.65
E
-
10
2.71
E
-
13
0.6
0.5646424734
4.03
E
-
7
2.62
E
-
10
3.15
E
-
13
0.7
0.6442176872
3.32
E
-
7
3.01
E
-
12
2.29
E
-
13
0.8
0.7173560909
5.66
E
-
7
3.07
E
-
10
3.85
E
-
13
0.9
0.7833260096
8.87
E
-
6
5.68
E
-
9
9.73
E
-
13
1
0.841470984
1.43
E
-
5
1.22
E
-
8
1.57
E
-
11(a)  Comparison of the approximate solution with exact solution forN=10. (b)  Comparison of absolute errors for N=5,8, and 10.
(a)
(b)Example 2.
Consider the Duffing equation [20]
(33)y′′(x)+0.4y′(x)+1.1y(x)+y3(x)=0,
with initial conditions
(34)y(0)=0.3,y′(0)=-2.3.Applying the present method, we have the following fundamental matrix equation:(35){XB2+0.4XB+1.1X}Y+X~~Y~~=F,F=[00⋯0](N+1)×1T.The solution of this nonlinear system is obtained forN=5,10,15,  and 20. For numerical results, see Tables 2, 3 and Figure 2.Table 2
Numerical results of Example2.
x
r
Error analysis (EN(xr))
N
=
5
N
=
10
N
=
15
N
=
20
0
0
0
1.70
E
-
8
0
0.1
4.62
E
-
2
0
0
0
0.2
5.57
E
-
24
0
1.05
E
-
9
2.23
E
-
25
0.3
2.24
E
-
3
0
0
2.22
E
-
25
0.4
0
3.22
E
-
24
2.91
E
-
11
9.80
E
-
25
0.5
6.00
E
-
25
0
0
1.00
E
-
24
0.6
0
2.51
E
-
24
1.62
E
-
11
1.70
E
-
24
0.7
3.63
E
-
2
4.31
E
-
24
0
1.31
E
-
24
0.8
1.13
E
-
1
1.87
E
-
4
1.80
E
-
24
2.10
E
-
24
0.9
1.46
E
-
1
8.28
E
-
3
1.32
E
-
7
8.50
E
-
24
1
5.93
E
-
1
1.32
E
-
2
4.47
E
-
5
3.68
E
-
24Table 3
Comparison of numerical solutions.
x
r
y
~
(
x
) (Laplace method)
y
N
(
x
) (present method)
0
0.3
0.3
0.1
0.0835845348
0.08358453484
0.2
−0.105091915
−0.1050919158
0.3
−0.266020303
−0.2660203036
0.4
−0.399977948
−0.3999779482
0.5
−0.508314810
−0.5083148108
0.6
−0.592890689
−0.5928906891
0.7
−0.656065502
−0.6560655028
0.8
−0.700676939
−0.7006769399
0.9
−0.729970850
−0.7299708508
1
−0.747476077
−0.7474760775Figure 2
Error functions forN=10,15,and20 of Example 2.Example 3.
In this last example, the method is illustrated by considering the damped Duffing equation [21]
(36)y′′(x)+ky′=-y3(x),y(0)=α,y′(0)=β.
Consider the case  α=β=k=1.We have similar results for Example3 as in Example 2. Table 4 shows the error values EN(xr)   for  N=5,8,10, and 20.Table 4
Comparison of the absolute errors of Example3.
x
r
Error analysis (EN(xr))
N
=
5
N
=
8
N
=
10
N
=
20
0
0
0
0
0
0.1
4.62
E
-
3
5.08
E
-
6
0
0
0.2
0
6.72
E
-
6
0
0
0.3
4.54
E
-
3
1.45
E
-
6
0
0
0.4
0
3.82
E
-
6
0
0
0.5
7.85
E
-
3
0
0
0
0.6
0
2.62
E
-
5
0
0
0.7
5.42
E
-
2
3.01
E
-
5
0
0
0.8
1.94
E
-
1
8.07
E
-
4
0
0
0.9
0.46
E
-
1
5.68
E
-
3
0
0
1
0.93
E
-
1
1.22
E
-
2
4.57
E
-
8
3.32
E
-
29


## 6.  Conclusion

In this paper, a very simple but effective Taylor matrix method was proposed for the numerical solution of the nonlinear Duffing equation. One of the advantages of this method that is the solution is expressed as a truncated Taylor series, theny(x) can be easily evaluated for arbitrary values of x by using the computer program without any computational effort. From the given illustrative examples, it can be seen that the Taylor series approach can obtain very accurate and satisfactory results. However, the main point is that the polynomial expansion is highly ill-posed when x is larger than 1. This method can be improved with new strategies to solve the other nonlinear equations.



---

*Source: 691614-2013-06-11.xml*