0% found this document useful (0 votes)
65 views10 pages

Integration

This document describes algorithms for numerical integration using the Trapezoidal, Simpson's 1/3, and Simpson's 3/8 rules. The Trapezoidal method approximates the area under a curve using trapezoid strips. Simpson's rules are improvements on the Trapezoidal method that use parabolic interpolation to achieve better accuracy. All methods involve dividing the area into strips, calculating the function value at interval points, and summing the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views10 pages

Integration

This document describes algorithms for numerical integration using the Trapezoidal, Simpson's 1/3, and Simpson's 3/8 rules. The Trapezoidal method approximates the area under a curve using trapezoid strips. Simpson's rules are improvements on the Trapezoidal method that use parabolic interpolation to achieve better accuracy. All methods involve dividing the area into strips, calculating the function value at interval points, and summing the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

1

03/23/2023
PREPARED BY: ER. KOBID KARKEE
Lab 9:
Numerical Integration Using
Trapezoidal, Simpson’s 1/3,
Simpson’s 3/8
Trapezoidal Method 2
Algorithm

03/23/2023
PREPARED BY: ER. KOBID KARKEE
1. Start
2. Declare the necessary variables and define the function
f(x).
3. Input the lower limit and upper limit as a and b
respectively.
4. Input the number of strips as n.
5. Compute the value of strip width as h = (b-a)/n.
6. Set sum = f(a) + f(b)
Trapezoidal Method 3
7. Begin for i=1 to n-1

03/23/2023
PREPARED BY: ER. KOBID KARKEE
sum = sum + 2*f(a + i*h)
End for i
8. sum = sum*h/2
9. Display sum as the integral value.
10. Stop
Pseudo Code 4

03/23/2023
PREPARED BY: ER. KOBID KARKEE
Input lower limit a, upper limit b, number of strips n
Define function f(x)
Calculate h = (b-a)/n
sum = f(a) + f(b)
Do for i = 1 : n-1
sum = sum + 2* f(a + i * h)
End for i
sum= (h/2)*sum
Print sum
Simpson’s 1/3 Method
5
Algorithm

03/23/2023
PREPARED BY: ER. KOBID KARKEE
1. Start
2. Declare the necessary variables and define the function f(x).
3. Input the lower limit and upper limit as a and b respectively.
4. Input the number of strips as n (where n is even).
5. Compute the value of strip width as h = (b-a)/n.
6. sum = f(a) + f(b)
Simpson’s 1/3 Method
6
7. for i=1 to n-1

03/23/2023
PREPARED BY: ER. KOBID KARKEE
if (i%2==0)
sum = sum + 2*f(a+i*h)
else
sum = sum + 4*f(a+i*h)
end i
8. sum= (h/3)*sum
9. Display sum as the integration value.
10. Stop
Pseudo Code
Input lower limit a, upper limit b, number of strips n 7
Define function f(x)

03/23/2023
PREPARED BY: ER. KOBID KARKEE
Calculate h = (b-a)/n
sum = f (a) + f (b)
For i = 1 : n-1
if(i%2==0)
sum = sum + 2*f( a + i * h)
else
sum = sum + 4*f( a + i * h)
end if
End for i
sum = (h/3)*sum
Print sum
Simpson’s 3/8 Rule 8

Algorithm

03/23/2023
PREPARED BY: ER. KOBID KARKEE
1. Start
2. Declare the necessary variables and define the function f(x).
3. Input the lower limit and upper limit as a and b respectively.
4. Input the number of strips as n where n is a multiple of 3.
5. Compute the value of strip width as h = (b-a)/n.
6. sum = f(a) + f(b)
Simpson’s 3/8 Rule 9

7. For i = 1 to n-1, perform

03/23/2023
PREPARED BY: ER. KOBID KARKEE
if (i%3==0)
sum = sum + 2*f(a + i*h)
else
sum = sum + 3*f(a + i*h)
end i
8. sum = (3*h/8)*sum
9. Display sum as the integral value.
10. Stop
Pseudo Code 10
Input lower limit a, upper limit b, number of strips n
Define function f(x)

03/23/2023
PREPARED BY: ER. KOBID KARKEE
Calculate h = (b-a)/n
sum = f (a) + f (b)
For i = 1 : n-1
if(i%3==0)
sum = sum + 2*f( a + i * h)
else
sum = sum + 3*f( a + i * h)
End if
End for i
sum = (3*h/8)*sum
Print sum

You might also like