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 03:15:06 -0800 (PST)

Actually I kind of understand what your saying.  I've been playing with this:

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

function y = f ( x ) 
   y = sin( 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;

u = linspace(0, p, n);
s = sum(a.*h)
s1 = a(end) - a(1)
#plot(u, a,"-1")

The more data points I used the closer s got to s1.  My last try was with
100,000,000 data points.  That overwhelm my machine.  All though at
10,000,000 data points s was x.xxe-13 and s1 was x.xxe-17 so they were on
the way to converging.  Now I have to figure out just how much accuracy do I
need, or can s1 just do by itself. 

I think now the behavior of the c program is OK.  What it is showing is just
s approaching s1.

I also fixed my central difference algorithm so that it minimizes funcion
calls, it now does half the calls it originally did.  Nifty stuff.   

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


reply via email to

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