Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Simpson's rule

  1. Oct 12, 2004 #1
    Hi All
    I am hoping someone can help me out with my problem.
    I am sampling data from a flow meter every 10 seconds and storing it into a data historian. The readings are the instantaneous flow rate at the moment the data is sampled.
    My problem is that I need to work out (based on the stored samples) the total flow over a given period (say 1 day). I have been advised that simpson's rule may offer a reasonable solution for integrating the area under the curve represented by the samples over the given time span.
    Let me be frank, I am no good at math! I can find plenty of reference to simpson's rule on the web but I don't understand much of what I am reading.
    The calculation engine supplied with the data historian supports vb script, external .exe's and its own scripting language (CalcScript).
    I am hoping that some kind soul will take pity on me and help me out in understanding how to apply simpson's rule to my set of circumstances.
    Any help is greatly appreciated.

  2. jcsd
  3. Oct 23, 2004 #2
    I suppose this is too late to answer, wish i had seen this before. You don't need to use Simpson's rule to begin with. Just use rectangular rule. So if one measurement is say 9.3 gal/sec and you measure between 10 sec; 9.3gal/sec x 10sec=93 gallons, then move to next step. Next up approx is trapizoidal rule and simpson's and 3/8 simpson's then gaussian integration but rectangular rule will get there to start and maybe good enuff.
  4. Oct 23, 2004 #3


    User Avatar
    Gold Member

    I'd be curious to see how the data looks when plotted (as accurately as possible). If it's linear in most places, Simpson's rule will likely give the least accuracy compared to the improved trapezoidal or midpoint rule, however, if the data is curved (specifically quadratic or cubic) then Simpson's rule will give you an ideal result. I'm unsure about how Simpson's compares to the other Newton-Cotes approximation forumulas when it comes to nth-degree polynomials. I'd still be willing to bet that Simpson's would perform decently on polynomials greater than degree 4. We can take a look at the error bound formula for Simpson's rule and notice that the 4th derivative of any cubic polynomial will be zero, therefore, the error bound on any cubic using Simpson's rule (with no respect to iterations, only restriction they are even) will be zero, also.

    Once you get some nice data samples, you could always do some least squares analysis, and figure out which polynomial looks the best. From there, you should be able to determine which Newton-Cotes formula gives the most accuracy with respect to your data.

    Edit: Actually, I stand corrected. I don't know what I was thinking about Simpson's rule not being the most accurate for linear equations (fourth derivative is of course zero). I'll rephrase my above statements and say that other "easier and more efficient" methods may exists for your data set compared to Simpson's rule.
    Last edited: Oct 23, 2004
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?