Re: Compute area between curves [message #62934 is a reply to message #62821] |
Wed, 15 October 2008 05:05   |
jameskuyper
Messages: 79 Registered: October 2007
|
Member |
|
|
James Kuyper wrote:
> mystea wrote:
>> On Oct 14, 4:26 am, James Kuyper <jameskuy...@verizon.net> wrote:
> ...
>>> Could you give a simple example that demonstrates the problem you've
>>> seen?
>>
>> I tried "tsum" and suddenly every problem was solved!
>
> I assume you're referring to
> <http://idlastro.gsfc.nasa.gov/ftp/pro/math/tsum.pro>. tsum uses the
> trapezoidal rule, which is the two-point Newton-Cotes formula;
> INT_TABULATED uses the five-point formula. The higher-order formula
> gives you more accurate results, so long as the data is tabulated at
> sufficiently close intervals so that is it relatively smooth over any 5
> consecutive data points. The lower order formula gives less accurate
> results, but is more robust with respect to the errors that can be
> created when the tabulated function isn't tabulated sufficiently
> closely. This is the typical trade-off you get when comparing
> higher-order numerical methods with lower-order ones.
I can be more specific about this. According to
<http://en.wikipedia.org/wiki/Newton%E2%80%93Cotes_formulas>, the error
terms are
trapezoidal (two-point) rule: -(h^3/12) *f2(zeta)
Boole's (five-point) rule: -(8*h^7/945)*f6(zeta)
where 'h' is the spacing of the data, f2(zeta) is the second derivative
of the function being integrated, evaluated at some unspecified location
in the range of integration, and f6(zeta) is the sixth derivative,
evaluated at some unspecified and probably different location in the
range of integration.
Therefore, if f2_max is the maximum value of the magnitude of the second
derivative over the range of integration, and f6_max is the same thing
for the sixth derivative, then it is better to use TSUM if
h > (315*f2_max/(32*f6_max))^0.25
if h is less than that limiting value, you'll get better results with
INT_TABULATED.
|
|
|