Chebyshev finite difference approximation for the ...

6 downloads 0 Views 97KB Size Report
goes to infinity. The numerical differentiation and integration can be performed ... numerical solution of various boundary value problems [4,7] and in compu-.
Applied Mathematics and Computation 139 (2003) 513–523 www.elsevier.com/locate/amc

Chebyshev finite difference approximation for the boundary value problems Elsayed M.E. Elbarbary

a,*

, M. El-Kady

b,1

a

b

Department of Mathematics, Faculty of Education, Ain Shams University, Roxy, Hiliopolis, Cairo, Egypt Department of Mathematics, Faculty of Science, South Valley University, Aswan, Egypt

Abstract This paper presents a numerical technique for solving linear and non-linear boundary value problems for ordinary differential equations. This technique is based on using matrix operator expressions which applies to the differential terms. It can be regarded as a non-uniform finite difference scheme. The values of the dependent variable at the Gauss–Lobatto points are the unknown one solves for. The application of the method to boundary value problems leads to algebraic systems. The method permits the application of iterative method in order to solve the algebraic systems. The effective application of the method is demonstrated by four examples. Ó 2002 Elsevier Science Inc. All rights reserved. Keywords: Chebyshev approximation; Boundary value problems; Incomplete LU-decomposition

1. Introduction Chebyshev polynomials are used widely in numerical computations. One of the advantages of using Chebyshev polynomials Tn ðxÞ as expansion functions is the good representation of smooth functions by finite Chebyshev expansions provided that the function uðxÞ is infinitely differentiable. The Chebyshev *

Corresponding author. Present address: Department of Mathematics, Al Jouf Teacher College, P.O. Box 269, Al Jouf, Skaka, Saudi Arabia. E-mail address: [email protected] (E.M.E. Elbarbary). URL: http://elbarbary.cjb.net. 1 Present address: Department of Mathematics, Tabuk Teachers College, P.O. Box 1144, Tabuk, Saudi Arabia. 0096-3003/02/$ - see front matter Ó 2002 Elsevier Science Inc. All rights reserved. PII: S 0 0 9 6 - 3 0 0 3 ( 0 2 ) 0 0 2 1 4 - X

514

E.M.E. Elbarbary, M. El-Kady / Appl. Math. Comput. 139 (2003) 513–523

expansion coefficients an approach zero faster than any inverse power in n as n goes to infinity. The numerical differentiation and integration can be performed very fast. Furthermore, Chebyshev polynomials have proven successfully in the numerical solution of various boundary value problems [4,7] and in computational fluid dynamics [1,10]. Clenshaw and Curtis [3] give a procedure for the numerical integration of a non-singular function f ðxÞ defined on a finite range 1 6 x 6 1, by expanding the function in a series of Chebyshev polynomials and integrating this series term by term. El-Gendi [11] used the Clenshaw scheme to define an operation matrix B to approximate the integration in the following form: Z x  f ðtÞ dt ¼ B½f ; 1

where B is a square matrix of order N þ 1 and the elements of the column matrix ½f  are given by fk ¼ f ð cosðkp=N ÞÞ, k ¼ 0; 1; . . . ; N . The purpose of this paper is to present an alternative operation matrix for the differentiation. The derivatives of the function f ðxÞ at a point xj are expanded as a linear combination from the values of the function f ðxÞ at the Gauss–Lobatto points xk ¼ cosðkp=N Þ, where k ¼ 0; 1; 2; . . . ; N , and j is an integer 0 6 j 6 N . The coefficients of this linear combination are the elements of the jth row of the suggested operation matrix. The approximation of the derivatives by using the suggested operation matrix is applicable to the numerical solution of a wide area of linear and nonlinear problems. In this paper, the suggested method is applied to linear and non-linear boundary value problems for the ordinary differential equations. This approach requires definition of a grid as the finite difference and elements techniques also do and it is applied to satisfy the differential equation and the boundary conditions at the grid points. The grid points are Gauss–Lobatto points. The application of the suggested method to differential equation leads to system of algebraic equations. The first rows and last rows of the coefficients matrix of the algebraic system are replaced by a suitable formulation of the boundary conditions. The suggested method is more accurate in comparison to the finite difference and finite elements methods because the approximation of the derivatives is defined over the whole domain.

2. Chebyshev operation matrix for the differentiation The Chebyshev functions of the first kind are defined as Tn ðxÞ ¼ cosðn cos1 xÞ;

1 6 x 6 1:

E.M.E. Elbarbary, M. El-Kady / Appl. Math. Comput. 139 (2003) 513–523

515

Clenshaw and Curtis [3] give the following approximation of the function f ðxÞ, f ðxÞ ¼

N X 00

an Tn ðxÞ;

ð1Þ

n¼0

where an ¼

N 2 X 00 f ðxj ÞTn ðxj Þ: N j¼0

The summation symbol with double primes denotes a sum with both the first and last terms halved. The exact relation between Chebyshev functions and its first derivatives is expressed as 8 0 Tnþ1 ðxÞ > > ; n ¼ 0; > > > ðn þ 1Þ > > > < T 0 ðxÞ nþ1 ð2Þ Tn ðxÞ ¼ ; n ¼ 1; > 2ðn þ 1Þ > > > > > T 0 ðxÞ T 0 ðxÞ > > : nþ1 ; n > 1:  n1 2ðn þ 1Þ 2ðn  1Þ The second derivative of the Chebyshev functions is formed as following [6]: Tn00 ðxÞ ¼

n2 X k¼0 ðnþkÞ even

1 nðn2  k 2 ÞTk ðxÞ; ck

ð3Þ

where c0 ¼ 2 and ci ¼ 1 for i P 1. The substitution from Eq. (3) in differentiation of Eq. (2) gives a relation between Chebyshev functions and their first derivative. Tn0 ðxÞ ¼

n1 X k¼0 ðnþkÞ odd

2n Tk ðxÞ: ck

ð4Þ

From Eq. (4) and by differentiation the series in Eq. (1) term by term, we get f 0 ðxÞ ¼

N N X 2 X 00 00 N n¼0 j¼0

n1 X k¼0 nþk odd

2n f ðxj ÞTn ðxj ÞTk ðxÞ: ck

Also, from Eqs. (1) and (3) we obtain f 00 ðxÞ ¼

N N X 2 X 00 00 N n¼0 j¼0

n2 X k¼0 ðnþkÞ even

1 nðn2  k 2 Þf ðxj ÞTn ðxj ÞTk ðxÞ: ck

516

E.M.E. Elbarbary, M. El-Kady / Appl. Math. Comput. 139 (2003) 513–523

We can define the elements of the matrices D1 and D2 which are defined in the following relations: ½f 0  ¼ D1 ½f ;

½f 00  ¼ D2 ½f ;

where D1 and D2 are square matrices of order ðN þ 1Þ and the elements of the column matrices ½f 00 , ½f 0  and ½f  are given by fi00 ¼ f 00 ðxi Þ, fi0 ¼ f 0 ðxi Þ, fi ¼ f ðxi Þ, i ¼ 0; 1; . . . ; N respectively. The first and second derivatives of the function f ðxÞ at the point xk are given by f 0 ðxk Þ ¼

N X

1 dk;j f ðxj Þ;

ð5Þ

j¼0

f 00 ðxk Þ ¼

N X

2 dk;j f ðxj Þ;

j¼0 1 2 the coefficients dk;j and dk;j , j ¼ 0; 1; . . . ; N are the elements of the kth row of the matrices D1 and D2 respectively. They are given as follows: 1 dk;j ¼

2 ¼ dk;j

N 4hj X N n¼0

N 2hj X N n¼0

n1 X l¼0 ðnþlÞ odd n2 X l¼0 ðnþlÞ even

nhn Tn ðxj ÞTl ðxk Þ; cl

k; j ¼ 0; 1; . . . ; N ;

1 hn nðn2  l2 ÞTn ðxj ÞTl ðxk Þ; cl

k; j ¼ 0; 1; . . . ; N ;

where h0 ¼ hN ¼ 12, hj ¼ 1 for j ¼ 1; 2; . . . ; N  1. We may note that the elements of the matrices D1 and D2 are satisfying the following relations: 1 di;j ¼ dN1 i;N j ;

2 di;j ¼ dN2 i;N j ;

i; j ¼ 0; 1; 2; . . . ; N ;

which help us to save the number of stored elements. 2.1. Numerical differentiation In this section we examine the Chebyshev finite difference approximation (ChFD) which is given by Eq. (5) to approximate the differentiation of the functions. We present a simple illustrative example to show that the suggested method is more accurate than the known classical methods. Consider the following example Example 1. Consider the functions uðxÞ ¼ ex

E.M.E. Elbarbary, M. El-Kady / Appl. Math. Comput. 139 (2003) 513–523

517

Table 1 The maximum absolute error of the first derivative

eN ;u eN ;v

N ¼6

N ¼8

N ¼ 10

N ¼ 12

N ¼ 14

8:72 105 0.146861

3:91 107 7:45 103

1:09 109 2:23 104

2:06 1012 4:41 106

3:86 1014 6:24 108

and vðxÞ ¼ sin px: Table 1 shows the maximum absolute error eN ;u ¼ max ju0 ðxk Þ  u0N ðxk Þj k

of the ChFD method for the first derivative of the functions uðxÞ, and vðxÞ. The suggested method is highly accurate because the approximation of the derivative is defined over the whole domain. The maximum error which is due to the central finite difference approximation with the same number of points on the interval ½1; 1 is 8:02 103 for uðxÞ and 0.104406 for vðxÞ when N ¼ 14.

3. Application to some boundary value problems In this section, we will illustrate the use of the ChFD method to linear and non-linear ordinary differential equations. 3.1. Linear boundary value problems Consider the two points boundary value problem u00 ðxÞ þ qðxÞuðxÞ ¼ f ðxÞ;

1 6 x 6 1;

ð6Þ

ga

du þ f a u ¼ na ; dx

x ¼ 1;

ð7Þ

gb

du þ f b u ¼ nb ; dx

x ¼ 1;

ð8Þ

where ga , gb , fa , fb , na and nb are constants. By applying the ChFD method to Eq. (6), we obtain a system of linear equations as follows: ðD2 þ QÞ½u ¼ ½f ;

ð9Þ

518

E.M.E. Elbarbary, M. El-Kady / Appl. Math. Comput. 139 (2003) 513–523

where

0

qðx0 Þ 0 B 0 qðx 1Þ B B 0 0 Q¼B B .. .. @ . . 0 0

0 0 qðx2 Þ .. .

0 0 0 .. .

.. .

0 0 0 .. .

0

0



qðxN Þ

1 C C C C C A

The first and last equations on the system (9) are replaced by the ChFD for the boundary conditions (7) and (8) ga

N X

1 d0;j uðxj Þ þ fa uðx0 Þ ¼ na ;

j¼0

gb

N X

dN1 ;j uðxj Þ þ fb uðxN Þ ¼ nb :

j¼0

Then the values of uðxÞ at the Gauss–Lobatto points have to be determined from the linear system A½u ¼ ½f :

ð10Þ

The square matrix A is usually dense matrix and as a consequence it is expensive to solve this equation directly. On the other hand iterative solution of the Eq. (10) for large value of N is difficult due to AÕs rapidly rising condition number. The use of preconditioner could accelerate convergence even more. 3.2. Numerical examples Three test problems were solved using the suggested method with and without preconditioning. Since the linear systems involved are non-symmetric, the method of conjugate gradients squared (CGS) [5] was applied for their iterative solution. In particular the routines DCGS and DSLUCS of the SLAP FORTRAN library available via NETLIB have been used. DSLUCS calls DCGS using preconditioning by incomplete LU-decomposition (ILU). The stopping criterion is set to krðiÞ k 6 10b k½f k for the CGS method without preconditioning, and kM 1 rðiÞ k 6 10b kM 1 ½f k for the CGS method with preconditioning where rðiÞ ¼ ½f   A½uðiÞ denotes the residual of the ith iterate of the linear system (10) and M being the ILU pre-

E.M.E. Elbarbary, M. El-Kady / Appl. Math. Comput. 139 (2003) 513–523

519

conditioner. We apply a function exactly satisfying the boundary conditions as the starting guess. The condition numbers in the tables are calculated as the quotient of the largest to the smallest singular values. In the tables ‘‘maximum error’’ always refers to the maximum difference between approximation and exact values at the Gauss–Lobatto points. Comparing with other approaches, we will consider the next two examples which were also considered by Cabos [2], Hiegemann and Strau [8] and Hiegemann [9]. Example 2. Consider the boundary value problem u00 ðxÞ  uðxÞ ¼ 0;

1 6 x 6 1;

uð1Þ ¼ uð1Þ ¼ 1: which has the exact solution: uðxÞ ¼

ex þ ex : e þ e1

Applying the CGS method without preconditioning the solution of the problem was found in 21 step with condition number 939.584 for N ¼ 16. DSLUCS reached convergence after one step with condition number 15.66 (see Tables 2 and 3). The results of Cabos [2], Hiegemann and Strau [8] and Hiegemann [9] are compared with the suggested method without preconditioning in Table 2 and with preconditioning in Table 3 for N ¼ 16: Example 3. Consider the following boundary value problem: y 00 ðxÞ cos px 0 y ðxÞ þ ðcos px  sin pxÞyðxÞ ¼ ð1  3 sin pxÞepx ; 1 6 x 6 1;  p2 p Table 2 Iterative solution without preconditioning of Example 2 for N ¼ 16, b ¼ 10

Condition number Iteration steps Maximum error

CGS [8]

CGS [9]

Tau [2]

Present method

13374 28 7:0 1012

20.2 6 1:0 1013

6961 37 5:0 1012

939.584 21 3:72 1013

Table 3 Iterative solution with preconditioning of Example 2 for N ¼ 16, b ¼ 10

Condition number Iteration steps Maximum error

CGS, ILU [9]

Mod. Tau [2]

Present method, CGS, ILU

4 1 2:0 1016

2.3 6 2:0 1013

15.66 1 5:994 1015

520

E.M.E. Elbarbary, M. El-Kady / Appl. Math. Comput. 139 (2003) 513–523

Table 4 Iterative solution without preconditioning of Example 3 for N ¼ 32, b ¼ 10

Condition number Iteration steps Maximum error

CGS [8]

CGS [9]

Tau [2]

Present method

31024 107 5:0 1012

243.7 13 3:0 1011

2:5 104 109 4:0 1010

8657.47 65 1:34 1012

Table 5 Iterative solution with preconditioning of Example 3 for N ¼ 32, b ¼ 10

Condition number Iteration steps Maximum error

CGS, ILU [9]

Mod. Tau [2]

Present method, CGS, ILU

17.2 8 3:0 1011

37.6 12 1:0 109

307.476 1 4:11 1014

yð1Þ ¼ yð1Þ ¼ 0: The exact solution is yðxÞ ¼ ð1 þ cos pxÞepx . Using CGS without preconditioning for N ¼ 32, the present method needs 65 iteration steps for convergence with b ¼ 10 while DSLUCS reached convergence after one step only. We apply the zero function which is exactly satisfying the boundary conditions as starting guess. The results of Cabos [2], Hiegemann and Strau [8] and Hiegemann [9] are compared with the suggested method without preconditioning in Table 4 and with preconditioning in Table 5 for N ¼ 32. In the next example we consider boundary value problem with general boundary conditions. Example 4. Consider the following boundary value problem: u00 ðxÞ þ xex uðxÞ ¼ ex þ x; du 2 þu¼ ; dx e

x ¼ 1;

du  u ¼ 0; dx

x ¼ 1:

1 6 x 6 1;

The exact solution is uðxÞ ¼ ex . In Table 6, we will study the relation between the number of grid points on the interval ½1; 1, the condition number, the iteration steps and the maximum error. The linear system was solved by CGS method without preconditioning.

E.M.E. Elbarbary, M. El-Kady / Appl. Math. Comput. 139 (2003) 513–523

521

Table 6 Iterative solution of Example 4 for b ¼ 10, 15 N Condition number Iteration steps, b ¼ 10 maximum error, b ¼ 10 Iteration steps, b ¼ 15 maximum error, b ¼ 15

6 380.627 9 1:67 104 12 1:67 104

8 1183.17 15 7:21 107 17 7:21 107

10 3009.95 18 1:98 109 23 1:98 109

12 6571.22 24 9:25 1012 36 3:78 1012

14 12817.9 30 3:03 1012 50 5:35 1014

3.3. Non-linear boundary value problems In this section we use the suggested method for solving non-linear ordinary boundary value problems. The suggested method is applicable for a wide area of non-linear differential equations. We consider the following model problem as an example. v00 ðxÞ þ pðxÞvðxÞv0 ðxÞ þ qðxÞvðxÞ ¼ f ðxÞ; g1

dv þ f 1 v ¼ n1 ; dx

g1

x 2 ½1; 1;

ð11Þ

x ¼ 1;

dv þ f1 v ¼ n1 ; dx

x ¼ 1;

where pðxÞ, qðxÞ and f ðxÞ are continuous functions on ½1; 1 and g1 , g1 , f1 , f1 , n1 and n1 are constants. The ChFD of the Eq. (11) is given by ðD2 þ PVD1 þ QÞ½v ¼ ½f ;

ð12Þ

where 0

pðx0 Þ 0 0 B 0 pðx Þ 0 1 B B 0 0 pðx Þ 2 P ¼B B .. .. .. .. @ . . . . 0 0 0 0 vðx0 Þ 0 0 B 0 vðx Þ 0 1 B B 0 0 vðx Þ 2 V ¼B B .. .. .. .. @ . . . . 0 0 0

0 0 0 .. .

1 C C C C; C A

pðxN Þ 0 0 0 .. .

1 C C C C: C A

vðxN Þ

The first and last equations on the system (12) are replaced by the ChFD for the boundary conditions

522

E.M.E. Elbarbary, M. El-Kady / Appl. Math. Comput. 139 (2003) 513–523

Table 7 The maximum absolute error N eN ;v

8 4:4 104

g1

N X

10 4:3 106

12 3:5 108

14 3:5 1010

16 2:6 1012

18 1:8 1014

1 d0;j vðxj Þ þ f1 vðx0 Þ ¼ n1 ;

j¼0

g1

N X

dN1 ;j vðxj Þ þ f1 vðxN Þ ¼ n1 :

j¼0

The results system of non-linear equations was solved by NewtonÕs method. Example 5. Consider v00 ðxÞ þ sinðpxÞvðxÞv0 ðxÞ  p cosðpxÞvðxÞ ¼ f ðxÞ;

x 2 ½1; 1;

vð1Þ ¼ vð1Þ ¼ 0; where f ðxÞ ¼ p sinðpxÞðp þ ð1=2Þ sinð2pxÞ  cosðpxÞÞ: The exact solution is given by vðxÞ ¼ sinðpxÞ: The maximum absolute error eN ;v of the present method is given in Table 7.

4. Conclusions The normal procedure in handling solutions of differential equations using finite difference method is to express the derivatives of a function in terms of its values. The numbers of these terms are two and three for the central finite difference of the first and second derivatives respectively. In our work, the derivatives of a non-singular function at any point from the Gauss–Lobatto points are expanded as a linear combination from the values of the function at these points. The coefficients of this linear combination are the elements of the suggested matrices D1 and D2 . Such procedure has been established throughout the paper with details, and has been showed when applies it on test problems highly accurate results, as shown in the given tables, better than those obtained by other techniques. Also the ILU preconditioner reached convergence after one step. The suggested method can be used to facilitate greatly the setting up of the algebraic systems to be obtained by applying the suggested method for solving differential equations of any order. Finally we believe that the used technique is a different handling and is beneficial for numerically wide area of differential equations in further research work.

E.M.E. Elbarbary, M. El-Kady / Appl. Math. Comput. 139 (2003) 513–523

523

References [1] C. Canuto, M.Y. Hussaini, A. Quarterini, T.A. Zang, Spectral Methods in Fluid Dynamics, Springer-Verlag, Berlin, 1988. [2] C.H. Cabos, A preconditioning of the Tau operator for ordinary differential equations, ZAMM 74 (1994) 521–532. [3] C.W. Clenshaw, A.R. Curtis, A method for numerical integration on an automatic computer, Numer. Math. 2 (1960) 197–205. [4] D. Gottlieb, S.A. Orszag, Numerical analysis of spectral methods: theory and applications, in: CBMS-NSF Regional Conference Series, Applied Mathematics 26, SIAM, Philadelphia, PA, 1977. [5] E.F. Kaasschieter, The solution of non-symmetric linear systems by bi-conjugate gradients or conjugate gradients squared, Techn. Rep. Report 86-21, Delft University of Technology, Delft, 1986. [6] J. Shen, Efficient spectral-galerkin method II direct solver of second and fourth-order equations using Chebyshev polynomials, SIAM J. Sci. Comput. 16 (1995) 74–87. [7] L. Fox, I.B. Parker, Chebyshev Polynomials in Numerical Analysis, Clarendon Press, Oxford, 1968. [8] M. Hiegemann, K. Strau, On Chebyshev matrix operator method for ordinary linear differential equations with non-constant coefficients, Acta Mech. 105 (1994) 227–232. [9] M. Hiegemann, Chebyshev matrix operator method for the solution of integrated forms of linear ordinary differential equations, Acta Mech. 122 (1997) 231–242. [10] R.G. Voigt, D. Gottlieb, M.Y. Hussaini, Spectral Methods for Partial Differential Equations, SIAM, Philadelphia, PA, 1984. [11] S.E. El-Gendi, Chebyshev solution of differential integral and integro-differential equations, Comput. J. 12 (1969) 282–287.