Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Problem
Date: Thu, 6 May 2010 15:47:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 11
Message-ID: <hruo9p$ocp$1@fred.mathworks.com>
References: <hrqe77$jcs$1@fred.mathworks.com> <1317322228.78895.1273096933766.JavaMail.root@gallium.mathforum.org> <c29d4c47-5dad-44ea-879c-f3e5c682148d@o8g2000yqo.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1273160825 24985 172.30.248.35 (6 May 2010 15:47:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 6 May 2010 15:47:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:633196

TideMan <mulgor@gmail.com> wrote in message <c29d4c47-5dad-44ea-879c-f3e5c682148d@o8g2000yqo.googlegroups.com>...
> But Roger, doesn't your fancy algorithm reduce to central finite
> differences if the x are equispaced:
> dydx(2:end-1)=(y(3:end) - y(1:end-2))/(2*dx);
> without the pretty stuff at the ends of course.

  Yes, of course, for equally-spaced x values.  In that case one can obtain the same answers from the single-dimensional version of the 'gradient' function except for the endpoints, which are not properly done in my opinion.

  For variable-spaced x's the 'gradient' function does not use weighted averages, so it is not actually a second order approximation in that circumstance.  That is, it does not get exact derivatives for quadratic functions if the x intervals are variable - at least not in my version.

Roger Stafford