Post Reply 
Compact Simpson's 3/8 Rule(??)
10-04-2019, 06:20 PM
Post: #19
RE: Compact Simpson's 3/8 Rule(??)
(09-25-2019 06:47 PM)Csaba Tizedes Wrote:  
Code:
h = (b - a) / n
sum = f(a) + f(b)

For i = 1 To n - 3 Step 3
  sum = sum + 3 * f(a + i * h) + 3 * f(a + (i+1) * h) + 2 * f(a + (i+2) * h)
Next

result = 3 / 8 * h * sum

I don't think this work.
We assumed n divisible by 3, and put a weight of 1 (3 3 2) ... (3 3 2) 3 3 1

However, above generate weight of 1 (3 3 2) ... (3 3 2) 0 0 1

You could also pull the (2*, 3*, 3*) from inside the loop, and scale it all in 1 step.
Code:
h = (b - a) / n
s2 = 0
s3 = f(a + h) + f(a + 2*h)
For i = 3 To n-3 Step 3
    s2 = s2 + f(a + i*h)
    s3 = s3 + f(a + (i+1)*h) + f(a + (i+2)*h)
Next i

result = 3/8 * h * (f(a) + f(b) + 2*s2 + 3*s3)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Compact Simpson's 3/8 Rule(??) - Namir - 12-13-2015, 02:26 PM
RE: Compact Simpson's 3/8 Rule(??) - Namir - 12-13-2015, 05:05 PM
RE: Compact Simpson's 3/8 Rule(??) - Albert Chan - 10-04-2019 06:20 PM



User(s) browsing this thread: 1 Guest(s)