<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
Dear all,<br>
<br>
Trying to implement sine integral from the series, my first attempt
<br>
<br>
y = 0<br>
N = 30;<br>
for n=0:N<br>
y = y + (-1)^n * x.^(2*n+1)./(2*n+1)./factorial(2*n+1);<br>
end<br>
<br>
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<br>
<br>
coe = (-1).^(0:N)./(1:2:2*N+1)./factorial(1:2:2*N+1)<br>
<br>
I get<br>
<br>
coe = <br>
<br>
column 1 to 6<br>
<br>
1. -0.055555555556 0.001666666667 -0.000028344671
0.000000306192 -0.000000002277<br>
<br>
column 7 to 19<br>
<br>
0.000000000012 -5.09810915D-14 1.65379838D-16 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.<br>
<br>
column 20 to 31<br>
<br>
0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.<br>
<br>
From the 10-th coefficient on, the value seems to be 0. However,
coe(10) yields 9.32044813D-22<br>
<br>
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.<br>
<br>
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.<br>
<br>
Is there a reason for that behavior that outweighs the inconvenience
I've mentioned? <br>
<br>
Regards,<br>
<br>
Federico Miyra<br>
<br>
<br>
<pre style="font-family:Monospaced;font-style:normal;font-size:16.0;"><span style="color:rgb(74,85,219);">
</span><span style="color:rgb(74,85,219);"></span></pre>
</body>
</html>