Calculating pi using Riemann Sum and Fortran77

Click For Summary

Discussion Overview

The discussion revolves around calculating pi using a Riemann Sum with a specific function and bounds, particularly focusing on implementing this calculation in Fortran77. The scope includes programming assistance, mathematical concepts, and integration techniques.

Discussion Character

  • Homework-related
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • One participant presents an assignment to calculate pi using a Riemann Sum with n=40,000,000 and the function 4/(1+x^2) over the interval from 0 to 1.
  • Another participant suggests that the problem should be posted in a dedicated homework section and provides guidance on finding the antiderivative of the function.
  • A participant expresses understanding of the calculus involved but requests help specifically with programming in Fortran.
  • There are inquiries about the participant's background in Fortran and suggestions to show any written code to identify issues.
  • One participant indicates a lack of programming experience and questions the necessity of using Fortran77 over other programming languages.
  • Another participant proposes using Excel as an alternative to programming for obtaining results.

Areas of Agreement / Disagreement

Participants generally agree on the mathematical approach to calculating pi, but there is disagreement regarding the choice of programming language and the necessity of programming skills for the assignment.

Contextual Notes

Some participants express uncertainty about the requirement for Fortran77 and suggest alternative programming languages or tools, indicating a lack of consensus on the best approach to complete the assignment.

Who May Find This Useful

This discussion may be useful for students seeking to understand Riemann Sums, integration techniques, and programming in Fortran77, as well as those exploring alternative methods for numerical calculations.

ncp1044
Messages
8
Reaction score
0
My assignment: Solve for pi using a Riemann Sum with n= 40,000,000. The function is the antiderivate of 4/(1+x^2) dx. The bounds are from 0 to 1. Solving this gives you pi.

Anyone know how to do this? Preferably with fortran77?
 
Physics news on Phys.org
A priori, homework and assignment question should be posted in the appropriate section, namely:
https://www.physicsforums.com/forumdisplay.php?f=158

Having said that, I'll look at your problem in that light. You will work out the function whose derivative is 4/(1+x^2). You do this by integration, and alternatively, it is a standard function that you can look up in references.
If you are not sure if this is correct, post your finding and we will be glad to confirm it.

You can find out about the Riemann Sum by googling just that. If you still do not understand what it is, post again.

The program in Fortran is basically a summation process with evaluation of the derivative (4/(1+x^2) at given intervals. The sum, if done correctly, should be your estimate of pi.
 
I understand the calculus part of the problem; I just need help with the programming part. I can do the differentiation and I know how to do a Riemann Sum by hand, assuming that the number of intervals is small. I'm no good at programming so if anyone knows, some help would be appreciated.
 
Did you take a Fortran course, or is this assignment part of the course?
Can you show us a few lines you wrote, and try to compile it. This way, we can see where your problem lies, if there is any?

Typically, you would write the main program just as the way you would do your calculations by hand. Define a variable called sum and set it to zero. Decide on the number of sub-intervals, call it ni. Calculate the values of the function (1/(1+x^2) from 0 to 1 using the appropriate multiplication factors.
 
I haven't even tried to write the program yet because I don't know anything about programming. I have yet to take a programming course.
 
I haven't even tried to write the program yet because I don't know anything about programming. I have yet to take a programming course.
In that case, two questions come to light.
1. Is Fortran 77 a language requirement prescribed by someone? Why not C, C++, VB.net, Perl, C# or Java?
2. If it is the answer/result that is essential, could you try using Excel, which will give you an answer without programming at all?
 

Similar threads

  • · Replies 14 ·
Replies
14
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 15 ·
Replies
15
Views
6K
  • · Replies 2 ·
Replies
2
Views
7K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K