Comp Sci Implementing Simpson's Rule in Fortran for Accurate Numerical Integration

  • Thread starter Thread starter Daniel1992
  • Start date Start date
  • Tags Tags
    Fortran
AI Thread Summary
The discussion centers on implementing Simpson's Rule for numerical integration in Fortran, specifically how to sum the y-values with their corresponding multipliers. The formula for integration is outlined, indicating the use of 100 strips. A key observation is that odd-indexed y-values are multiplied by 4, while even-indexed values (except the first and last) are multiplied by 2. Participants suggest using a do-loop that increments the loop variable by 2 to efficiently accumulate the products of y-values and their multipliers. This approach aims to simplify the implementation of Simpson's Rule in the Fortran program.
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
Well, do you notice any patterns about which y-values take which Simpsons's multipliers?
 
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.
 
Does this pattern suggest how you might go about accumulating products of the y-values and the corresponding Simpson's multipliers?
 
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 :(
 
When you write a do-loop, you can make the loop variable increase by 2 each time through the loop.
 

Similar threads

Replies
11
Views
4K
Replies
3
Views
7K
Replies
11
Views
6K
Replies
4
Views
10K
Replies
2
Views
1K
Replies
3
Views
2K
Back
Top