Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: precise numerical integration
Date: Fri, 4 Jun 2010 01:54:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 18
Message-ID: <hu9mbs$jvq$1@fred.mathworks.com>
References: <hu9gb8$dvg$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1275616444 20474 172.30.248.37 (4 Jun 2010 01:54:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 4 Jun 2010 01:54:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:642063

"Marcio Barbalho" <marciobarbalho@live.com> wrote in message <hu9gb8$dvg$1@fred.mathworks.com>...
> Hello dear friends...
> 
> I would to know if you know any other numerical integration method besides 'trapz' given x an y vectors:
> 
> Area = trapz(x,y)
> 
> my data are kind of randomic and I have obtained areas that are not so precise, numbers are not matching...So I was wondering if you could give some help on increasing the performance of matlab's numerical integrators.
> 
> Many thanks

  It all depends on what you mean by "randomic".  As Urs says, there is no magic wand to make good data out of bad.  If your data is bad because it is noisy, then trapz results are about as good as you are going to get.

  On the other hand if your data is comparatively free of noise and is accurately obtained from a function which is smoothly varying, meaning that it's higher derivatives are not excessively large, then there is hope for better accuracy from higher order integration methods.

  There are a number of these in the file exchange, including one I wrote which does cubic type approximation, but they all require that the discrete data be derived from smooth functions.  Mine approximates the integral over each interval using the two endpoints of the interval and two other points at the ends of the two adjacent intervals.  It computes the integral a cubic polynomial would have over the central interval if it runs through all four points.  However the size of the inevitable error it makes depends on how large the underlying function's fourth derivative is, based on the mean value theorem of calculus.  For trapz the mean value theorem expresses the error in terms of its second derivative.

Roger Stafford