Stéphane,
Thanks for your solution.
I've found another solution that is even slightly faster: I've modified
the function intsplin(), changing
both instances of sum by cumsum (and some formal details), so the same
interpolator is used for the whole set of data.
Regards,
Federico Miyara
Sorry the ode call should be (y0 first, then x0)
y = ode(-1,x0,x1,list(f,x1,y1,d1))
The elapsed time seems OK:
--> tic;y = ode(-1,x0,x1,list(f,x1,y1,d1));toc
ans =
0.002235
S.
Le 11/02/2020 à 08:17, Stéphane Mottelet a écrit :
Hello,
The usual way to compute a primitive would be
Hello,
The usual way to compute a primitive would be to use ode, like this:
function out=f(x, y, x1, y1, d1)
out = interp(x,x1,y1,d1)
endfunction
x0 = 0
x1 = 0:0.01:2*%pi;
y1 = sin(x1);
d1 = splin(x1,y1);
y = ode(x0,-1,x1,list(f,x1,y1,d1))
Your proposition is very slow
Dear all,
The function integrate() is very handy to obtain a numerical primtive of
a function, particularly useful when there is no closed form for the
primitive or it is too involved. According to the documentation
x = integrate(expr, v, x0, x1 [, atol [, rtol]])
expr: a character