[Scilab-users] Certain operations are not expressed as floating point

Federico Miyara fmiyara at fceia.unr.edu.ar
Thu Feb 6 08:30:57 CET 2020


Dear all,

Trying to implement sine integral from the series, my first attempt

         y = 0
         N = 30;
         for n=0:N
             y = y + (-1)^n * x.^(2*n+1)./(2*n+1)./factorial(2*n+1);
         end

works fine for x<20. Now I want to vectorize it so the plan is to create 
a polynomial and then apply horner. The coefficients are

coe = (-1).^(0:N)./(1:2:2*N+1)./factorial(1:2:2*N+1)

I get

coe  =

          column 1 to 6

    1.  -0.055555555556   0.001666666667  -0.000028344671 
0.000000306192  -0.000000002277

          column 7 to 19

    0.000000000012  -5.09810915D-14   1.65379838D-16   0.   0.   0. 0.   
0.   0.   0.   0.   0.   0.

          column 20 to 31

    0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.

 From the 10-th coefficient on, the value seems to be 0. However, 
coe(10) yields  9.32044813D-22

Actually this is a documented behavior (it is described in hhe format 
help page). But I wonder if it is advisable, since it may be confusing.

Indeed, it took me some time to discover that the coefficients were 
stored as floating point. At the beginning I "believed" what I saw and 
started to think which would be the best order of the operations to 
avoid too small intermediate values.

Is there a reason for that behavior that outweighs the inconvenience 
I've mentioned?

Regards,

Federico Miyra


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20200206/1cd1e7a7/attachment.htm>


More information about the users mailing list