Numerical Calculation Part 3: Integration (Simpson’s method) Dr.Entesar Ganash Simpson’s Rule Simpson’s rule is a method of numerical integration, which is a good deal more accurate than the Trapezoidal rule. It also divides the area under the function into vertical strips, but instead of joining the points f ( xi ) with straight lines, every set of three such successive points are fitted with a parabola. Simpson’s Rule f ( xi ) Simpson’s Rule Dividing [a,b] into EVEN number n of sub intervals of equal length h=(b-a)/n a x0 Simpson’s Rule Simpson’s rule is b h a f ( x) dx 3 f (a) 4 f ( x1 ) 2 f ( x2 ) 4 f ( x3 ) 2 f ( x4 ) ..... 4 f ( xn1 ) f (b) Odd terms Even terms Example Write a program to find the value of the following function using Simpson's method, take n=60 1 2 x dx 0 Solving program Simpson Implicit none Integer :: i ! counter Real :: h, sum, x Integer :: n ! the number of subintervals (EVEN No) Real:: a,b ! the start & end integration term a=0.0 b=1.0 n=60 h = (b-a)/real(n) sum = f(a) + f(b) Do i=1,n-1 x = a + i*h if (i/2*2.NE.i)Then sum = sum + 4*f(x) !ODD terms Else sum = sum + 2*f(x) !EVEN terms End if End Do sum = h*sum/3.0 Print *,'The numerical Simpson value=',sum CONTAINS function f(t) real ::f, t f=t**2 end function f End program Simpson 1 continue Solving The result: Exercise Write a program to find the value of the following function using Simpson's method, take n=64 5 sin 2 ( x) 1 x dx References •Hahn, B.D., 1994, Fortran 90 For Scientists and Engineers, Elsevier. •http://en.wikipedia.org/wiki/Simpson%27s_rule •http://www.uobabylon.edu.iq/eprints/publication_4_13618_553.pdf •Univ.,
© Copyright 2026 Paperzz