Post Reply 
Simpson's Rule Implementation trick?
03-18-2016, 08:47 PM
Post: #3
RE: Simpron Rule Implementation trick?
By initializing the sum as:

Code:
sum = f(a) + f(b) + 4*f(a+h)

Instead of the usual expression:
Code:

sum = f(a) + f(b)
We can then iterate over the terms multiplied by 2 and then by 4. We can do this:

Code:
for i=2 to n step 2
  sum = sum + 2*f(a+i*h) + 4*f(a + (i+1)*h)
next

Or, borrowing from the old threads:

Code:
c = 2
for i=2 to n
  x = x + h
  sum = sum + c*f(x)
  c = 6 - c
next
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Simpron Rule Implementation trick? - Namir - 03-18-2016 08:47 PM



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