[Scilab-users] Command integrate() is too slow under certain expressions
Federico Miyara
fmiyara at fceia.unr.edu.ar
Mon Feb 10 20:52:05 CET 2020
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 string defining a Scilab expression.
v: a character string, the integration variable name
However there is a case that would be interesting to handle, and it is
when one has a set of experimental (or simulated) data xk, yk. Here
there is no expression defining a function.
One way to circumvent this is using as the expression some sort of
interpolator such as
x = integrate("interp1(xk, yk, x, ''spline'')", "x", x0, x1)
This works, but for some reason I don't quite understand it is very slow.
For instance,
x0 = 0
x1 = 0:0.01:2*%pi;
y1 = sin(x1);
tic
X = integrate("interp1(x1, y1, x, ''spline'')", "x", x0, x1);
toc
Requires 27 s to execute. In the meantime, control is seemingly returned
to the console, one can enter instructions, but then the program freezes
until the integrate comand finishes.
Changing "spline" to "linear" even worsens it rising to 33 s.
Has anybody an idea of what can be happening?
Maybe it computes the full interpolator for each single point? Even if
so, I have only 629 values of the independent variable.
Regards,
Federico Miyara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20200210/b3084679/attachment.htm>
More information about the users
mailing list