vmohan1978 said:
Hi when i am using following example i am not getting required answer please
let me know what to do .
P0 60
P1 65
P2 70
P3 75
P4 80
P5 50
P6 40
P7 41
P8 43
P9 50
P10 85
P11 80
P12 75
P13 78
required answer is 2368 but i am getting 2524 .
Someone else has already pointed out that this has an odd number of
intervals, so Simpson's rule isn't applicable. Looks like the result
you want is the Simpson's rule result for the first 13 points (12
intervals) plus the sum of the last 2 points. In other words, in brute
force terms assuming your data was in B1:B14, you want
=SUMPRODUCT(B1:B14,{1;4;2;4;2;4;2;4;2;4;2;4;2;1})
which is equal to
=SUMPRODUCT(B1:B13,{1;4;2;4;2;4;2;4;2;4;2;4;1})+B13+B14
If you always want to handle even numbers of points/odd numbers of
intervals this way, try
=SUMPRODUCT(B1:B14,LOOKUP(MOD(ROW(B1:B14)-MIN(ROW(B1:B14)),2),{0,1},
{2,4}))
-B1-B14*IF(MOD(ROWS(B1:B14),2)=1,1,3)
And if you want to generalize this to refer to the defined name data,
=SUMPRODUCT(data,LOOKUP(MOD(ROW(data)-MIN(ROW(data)),2),{0,1},{2,4}))
-N(data)-LOOKUP(1E+300,data)*IF(MOD(ROWS(data),2)=1,1,3)