Sie sind auf Seite 1von 5

Applied Mathematics and Computation 156 (2004) 493–497

www.elsevier.com/locate/amc

An algorithm to compute the derivatives


of the function
M.T. Rashed
Department of Mathematics, Faculty of Science, Sohag University, 82516 Sohag, Egypt

Abstract
The suggested method is depended on an interpolation. The method is extended to
compute nth derivative. The method is tested by several examples.
Ó 2003 Elsevier Inc. All rights reserved.

1. Introduction

In this paper, we discuss an algorithm to compute the derivatives of a


function. The algorithm depend on an interpolation (for further reading see
Refs [1–4]). In Section 2, we give the suggested method. In Section 3, we give
numerical examples. Finally, we put the conclusion of this paper.

2. The suggested method

Consider the interpolation


X n
yðxÞ ¼ cj Tn ðx; xj Þ; a 6 x 6 b; ð2:1Þ
j¼0

where
Y
n
Tn ðx; xj Þ ¼ ðx  xk Þ;
k¼0
k6¼j

E-mail address: taha_123452002@yahoo.com (M.T. Rashed).

0096-3003/$ - see front matter Ó 2003 Elsevier Inc. All rights reserved.
doi:10.1016/j.amc.2003.08.022
494 M.T. Rashed / Appl. Math. Comput. 156 (2004) 493–497

xj ¼ a þ jðbaÞ
n
, j ¼ 0ð1Þn. From (2.1) we get a system of equations

X
n
yðzi Þ ¼ cj Tn ðzi ; xj Þ; i ¼ 0ð1Þn; ð2:2Þ
j¼0

where
 
ba ði  0:45Þp bþa
zi ¼ cos þ ; i ¼ 0ð1Þn:
2 n 2

From (2.1) we get

X
n
y 0 ðxÞ ¼ cj bn ðx; xj Þ;
j¼0

X
n
y 00 ðxÞ ¼ cj dn ðx; xj Þ
j¼0

and

X
n
y 000 ðxÞ ¼ cj en ðx; xj Þ;
j¼0

where

bn ðx; xj Þ ¼ Tn ðx; xj Þf1 ðx; xj Þ;

dn ðx; xj Þ ¼ Tn ðx; xj Þff12 ðx; xj Þ  f2 ðx; xj Þg

and
 
en ðx; xj Þ ¼ Tn ðx; xj Þ f13 ðx; xj Þ  3f1 ðx; xj Þf2 ðx; xj Þ þ 2f3 ðx; xj Þ ;

where

X
n
1
f1 ðx; xj Þ ¼ ;
ðx  xk Þ
k¼0
k6¼j

X
n
1
f2 ðx; xj Þ ¼ 2
;
ðx  xk Þ
k¼0
k6¼j
M.T. Rashed / Appl. Math. Comput. 156 (2004) 493–497 495

X
n
1
f3 ðx; xj Þ ¼ 3
:
ðx  xk Þ
k¼0
k6¼j

The method may be extended to compute the nth derivative of a function


yðxÞ as follows:
Since
X
n
ð1Þ
yðxÞ ¼ cj Tn ðx; xj Þ
j¼0

or
ð1Þ
½cj ¼ A1 ½y

but
X
n
ð1Þ
y 0 ðxÞ ¼ cj bn ðx; xj Þ
j¼0

or
ð1Þ
½y 0 ¼ B½cj
½y 0 ¼ BA1 ½y

also, since
X
n
ð2Þ
y 0 ðxÞ ¼ cj Tn ðx; xj Þ:
j¼0

Hence
h i
ð2Þ
cj ¼ A1 ½y 0 ;

X
n
ð2Þ
y 00 ¼ cj bn ðx; xj Þ;
j¼0

½y 00 ¼ BA1 ½y 0
..
.
½y ðnÞ ¼ BA1 ½y n1 :

It is obvious that the matrices B, A1 and BA1 are computed in computing
the first derivative only and hence computing the second derivative with using
the matrix BA1 and the first derivative of the function yðxÞ and so on.
496 M.T. Rashed / Appl. Math. Comput. 156 (2004) 493–497

3. Numerical examples

In this section, we give the computed error by

Z 1=2 !1=2
1
2
X
n
2
rn ¼ ðen ðtÞÞ dt 1=n ðen ðxj ÞÞ ;
1 j¼0

en ðxj Þ ¼ yexact ðxj Þ  yn ðxj Þ;

where yexact ðxÞ is the exact derivative of function and yn ðxÞ is given by the
suggested method. Table 1 show the first El, second E2 and third E3 derivative
of the following functions:

1: yðxÞ ¼ x2
2: yðxÞ ¼ x2 þ 4x þ 4:

Table 2 shows the first E1, second E2 and third E3 derivative of the following
functions:

3: yðxÞ ¼ ex 06x61
4: yðxÞ ¼ lnðx þ 3Þ 0 6 x 6 1:

Table 3 shows the first E1, the second E2 and third E3 derivative of the fol-
lowing functions:
px
5: yðxÞ ¼ cos 06x61
2
6: yðxÞ ¼ tan1 ð4x þ 5Þ; 0 6 x 6 1:

Table 1
Function 1 2
n E1 E2 E3 El E2 E3
2 1.3D)15 1.8D)15 2.1D)14 5.3D)15 3.9D)14 4.4D)13
3 6.2D)15 4.3D)14 1.8D)13 4.6D)14 2.3D)13 3.5D)12
4 1.3D)14 1.6D)13 1.6D)12 1.4D)13 1.6D)12 3.3D)11
5 2.7D)14 4.9D)13 8.6D)12 1.2D)13 2.4D)12 1.2D)10
6 3.6D)14 8.4D)13 2.8D)11 5.3D)13 1.4D)11 4.3D)10
7 3.2D)14 1.5D)12 4.8D)11 7.0D)13 3.2D)11 6.0D)10
8 8.9D)16 9.6D)13 6.4D)11 5.9D)13 3.3D)11 1.7D)09
9 4.9D)14 3.5D)12 3.9D)10 5.1D)13 3.9D)11 8.1D)09
10 1.0D)13 6.8D)12 6.6D)10 2.3D)12 1.7D)10 1.5D)08
14 3.5D)12 5.1D)10 7.8D)08 7.6D)11 1.1D)08 1.8D)06
M.T. Rashed / Appl. Math. Comput. 156 (2004) 493–497 497

Table 2
Function 3 4
n E1 E2 E3 E1 E2 E3
2 1.0D)01 7.1D)01 2.5D+00 3.0D)02 2.1D)02 5.8D)02
3 1.3D)02 1.2D)01 7.4D)01 3.3D)04 3.3D)03 1.8D)02
4 1.1D)03 1.5D)02 1.3D)01 3.0D)05 4.6D)04 3.9D)03
5 6.2D)05 1.3D)03 1.6D)02 2.5D)06 5.6D)05 6.9D)04
6 2.9D)06 8.5D)05 1.5D)03 2.0D)07 6.2D)06 1.1D)04
7 1.1D)07 4.5D)06 1.0D)04 1.6D)08 6.5D)07 1.5D)05
8 3.8D)09 1.9D)07 6.7D)06 1.2D)09 6.5D)08 1.9D)06
9 1.1D)10 7.2D)09 6.7D)07 9.6D)11 6.2D)09 2.3D)07
10 3.3D)12 2.5D)10 8.7D)09 4.7D)12 5.9D)10 1.4D)08
14 1.9D)11 2.8D)09 4.8D)07 1.4D)11 2.1D)09 3.5D)07

Table 3
Function 5 6
n E1 E2 E3 E1 E2 E3
2 1.2D)01 1.1 1.8D+00 1.1D)02 7.8D)02 2.8D)01
3 3.4D)02 3.4D)01 1.7 3.0D)03 3.3D)02 1.9D)01
4 4.2D)03 5.9D)02 5.1D)01 6.7D)04 1.1D)03 9.9D)02
5 3.9D)04 8.5D)03 1.0D)01 1.3D)04 3.0D)03 3.9D)02
6 2.8D)05 8.3D)04 1.4D)02 2.4D)05 7.4D)04 1.3D)02
7 1.8D)06 7.1D)05 1.6D)03 4.0D)06 1.7D)07 3.9D)03
8 9.3D)08 4.7D)06 1.4D)04 6.6D)07 3.5D)05 1.1D)03
9 4.4D)09 2.8D)07 1.0D)05 1.0D)07 6.9D)06 2.6D)04
10 1.8D)10 1.4D)08 6.4D)04 1.6D)08 1.3D)06 5.9D)05
12 7.0D)13 7.3D)11 2.0D)08 3.4D)10 2.3D)07 2.6D)06

4. Conclusion

We have shown that the numerical derivative of a function is very useful.


The method is extended to compute nth-derivative. The derivatives are given at
the points xi ¼ ba
2
cosðði0:45Þp
n
Þ þ bþa
2
, i ¼ 0ð1Þn. The very rapid convergence
obtain shows that the method treats the problem of finding derivatives of a
function.

References

[1] I.S. Berezin, N.P. Zhidkor, Computing methods, Pergamon Press, Oxford, 1965.
[2] F. Feuilebcis, Precise calculation of numerical derivatives using Lagrange and Hermite
interpolation, Comp. Math. Appl. 19 (5) (1990) 1–11.
[3] Z. Kopal, Numerical Analysis, Wiley, NY, 1955.
[4] F.B. Hildebrand, Introduction to Numerical Analysis, Tata McGraw-Hill, 1970.

Das könnte Ihnen auch gefallen