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

Converting sums to integrals

  1. Apr 10, 2012 #1
    So kind of like this thread, I'm looking to convert a discrete sum to an integral. My idea thus far has been to arrive at a function via spline interpolation. I'm doing a few different types of sums, but the first ones look like

    [tex]\displaystyle a=\sum_{i=1}^{100}{data[1]*data[4]}[/tex]

    where data is of course an two-dimensional array. So I've got a function representing data[1] and a function representing data[4]. I'm not entirely sure what to do from here, primarily because as I increase my sampling "frequency", a is going to balloon. I later do some division by another sum, so the result won't be too different than what I already have, but I'm not really sure how to proceed.
     
  2. jcsd
  3. Apr 11, 2012 #2

    mathman

    User Avatar
    Science Advisor
    Gold Member

    I am not quite sure what you are doing, but in general to convert a sum to an integral, as you are doing, you need to divide by the number of terms.

    Think in terms of the reverse process where an integral is approximated by a sum. Each term in the sum includes a Δx, which is the length of the interval of the integral divided by the number of terms in the sum.
     
  4. Apr 11, 2012 #3
  5. Apr 12, 2012 #4
    Example time!
    [tex]f(i)=5x[/tex]
    [tex]g(i)=x^2[/tex]
    [tex]\displaystyle \sum_{i=1}^{10}{f(i)g(i)}=15125[/tex]
    [tex]\displaystyle \int_{1}^{10}{{f(i)g(i)} di}=12498.8[/tex]
     
  6. Apr 12, 2012 #5

    mathman

    User Avatar
    Science Advisor
    Gold Member

    A better match would be to use 0.5 and 10.5 as the limits of integration. Since your sum has ten items, the interval for the integral has to be of length 10. The underlying assumption you are using is that Δx = 1. Δx is implicitly multiplying f(i)g(i).

    Using the limits I suggest the integral = 15193.75, obviously a lot better.
     
    Last edited: Apr 12, 2012
  7. Apr 13, 2012 #6
    So, I picked an arbitrary example, but in my real problem, I only have data within a certain range (360-830), so while I can theoretically integrate my spline interpolation from 360.5 to 830.5, it's not going to be very reliable past 830. Is there another way?
     
  8. Apr 13, 2012 #7

    mathman

    User Avatar
    Science Advisor
    Gold Member

    If you want to restrict the domain as you describe, add 1/2 of each of the two end point values to the integral. Going back to your example, you would get 15001.3.
     
  9. Apr 13, 2012 #8
    This seems to be somewhat violating the spirit of using an integral. It seems we're kind of "hacking on" some Riemann sums to our nice continuous integral in order to get it a little closer to what we'd expect. No?

    Also, my final answer via integrals (both with and without those adjustment terms) is significantly different than what I would expect from a "rough" integral (decreasing the step size in the summation and making an educated guess about where they'll end up).
     
  10. Apr 14, 2012 #9

    mathman

    User Avatar
    Science Advisor
    Gold Member

    I can't comment unless you describe what you did precisely.
     
  11. Apr 15, 2012 #10
    Alright, let's go from example problem to the real problem. No point in coming up with increasingly complex examples.



    So initially, I calculated my A0...C2 constants with a step size of 1, so stepping through each function at {360, 361, ..., 829, 830}. Then step sizes of .1, so {360, 360.1, ..., 829.9, 830}. Then step sizes of .01, etc. I felt that doing so will get me progressively closer to the most exact form of the answer, theoretically the form the integral will give me once I work out the quirks. Indeed, I got answers that indicated that M1 and M2 were converging to a certain value.
     
  12. Apr 15, 2012 #11

    mathman

    User Avatar
    Science Advisor
    Gold Member

    From what I can see you are trying to get an integral using the equivalent of the trapezoidal rule. (It was confusing to me previously, since I thought you were trying to do the opposite). For that purpose, I suggest that you modify the sums by using half the values for the two end terms.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Converting sums to integrals
  1. Sum and integral (Replies: 2)

Loading...