How to Compute an Integral Using FORTRAN?

In summary, the conversation discusses the use of composite rectangle method, trapezoidal rule, and Simpson's rule to compute an unknown integral. The table of results for f(x) and x is provided, along with a question about the approach to the problem in FORTRAN. The conversation also mentions the need for the user to select the method of approximation and discusses potential issues with using a step size of 0.4. It is suggested to use the composite trapezoidal rule for a step size of 0.3 and to consider using Simpson's rule for a step size of 0.6.
  • #1
Chris Red
1
0
Thread moved from a technical section, so is missing the homework template
I have a question set for programming to compute integral for the following unknown function using composite rectangle method, trapezoidal rule and simpsons rule.

[tex]\int_{0}^{1.8} f(x) dx[/tex]

for h=0.3 and h=0.4

I have a table of results for f(x) and x as follows
x=0, 0.3, 0.6, 0.9, 0.12, 0.15, 0.18
f(x)=0.5, 0.6, 0.8, 1.3, 2, 3.2, 4.8

My interval is 6 using the formula n=1.8-0/0.3 for the first case. I am just wondering how I should approach this problem in my programming.

For the rectangle method does anyone have a step by step guide of how this would be done analytically. Surely this would also require the user to enter all values for f(x) too or they be read from a file in some way? I am mainly struggling because I am not sure how to implement this into my program which is in FORTRAN. I have not even thought about how to tackle the trapezoidal or simpson rule yet! Ideally they should be all within one program where the user selects the method of approximation.

Thanks for any advice
 
Physics news on Phys.org
  • #2
Chris Red said:
I have a question set for programming to compute integral for the following unknown function using composite rectangle method, trapezoidal rule and simpsons rule.
I don't know the composite rectangle method. I'm familiar with using rectangles, where you use either the left endpoint of each subinterval or the right endpoint.
Chris Red said:
[tex]\int_{0}^{1.8} f(x) dx[/tex]

for h=0.3 and h=0.4

I have a table of results for f(x) and x as follows
x=0, 0.3, 0.6, 0.9, 0.12, 0.15, 0.18
f(x)=0.5, 0.6, 0.8, 1.3, 2, 3.2, 4.8
Are you also given a table of results for h = 0.4? Also, a stepsize of 0.4 is problematic, since 0.4 doesn't divide 1.8 evenly.
Chris Red said:
My interval is 6
No, the number of subintervals is 6.
Chris Red said:
using the formula n=1.8-0/0.3 for the first case. I am just wondering how I should approach this problem in my programming.
The right side of your formula should be written as (1.8 - 0)/0.3. Otherwise, due to the order of operations, what you wrote is 1.8 - (0/0.3) = 1.8.
Chris Red said:
For the rectangle method does anyone have a step by step guide of how this would be done analytically.
?
Are you asking how you should do the calculations? The term analytically implies the opposite of integrating numerically; i.e., by finding the antiderivative of your function and evaluating it at the two endpoints.
Chris Red said:
Surely this would also require the user to enter all values for f(x) too or they be read from a file in some way? I am mainly struggling because I am not sure how to implement this into my program which is in FORTRAN. I have not even thought about how to tackle the trapezoidal or simpson rule yet! Ideally they should be all within one program where the user selects the method of approximation.

Thanks for any advice
 
  • #3
For ##h = 0.3##.

You should numerically estimate the integral using the composite trapezoidal rule. This will give you a good idea of the the correct answer at first.

Then, you should notice that the step size causes there to be an even number of segments (6) and an odd number of data points (7). This tells you that a Simpson's 1/3 approach would be most appropriate.

Write functions in FORTRAN that return the values for the respective methods (trapezoidal/Simpson's).

For ##h = 0.4##.

There is a serious problem. You can't even numerically estimate the integral with the composite trapezoidal rule using unequal step sizes for each segment. This is because the step size makes your data obsolete.

A step size of ##0.6## would prove more interesting.
 

FAQ: How to Compute an Integral Using FORTRAN?

1. What is Computing Integral Programming?

Computing Integral Programming is a mathematical optimization technique used to find the best possible solution to a given problem by finding the optimal way to allocate limited resources.

2. How does Computing Integral Programming work?

Computing Integral Programming involves breaking a problem down into smaller parts, assigning variables and constraints, and then using mathematical algorithms to find the best possible solution.

3. What types of problems can be solved using Computing Integral Programming?

Computing Integral Programming can be used to solve problems with limited resources, such as production scheduling, resource allocation, network optimization, and many more.

4. What are the benefits of using Computing Integral Programming?

Computing Integral Programming can provide optimal solutions to complex problems, increase efficiency, reduce costs, and improve decision-making processes.

5. What are some common algorithms used in Computing Integral Programming?

Common algorithms used in Computing Integral Programming include the simplex method, the branch and bound method, and the interior point method. These algorithms help to find the best possible solution efficiently.

Similar threads

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