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
Click For Summary

Discussion Overview

The discussion revolves around implementing Simpson's Rule for numerical integration in Fortran. Participants are exploring how to programmatically apply the rule, particularly focusing on the accumulation of y-values with their corresponding multipliers.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant presents the formula for Simpson's Rule and mentions generating y-values but struggles with implementing the summation in Fortran.
  • Another participant prompts the group to identify patterns in the multipliers associated with the y-values.
  • A participant notes that, aside from the first and last y-values, odd-indexed y-values are multiplied by 4 and even-indexed ones by 2.
  • Further discussion questions how to accumulate the products of y-values and their multipliers based on the identified pattern.
  • One participant expresses difficulty in figuring out the implementation despite the hints provided.
  • A suggestion is made to use a do-loop with a variable that increases by 2 to facilitate the accumulation process.

Areas of Agreement / Disagreement

Participants appear to agree on the pattern of multipliers for y-values, but there is no consensus on how to implement the accumulation in Fortran, as some participants express confusion.

Contextual Notes

There may be limitations in the understanding of Fortran syntax and programming constructs, as well as potential missing details on how to structure the loop for the accumulation process.

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 14 ·
Replies
14
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 11 ·
Replies
11
Views
6K
  • · Replies 4 ·
Replies
4
Views
10K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K