comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » replace integration by summation
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: replace integration by summation [message #84957 is a reply to message #84953] Wed, 19 June 2013 14:04 Go to previous messageGo to previous message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
OK, let's go with a simple example.

Let:
x=FINDGEN(4)
y=x^2

Your loop over INT_TABULATED will give the area under the curve for x=0->x[i]; this means

tab = FLTARR(4)
FOR i=1, 3 DO tab[i] = INT_TABULATED(x[0:i], y[0:i])

yields

print, tab
0.00000 0.500000 2.75556 9.10000

You can check these aren't quite the correct answers, *for the integration*, given the (known) underlying function, but are fairly close. The discrepancy is caused by the rather coarse grid of dx=1.

For example, the integral of x^2 between 0 and 2 (i=2) is analytically 8/3=2.67. This method is off by about 5%.

The method of using the cumulative total is *not* the area under the curve, i.e., it's not integration. In this example,

tot = total(y, /cum)*(x[1]-x[0])
print, tot
0.00000 1.00000 5.00000 14.0000

Clearly, this is not doing the same thing as integration. In this case, for i=2 you are finding the area of a rectangle 5 tics tall and 1 tics wide. This is not the same as the integration of x^2 between 0 and 2.

The underlying answer to your question is these two methods should not give the same answer - they are different operations.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: convert .dat to .fits
Next Topic: GRID3 Problems

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 00:42:13 PDT 2025

Total time taken to generate the page: 0.56118 seconds