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: Sat, 3 Dec 2011 02:51:18 -0800 (PST)

Those replies helped.

Here is my version of the the central difference algorithm along with a sum
statement for integrating.  

n = 100000; # Number of data points
p = 0.005;   # Time period
a = 5;    # Just a variable parameter
h = p ./ n;  # dt
g = h ./ 2;  # dt/2 for my version of central diff

t = linspace(0, p , n);

f = ( (a .+ sin(1256 .* (t .+ g))) .- (a .+ sin(1256 .* (t .- g))) ) ./ h;
 
s = sum(h .* (f(1:end-1) .+ f(2:end)) ./ 2)


Nifty, and quick too.  Although with a million data points it gave octave a
bit of a pause, a bit more then a second on my machine.  Accuracy seemed
sufficient at 100,000 data points.

Although I would figure this should sum to zero.  It seems to be providing
only three significant digits of of accuracy.  That would be the minimum I
could use.  I would prefer at least 4 and 6 would be comforting.  I'll have
to study up on some err management.

The functions for my model are significantly more involved, and there are
three of them, each of which  needs to be differentiated then integrated,
along with some additional calculations which are just basic stuff.

My guess is that octave would be noticably slow then a compiled program. 
The c program does all three functions even with 1 million data points each
as fast as I can release the return key.  :)

Now if I can just get it to give a proper answer...

Maybe I'll end up using octave anyway, now I know how to do that.  

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


reply via email to

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