International Journal of Scientific Engineering and Technology Vo lu me No.3 Issue No.4, pp : 342-345
(ISSN : 2277-1581) 1April 2014
A Numerical Simulator for Solving Numerical Integration B. K. Datta1 , N. Rahman1 , R. C. Bhowmik1 , S. Paul2 , M. R. Kabir1 & U. Roy Department of Mathematics, Pabna University of Science and Technology1 & Ball State University2 . bimaldu@gmail.com, nl.nizhum@yahoo.com, rajpust09@gmail.com, spaul@bsu.edu, rashedkabir_dhaka@yahoo.com & umams459@gmail.com Abstract : Numerical integration is a frequently-needed tool in modern Science and Engineering. E ngineers and Scientists typically visualize integration as the process of determining the area under a curve. Besides this, because of its many more applications, it is often viewed as a discipline in and of itself. In this paper we develop a mathematical simulator for solving numerical integration problems. This si mulator is incorporated with a combination of Trapezoidal rule, Simpson’s 1/ 3 rule, Simpson’s 3 / 8 rule and rule.
Clearly, xn x0 nh . Hence the integral beco mes
I
xn
I [ y 0 p y 0
Since
Given a set of data of points ( x0 , y 0 ) , ( x1 , y1 ) , ..., ( xn , y n ) of a function y f (x) where f (x) is not known explicit ly, it is required to compute the value of the defin ite integral b
(1)
a
We derive a general formula for nu merical integration using Newton’s forward difference formula. that a x0 x1 ... xn b .
IJSET@2014
p( p 1) 2 p( p 1)( p 3) 3 y0 y 0 ...] dx 1.2 1.2.3
x x0 ph and so dx dp hence the above integral
becomes
Integration generally means combining parts so that they form a whole. The foundation for the discovery of the integral was laid by Cavelieri, an Italian mathematician, in around 1635. Besides, numerical algorith ms are almost as old as human civilization. In numerical analysis, numerical integration constitutes a broad family of algorith ms for calculating the numerical value of a definite integral. Arch imedes of Syracuse (287-212 BC) created much new mathematics, including the “method of exhaustion” for calculating lengths, areas, and volumes of geo metric figures [1] . When used as a method to find approximations, it is in much the spirit of modern numerical integration; and it was an important precursor to the development of the calculus by Isaac Newton and Gottfried Leibnit z. Following Newton, many of the giants of mathematics of the 18th and 19th centuries made major contributions to the numerical solution of mathemat ical problems.
Let the interval [a, b] be divided into
y by Newton’s forward
x0
x0
1. Introduction
y dx
y dx . No w appro ximating
difference formu la, we obtain [3]
Keywords : Trapezo idal, Weddle, Sy racuse, language
I
xn
n equal subintervals such
n
I [ y 0 p y 0 0
p( p 1) 2 p( p 1)( p 3) 3 y0 y 0 ...] dp 1.2 1.2.3
This imp lies xn
y dx nh[ y
x0
0
(n / 2) y0
n(2n 3) 2 y0 ...]dp 12
(2)
Fro m this general formula, we can obtain different integration formula by putting n 1, 2, 3,... etc. Programming language C is very flexib le and powerful. It originally designed in the early 1970s [4]. It allows us to maximu m control with minimu m co mmand. It is recognized world wide and used in a multitude of applications especially in numerical analysis. Along with other numerous benefits, we have used programming language C in this paper. The outline of this paper is as follows: Section 2 contains the brief description of the existing methods with methodology and simp le examp les. In Section 3, we develop a numerical simu lator, using the programming language C, wh ich gives us the solution of a problem simu ltaneously regarding four popular existing numerical integration methods namely Trapezoidal rule, Simpson’s 1/ 3 rule, Simpson’s 3 / 8 rule and Weddle’s rule. Moreover, the simulator identifies the method that gives the best solution comparing with possible exact solution of the problem.
Page 342
International Journal of Scientific Engineering and Technology Vo lu me No.3 Issue No.4, pp : 342-345 We devote Section 4 to an output of the program for a specific problem. Conclusions are given at the end at Section 5.
(ISSN : 2277-1581) 1April 2014 x4
Similarly,
2. Existing Methods We give a brief description of the existing methods of numerical integration like Trapezo idal ru le, Simpson’s 1/ 3 rule, Simpson’s 3 / 8 rule and Weddle’s rule in this section with their methodology and simple examples. 2.1 Trapezoi dal Rule Putting n 1 in (2) all d ifferences higher than the first will become zero and therefore we have x1
y dx h [ y
0
(1 / 2) y0 ] (h / 2) [ y0 y1 ]
x0
For the next interval [ x1 , x2 ] and others we have the similar x2
expression as
y dx (h / 2) [ y1 y2 ] and so on and finally x1
for the last interval
[ xn 1 , xn ] , we have
xn
y dx (h / 2)[ y n1 y n ] .
xn 1
Co mbin ing all these expressions, we obtain the rule [2] xn
y dx (h / 2) [ y
0
y dx (h / 3) [ y
4
4 y3 y2 ] and finally
x2
2( y1 y2 ... yn1 ) yn ]
x0
xn
y dx (h / 3) [ y
n
4 yn1 yn2 ]
xn 2
Co mbin ing all these expressions, we obtain
xn y dx (h / 3) [ y0 4( y1 y3 ... yn 1) xn 2( y y ... y ) y ] 2 4 n2 n This is known as Simpson’s 1 / 3 rule. 2.2.1 Example Calculate the integral of the function,
f ( x) 2 x
in the
interval (0,1) using Simpson's 1 / 3 rule. Let
h 1 / 3 . The tabulated values of and are given below
x
0
1/6
1/3
½
2/3
5/6
1
y f (x)
0
1/3
2/3
1
4/3
5/3
2
Using Simpson’s 1/3 Ru le
5 1 1 2 4 I 0 4 1 2 2 1 3 18 3 3 3
This is known as Trapezo idal rule. 2.3 Simpson’s 3/8 Rule 2.1.1 Example 3
1 We are estimat ing 1 ln x 3 dx using the Trapezoidal Rule with
n 4.
Here h (b a) / n (3 1) / 4 1 , and 3
Putting n 3 in (2) all differences higher than the third term will beco me zero and therefore we have
x3 3 9 2 3 3 y y ] y dx 3h [ y0 y0 0 0 2 12 24 x0
1
ln x 3 dx (h / 2) [ y
0
2( y1 y2 ... yn1 ) yn ]
3 h [ y 3 y 3 y y ] 0 1 2 3 8 x6
1
3
y dx 8 h [ y 3 y
[0.9102 2(0.721 0.621 0.558) 0.514] / 2 2.613
Similarly,
2.2 Simpson’s 1/3 Rule
Summing up all these, we obtain [3]
Putting n 2 in (2) all d ifferences higher than the second term will beco me zero and therefore we have
xn
y dx (3h / 8) [ y
0
3 y5 y6 ] and so on.
3 y1 3 y2 2 y3 3 y4 3 y5
0
y0 2 y0 / 6] ( h / 3) [ y2 4 y1 y0 ]
2 y6 ... 2 yn 3 3 yn 2 3 yn 1 yn ]
x0
This is known as Simpson’s IJSET@2014
4
x0
x2
y dx 2h [ y
3
x3
3/ 8
rule. Page 343
International Journal of Scientific Engineering and Technology Vo lu me No.3 Issue No.4, pp : 342-345 2.3.1 Example
INPUT: function
We solve the integral of the function, f ( x) x 1 , in the interval [1, 4] using Simpson's 3 / 8 rule. 2
Let
(ISSN : 2277-1581) 1April 2014
x
1
2
3
4
y
2
5
10
17
direct result r . Step-1: Co mpute
h 1 . The tabulated values of x and y are given below:
Step-2: Set
xn
y dx (3h / 8) [ y
0
3 y1 3 y2 2 y3 3 y4 3 y5
2 y6 ... 2 yn 3 3 yn 2 3 yn 1 yn ]
x6
3h
y dx 10 [ y
0
5 y1 y2 6 y3 y4 5 y5 y6 ]
i 1
rule
is
Else
If
i%3 0 sum _ 3 sum _ 3 2 y [i ]
6
t _ Sum _ 2 (h / 3) * ( y [0] y [n] sum _ 2)
o
t _ Sum _ 3 (3h / 8) * ( y [0] y [n] sum _ 3)
2 x dx up to three decimal p laces, by Weddle’s
h 1.0 . The tabulated values of x and y
are given below
If
i%6 0
Set 0 0
1 2
2 4
3 6
4 8
5 10
6 12
y dx (3h / 10 ) [ y 0 5( y1 y 5 ) 6 y 3
x0
( y 2 y 4 ) y 6 ] 36
3. Algorithm Now we are introducing an algorith m to evaluate an integral numerically by four well known methods namely Trapezo idal rule, Simpson’s 1/3 rule, Simpson’s 3/8 rule and Weddle’s rule simu ltaneously and it will ensure which method gives the best accuracy compare to the exact solution. IJSET@2014
sum _ 3 sum _ 3 3 y [i ]
t _ Sum _ 1 (h / 2) * ( y [0] y [n] sum _ 1)
Fro m Weddle’s Rule,
sum _ 2 sum _ 2 4 y [i ]
Set
rule.
xn
sum _ 2 sum _ 2 2 y [i ]
Set
Else
2.4.1 Example
x y
i%2 0
Set
5( y1 y7 ... y ) 6( y3 y9 ... yn 3 ) yn ]
Let
i n , repeat Step-7
sum _ 1 sum _ 1 2 y [i ]
Set
x0
And thus the general form for Weddle’s xn y dx ( 3h / 10) [ y0 2( y6 y12 ... yn 6 ) x0
We evaluate
Step-5: Set
If
Putting n 6 in (2) all differences higher than the first will become zero and we obtain
i n , repeat Step- 4
y [i ] f ( x0 ih)
Step-7: Set
2.4 Weddle’s Rule
xn x0 n
Step-4: Set
Step-6: While
x0
h
i0
Step-3: While
Fro m Simpson’s 3/8 Ru le,
f , limits x 0 and x n , number of d ivision n ,
sum _ 4 sum _ 4 2 y [i ]
Else if Set
i%3 0
sum _ 4 sum _ 4 6 y [i ]
Else Set
sum _ 4 sum _ 4 4 y [i ]
Else If ( i % 6 1 || i % 6 5 )
sum _ 4 sum _ 4 5 y [i ] Else
sum _ 4 sum _ 4 y [i ] t _ sum _ 4 (3 * h / 8) * ( y [0] y [n] sum _ 4)
Step-8: Set
a t _ sum _ 1 r , b t _ sum _ 2 r , Page 344
International Journal of Scientific Engineering and Technology Vo lu me No.3 Issue No.4, pp : 342-345
c t _ sum _ 3 r , d t _ sum _ 4 r If ( a b and
a c)
If ( a d )
(ISSN : 2277-1581) 1April 2014
Please enter 6 o r mu ltiple of 6: 12 Type direct result of integration:
t _ Sum _ 1 .693140
Else
4.2 Output:
t _ sum _ 4 If ( b a and
bc)
If ( b d )
t _ Sum _ 2
The Trapezoidal rule g ives: 0.693581 The Simpson
1 / 3 rule g ives: 0.693149
The Simpson
3 / 8 rule g ives: 0.693150
Else
t _ sum _ 4 If ( c
a and c b )
If ( c d )
t _ Sum _ 3 Else
t _ sum _ 4 OUTPUT:
t _ Sum _ 1 , t _ Sum _ 2 , t _ Sum _ 3 ,
t _ sum _ 4 with message which sum is most
The Weddle’s rule gives: 0.693147 Weddle’s rule gives the best among these.
5 Conclusion In this paper, we develop a simulator incorporated with traditional Trapezoidal ru le, Simpson’s 1/ 3 rule, Simpson’s 3 / 8 rule and Weddle’s rule for solving numerical integration. We observed that the result obtained according to our procedure is completely identical with the hand calculation. We therefore, hope that this simulator can evaluate integrals nu merically to save time and labour. Moreover, we have seen that Weddle’s rule gives the best solution among the four methods.
accurate. STOP.
REFERENCES i.
4 Findings We are now giving a trial of the simulator fo r the numerical 1 1 integration problem I 0 1 x dx . 4.1 Input: This is a program to evaluate numerical integration and check which method gives the best accuracy. Enter equation:-
A. Kaw, E.E. Kalu, Numerical Methods with Applications,
Lalu.com, 2008. ii.
C. Edwards, Jr. The Historical Development of the Calculus,
Springer-Verlag, 1997. iii.
M.
Goyal,
Computer-based
Numerical
&
Statistical
Techniques, Infinity Science Press LLC, New Delhi, India, 2007. iv.
S. S. Sastry, Introductory Methods of Numerical Analysis,
Prentice-Hall India, 2005.
1 I 1 x Type the initial value & final value: 0 1 Type the number of div ision. IJSET@2014
Page 345