Anda di halaman 1dari 6

Integration by Simpson's 3-Point Rule

This spreadsheet has a general program for numerical integration by Simpson's 3-point rule. The
user inputs the upper bounds, the lower bounds and number of intervals. A greater interval number
increases the accuracy. The spreadsheet also has an example calculated with just a spreadsheet
calculation to demonstrate what the program is doing. The general formula for Simpsons rule is:

UB
n
∫ f ( x )⋅dx=∑i=2,4,6 . .. (h/3)⋅( x i−2+ 4⋅x i−1+x i )
LB

Where,

LB = Lower bounds of integration


UB = Upper bounds of integration
X= Independent variable
n= number of intervals
h= step size
i= index for the interval
Simpson's Rule Program

This sheet uses a general purpose macro for Simpsons Rule 3-pt. Integration

Input
Example: f(x) = X2+2X-0.15
lower bounds = 0.00 input values in the yellow-shaded cells
Upper bounds = 2.4
number of increments= 12
h= 0.2 calculated step size

Calculation

The "change function" button takes you to the location in the macro to change the function.
Close window when complete. The "integrate function" button actives the integration program.

Change Function Integrate Function

Results

area under curve = 10.008 by VBA program


Example Sheet

This sheet shows a demonstration example calculated out using only the spreadsheet

Example: f(x) = X2+2X-0.15


lower bounds = 0.00
Upper bounds = 2.4
number of increments 12
h= 0.2

i x f(x) Trapazoidal Simpson Simpson


Rule 3 pt. 4 pt
0 0 -0.15
1 0.2 0.29 0.014
2 0.4 0.81 0.11 0.121333
3 0.6 1.41 0.222 0.342
4 0.8 2.09 0.35 0.569333
5 1 2.85 0.494
6 1.2 3.69 0.654 1.145333 1.494
7 1.4 4.61 0.83
8 1.6 5.61 1.022 1.849333
9 1.8 6.69 1.23 3.078
10 2 7.85 1.454 2.681333
11 2.2 9.09 1.694
12 2.4 10.41 1.95 3.641333 5.094

area= 10.0240 10.0080 10.0080

compares to an analytic solution of: 10.0080


28-Jun
12-Feb
136.00
4.533333
d= 25

EGL 90.5 90.5 90.5 90.5 90.5 90.5 90.5


A-A 81.197 89.634 95.674 92.045 87.116 82.423 82.423
B-B 82.468 91.17 96.925 97.625 94.083 88.956 81.435
C-C 83.122 92.228 97.939 100.341 97.04 92.03 84.384
D-D 83.899 92.729 97.541 99.556 96.988 91.38 84.458
E-E 74.118 83.553 91.166 95.437 96.324 92.927 85.962
120

100

A-A 9.303 0.866 -5.174 -1.545 3.384 8.077 8.077 80


B-B 8.032 -0.67 -6.425 -7.125 -3.583 1.544 9.065 60
C-C 7.378 -1.728 -7.439 -9.841 -6.54 -1.53 6.116
40
D-D 6.601 -2.229 -7.041 -9.056 -6.488 -0.88 6.042
E-E 16.382 6.947 -0.666 -4.937 -5.824 -2.427 4.538 20

0
1 2
90.5 90.5 90.5 90.5 90.5 90.5 90.5
A-A 8.6675 0.098 -5.7995 -4.335 -0.0995 4.8105 8.571
B-B 7.705 -1.199 -6.932 -8.483 -5.0615 0.007 7.5905
C-C 6.9895 -1.9785 -7.24 -9.4485 -6.514 -1.205 6.079
D-D 11.4915 2.359 -3.8535 -6.9965 -6.156 -1.6535 5.29
-7.2965

A-A 17.2385 2.294 -11.798 7.7345


B-B 15.2955 -38.7 -23.987 -47.3915
C-C 13.0685 -50.528 -27.508 -64.9675
D-D 16.7815 -25.164 -20.019 -28.4015
-133.026

d/3 8.333333 -1108.55


120

100
EGL A-A
80

60 B-B C-C

40
D-D E-E
20
D
D-
0
B -B
1 2 L
3 4 5 EG
6 7

Anda mungkin juga menyukai