Post Reply 
Compact Simpson's 3/8 Rule(??)
09-25-2019, 06:47 PM
Post: #17
RE: Compact Simpson's 3/8 Rule(??)
(12-13-2015 05:05 PM)Namir Wrote:  
Code:
h = (b - a) / n
sum = f(a) + f(b)

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

result = 3 / 8 * h * sum
I like your FOR loop and the use of the SIGN function!!

Now we have a compact implementation that performs one function summation per iteration and with minimum calculations. Your pseudo-code version looks simple and very nice.


Or maybe:

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

Csaba
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(??) - Csaba Tizedes - 09-25-2019 06:47 PM



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