1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Simpsons Rule in FORTRAN

  1. Feb 1, 2013 #1
    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.
     
  2. jcsd
  3. Feb 1, 2013 #2

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Well, do you notice any patterns about which y-values take which Simpsons's multipliers?
     
  4. Feb 1, 2013 #3
    A part from the first and last y values the odd ones are multiplied by 4 and the even are multiplied by 2.
     
  5. Feb 1, 2013 #4

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Does this pattern suggest how you might go about accumulating products of the y-values and the corresponding Simpson's multipliers?
     
  6. Feb 3, 2013 #5
    I can't work it out :(
     
  7. Feb 4, 2013 #6

    Redbelly98

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    When you write a do-loop, you can make the loop variable increase by 2 each time through the loop.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Simpsons Rule in FORTRAN
  1. Fortran code (Replies: 1)

  2. Searching on Fortran (Replies: 13)

Loading...