Implementing Simpson's Rule in Fortran for Accurate Numerical Integration

  • Context: Comp Sci 
  • Thread starter Thread starter Daniel1992
  • Start date Start date
  • Tags Tags
    Fortran
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
5 replies · 4K views
Daniel1992
Messages
21
Reaction score
0
I am trying to program Simpson's Rule in Fortran

I=(1/3)*h*(y0 + 4*y1 + 2*y2 + 4*y3 + 2*y4 + ... 2*yn-2 + 4*yn-1 + yn)

n=100 (number of strips)

I have generated the y values but I don't know how to get Fortran to follow the pattern in the brackets after h to add up the y values.

Any help would be appreciated.
 
Physics news on Phys.org
SteamKing said:
Well, do you notice any patterns about which y-values take which Simpsons's multipliers?

A part from the first and last y values the odd ones are multiplied by 4 and the even are multiplied by 2.
 
SteamKing said:
Does this pattern suggest how you might go about accumulating products of the y-values and the corresponding Simpson's multipliers?

I can't work it out :(