[Scilab-users] Command integrate() is too slow under certain expressions
Stéphane Mottelet
stephane.mottelet at utc.fr
Tue Feb 11 08:17:12 CET 2020
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 because you are recomputing the spline
many times.
S.
Le 10/02/2020 à 20:52, Federico Miyara a écrit :
>
> 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
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20200211/f9ec1129/attachment.htm>
More information about the users
mailing list