Simpsons Rule in FORTRAN

  • Comp Sci
  • Thread starter Daniel1992
  • Start date
  • #1
22
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.
 

Answers and Replies

  • #2
SteamKing
Staff Emeritus
Science Advisor
Homework Helper
12,796
1,667
Well, do you notice any patterns about which y-values take which Simpsons's multipliers?
 
  • #3
22
0
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.
 
  • #4
SteamKing
Staff Emeritus
Science Advisor
Homework Helper
12,796
1,667
Does this pattern suggest how you might go about accumulating products of the y-values and the corresponding Simpson's multipliers?
 
  • #5
22
0
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 :(
 
  • #6
Redbelly98
Staff Emeritus
Science Advisor
Homework Helper
Insights Author
12,102
130
When you write a do-loop, you can make the loop variable increase by 2 each time through the loop.
 

Related Threads on Simpsons Rule in FORTRAN

Replies
11
Views
3K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
5
Views
803
Replies
2
Views
8K
Replies
1
Views
1K
Replies
4
Views
620
  • Last Post
Replies
1
Views
2K
Replies
1
Views
964
Replies
12
Views
902
  • Last Post
Replies
9
Views
7K
Top