1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Simpson's Rule and Numerical Integration

  1. Oct 4, 2013 #1
    For this problem use Simpson's Rule with N=256 for numerical integration function is y=×^2
    and the lower limit is 1 & 3 is the upper limit.

    I=[itex]\frac{h}{3}[/itex] {fstart+fend+2Ʃfeven+4Ʃfodd}

    Find the numerical integration, using FORTRAN

    my solution follows like this:

    Program SimpsonRule


    REAL :: Xmax, Xmin,h , y

    INTEGER :: N








    DO i=1,256

    I=[itex]\frac{h}{3}[/itex] {fstart+fend+2Ʃfeven+4Ʃfodd}

    integrate y=x^2


    END DO

    END Program SimpsonRule


    I have be told that the code must have subroutine, Do statement, function and call if statement.

    my problem most start when i have to tell the computer to sum odd number and multiply by factor of 4 and sum the even number also multiply by factor of two.

    the answer for the problem is 8.66667
    Last edited: Oct 4, 2013
  2. jcsd
  3. Oct 4, 2013 #2
    the equation BELOW CONTAINS suppose to be : h=(Xmax-Xmin)/N
  4. Oct 4, 2013 #3


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Use CODE tags when entering source code to your post. This helps to preserve any spacing.

    In the Loop, you can't just throw your I eqn. from the first part of the post directly into the middle of a loop and expect Fortran to make sense of it. More programming is required to obtain the proper calculation of the integral. How is the program to know what 'fodd' and 'feven' are?
  5. Oct 4, 2013 #4
    Hi Nandos. Welcome to Physics Forums.

    I don't know what this code is that you have written, but it definitely is not FORTRAN. Have you been assigned any simpler problems to work on before you advanced to a program like this?

  6. Oct 5, 2013 #5
    This is the simpler problem that we need to work on before we do the hard problem, to make problem simple we suppose to find the integration of Y=×2 using Simpson's Rule on FORTRAN
  7. Oct 5, 2013 #6
    Are you saying that this is the first FORTRAN program you will have ever written?

  8. Oct 6, 2013 #7
    Nope it no but it the first one for integration and Simpsons rule
  9. Oct 6, 2013 #8
    So you are familiar with Dimension statements, and have used them before?
  10. Oct 7, 2013 #9
    Yes we have
  11. Oct 7, 2013 #10
    Then at least the function F should be dimensioned in your FORTRAN program. Do you know how to set up a do loop to carry out a sum on a subscripted variable?
  12. Oct 10, 2013 #11
    Nope i don't know and can you please help me.
  13. Oct 10, 2013 #12
    You need to get yourself a text book on FORTRAN and do a little studying. The information you need to do this assignment is a little to extensive for a format like PF.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted