help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Numerical Differentiation and Integration of Array Data


From: syberraith
Subject: Re: Numerical Differentiation and Integration of Array Data
Date: Sun, 4 Dec 2011 14:36:16 -0800 (PST)

Actually, I think my central difference algorithm is providing more realistic
answers than Octave's diff function in this case:

n = 400
p = (2 * pi)/200;
h = p / (n-1);
g = h / 2;

function y = f ( x ) 
   y = sin( 200 * x );
endfunction

t = linspace(0 - g, p + g, n + 1);
a = (f(t+g) - f(t-g))/h;
a = h.*(a(1:end-1) + a(2:end))./2;

#t = linspace(0, p, n);
#a = diff(f(t))/h;

s1 = sum(a.*h)
s2 = f(p) - f(0)
ds = s1 - s2  

n = 400
p = (2 * pi)/200;
h = p / (n-1);
g = h / 2;

n = 400
s1 =  1.2398e-06
s2 =  6.4326e-16
ds =  1.2398e-06

Or, am I still missing something?

--
View this message in context: 
http://octave.1599824.n4.nabble.com/Numerical-Differentiation-and-Integration-of-Array-Data-tp4145498p4158445.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]