Processing math: 100%

 

 

 

Algorithm for Simpson's rule

The method can easily be implemented numerically through the following simple algorithm

  • Choose the number of mesh points and fix the step.
  • calculate f(a) and f(b)
  • Perform a loop over n=1 to n1 (f(a) and f(b) are known) and sum up the terms 4f(a+h)+2f(a+2h)+4f(a+3h)++4f(bh). Each step in the loop corresponds to a given value a+nh. Odd values of n give 4 as factor while even values yield 2 as factor.
  • Multiply the final result by h3.