<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<font face="Courier New">Stéphane,<br>
<br>
Thanks. I think I get the idea: log(1+x) allows values much closer
to 1 than possible with log(x) because x could fall down way below
%eps, since the full folating point range for small values would
be available (about 1e-323). <br>
<br>
But then the same would be true for any function that happens to
be 0 at some point, such as cos(x) at %pi/2, or besselj(x) at any
of its zeros.<br>
<br>
Besides, for any value for which log1p() is relevant (in the sense
that it would differ from an optimized log(x) that is accurate up
to 1 + %eps or so) probably log1p(x) wouldn't differ from x, since
the next digit, corresponding to the x^2 Taylor term cannot fit in
the mantissa of a double different from x.<br>
<br>
For instance (as per Wolfram Alpha site --truncated),<br>
<br>
log(1 + 1e-16) =
9.99999999999999950000000000000003333333333333333083333333333333353333333333333331...
× 10^-17<br>
<br>
Attempting to represent this with double, it yields
0.0000000000000001<br>
<br>
No difference from 1e-16 since the next different digit would
produce a difference below %eps.<br>
<br>
log1p() would make sense in case the result could be given with
extended precision<br>
<br>
Regards,<br>
<br>
Federico Miyara <br>
<br>
<br>
</font><br>
<div class="moz-cite-prefix">On 03/05/2020 05:41, Stéphane Mottelet
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:2F47E992-1350-4F24-9DE8-240B92817F5F@utc.fr">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">Hi Fredrico,</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">See the discussion @</div>
<div dir="ltr"><br>
</div>
<div dir="ltr"><a
href="https://stackoverflow.com/questions/52736011/instruction-fyl2xp1"
moz-do-not-send="true">https://stackoverflow.com/questions/52736011/instruction-fyl2xp1</a></div>
<div dir="ltr"><br>
</div>
<div dir="ltr">here is a relevant excerpt: </div>
<div dir="ltr"><br>
</div>
<div dir="ltr"><span style="caret-color: rgb(104, 108, 110);
color: rgb(104, 108, 110); font-family: "Helvetica
Neue", Helvetica, Arial, sans-serif; font-size: 12px;
-webkit-text-size-adjust: 100%; background-color: rgb(250,
250, 251);">The Taylor series for </span><code
style="box-sizing: inherit; margin: 0px 1px; padding: 0px 2px;
border: 0px; font-family: Consolas, Menlo, Monaco,
"Lucida Console", "Liberation Mono",
"DejaVu Sans Mono", "Bitstream Vera Sans
Mono", "Courier New", monospace, sans-serif;
font-stretch: inherit; line-height: inherit; font-size: 11px;
vertical-align: baseline; word-break: break-all;
background-color: rgba(0, 0, 0, 0.0745098); display:
inline-block; caret-color: rgb(104, 108, 110); color: rgb(104,
108, 110); -webkit-text-size-adjust: 100%;">log(x)</code><span
style="caret-color: rgb(104, 108, 110); color: rgb(104, 108,
110); font-family: "Helvetica Neue", Helvetica,
Arial, sans-serif; font-size: 12px; -webkit-text-size-adjust:
100%; background-color: rgb(250, 250, 251);"> is usually done
about </span><code style="box-sizing: inherit; margin: 0px
1px; padding: 0px 2px; border: 0px; font-family: Consolas,
Menlo, Monaco, "Lucida Console", "Liberation
Mono", "DejaVu Sans Mono", "Bitstream Vera
Sans Mono", "Courier New", monospace,
sans-serif; font-stretch: inherit; line-height: inherit;
font-size: 11px; vertical-align: baseline; word-break:
break-all; background-color: rgba(0, 0, 0, 0.0745098);
display: inline-block; caret-color: rgb(104, 108, 110); color:
rgb(104, 108, 110); -webkit-text-size-adjust: 100%;">x = 1</code><span
style="caret-color: rgb(104, 108, 110); color: rgb(104, 108,
110); font-family: "Helvetica Neue", Helvetica,
Arial, sans-serif; font-size: 12px; -webkit-text-size-adjust:
100%; background-color: rgb(250, 250, 251);">. So every term
will have </span><code style="box-sizing: inherit; margin: 0px
1px; padding: 0px 2px; border: 0px; font-family: Consolas,
Menlo, Monaco, "Lucida Console", "Liberation
Mono", "DejaVu Sans Mono", "Bitstream Vera
Sans Mono", "Courier New", monospace,
sans-serif; font-stretch: inherit; line-height: inherit;
font-size: 11px; vertical-align: baseline; word-break:
break-all; background-color: rgba(0, 0, 0, 0.0745098);
display: inline-block; caret-color: rgb(104, 108, 110); color:
rgb(104, 108, 110); -webkit-text-size-adjust: 100%;">x - 1</code><span
style="caret-color: rgb(104, 108, 110); color: rgb(104, 108,
110); font-family: "Helvetica Neue", Helvetica,
Arial, sans-serif; font-size: 12px; -webkit-text-size-adjust:
100%; background-color: rgb(250, 250, 251);">. If you're
trying to compute </span><code style="box-sizing: inherit;
margin: 0px 1px; padding: 0px 2px; border: 0px; font-family:
Consolas, Menlo, Monaco, "Lucida Console",
"Liberation Mono", "DejaVu Sans Mono",
"Bitstream Vera Sans Mono", "Courier New",
monospace, sans-serif; font-stretch: inherit; line-height:
inherit; font-size: 11px; vertical-align: baseline;
word-break: break-all; background-color: rgba(0, 0, 0,
0.0745098); display: inline-block; caret-color: rgb(104, 108,
110); color: rgb(104, 108, 110); -webkit-text-size-adjust:
100%;">log(x + 1)</code><span style="caret-color: rgb(104,
108, 110); color: rgb(104, 108, 110); font-family:
"Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 12px; -webkit-text-size-adjust: 100%;
background-color: rgb(250, 250, 251);"> for a very small </span><code
style="box-sizing: inherit; margin: 0px 1px; padding: 0px 2px;
border: 0px; font-family: Consolas, Menlo, Monaco,
"Lucida Console", "Liberation Mono",
"DejaVu Sans Mono", "Bitstream Vera Sans
Mono", "Courier New", monospace, sans-serif;
font-stretch: inherit; line-height: inherit; font-size: 11px;
vertical-align: baseline; word-break: break-all;
background-color: rgba(0, 0, 0, 0.0745098); display:
inline-block; caret-color: rgb(104, 108, 110); color: rgb(104,
108, 110); -webkit-text-size-adjust: 100%;">x</code><span
style="caret-color: rgb(104, 108, 110); color: rgb(104, 108,
110); font-family: "Helvetica Neue", Helvetica,
Arial, sans-serif; font-size: 12px; -webkit-text-size-adjust:
100%; background-color: rgb(250, 250, 251);">, a direct call
as </span><code style="box-sizing: inherit; margin: 0px 1px;
padding: 0px 2px; border: 0px; font-family: Consolas, Menlo,
Monaco, "Lucida Console", "Liberation
Mono", "DejaVu Sans Mono", "Bitstream Vera
Sans Mono", "Courier New", monospace,
sans-serif; font-stretch: inherit; line-height: inherit;
font-size: 11px; vertical-align: baseline; word-break:
break-all; background-color: rgba(0, 0, 0, 0.0745098);
display: inline-block; caret-color: rgb(104, 108, 110); color:
rgb(104, 108, 110); -webkit-text-size-adjust: 100%;">log(x +
1)</code><span style="caret-color: rgb(104, 108, 110); color:
rgb(104, 108, 110); font-family: "Helvetica Neue",
Helvetica, Arial, sans-serif; font-size: 12px;
-webkit-text-size-adjust: 100%; background-color: rgb(250,
250, 251);"> will result in </span><code style="box-sizing:
inherit; margin: 0px 1px; padding: 0px 2px; border: 0px;
font-family: Consolas, Menlo, Monaco, "Lucida
Console", "Liberation Mono", "DejaVu Sans
Mono", "Bitstream Vera Sans Mono",
"Courier New", monospace, sans-serif; font-stretch:
inherit; line-height: inherit; font-size: 11px;
vertical-align: baseline; word-break: break-all;
background-color: rgba(0, 0, 0, 0.0745098); display:
inline-block; caret-color: rgb(104, 108, 110); color: rgb(104,
108, 110); -webkit-text-size-adjust: 100%;">x + 1 - 1</code><span
style="caret-color: rgb(104, 108, 110); color: rgb(104, 108,
110); font-family: "Helvetica Neue", Helvetica,
Arial, sans-serif; font-size: 12px; -webkit-text-size-adjust:
100%; background-color: rgb(250, 250, 251);"> which will drop
all the low-order bits of </span><code style="box-sizing:
inherit; margin: 0px 1px; padding: 0px 2px; border: 0px;
font-family: Consolas, Menlo, Monaco, "Lucida
Console", "Liberation Mono", "DejaVu Sans
Mono", "Bitstream Vera Sans Mono",
"Courier New", monospace, sans-serif; font-stretch:
inherit; line-height: inherit; font-size: 11px;
vertical-align: baseline; word-break: break-all;
background-color: rgba(0, 0, 0, 0.0745098); display:
inline-block; caret-color: rgb(104, 108, 110); color: rgb(104,
108, 110); -webkit-text-size-adjust: 100%;">x</code><span
style="caret-color: rgb(104, 108, 110); color: rgb(104, 108,
110); font-family: "Helvetica Neue", Helvetica,
Arial, sans-serif; font-size: 12px; -webkit-text-size-adjust:
100%; background-color: rgb(250, 250, 251);"> - thereby losing
precision if </span><code style="box-sizing: inherit; margin:
0px 1px; padding: 0px 2px; border: 0px; font-family: Consolas,
Menlo, Monaco, "Lucida Console", "Liberation
Mono", "DejaVu Sans Mono", "Bitstream Vera
Sans Mono", "Courier New", monospace,
sans-serif; font-stretch: inherit; line-height: inherit;
font-size: 11px; vertical-align: baseline; word-break:
break-all; background-color: rgba(0, 0, 0, 0.0745098);
display: inline-block; caret-color: rgb(104, 108, 110); color:
rgb(104, 108, 110); -webkit-text-size-adjust: 100%;">x</code><span
style="caret-color: rgb(104, 108, 110); color: rgb(104, 108,
110); font-family: "Helvetica Neue", Helvetica,
Arial, sans-serif; font-size: 12px; -webkit-text-size-adjust:
100%; background-color: rgb(250, 250, 251);"> is really small.
A built-in </span><code style="box-sizing: inherit; margin:
0px 1px; padding: 0px 2px; border: 0px; font-family: Consolas,
Menlo, Monaco, "Lucida Console", "Liberation
Mono", "DejaVu Sans Mono", "Bitstream Vera
Sans Mono", "Courier New", monospace,
sans-serif; font-stretch: inherit; line-height: inherit;
font-size: 11px; vertical-align: baseline; word-break:
break-all; background-color: rgba(0, 0, 0, 0.0745098);
display: inline-block; caret-color: rgb(104, 108, 110); color:
rgb(104, 108, 110); -webkit-text-size-adjust: 100%;">log(x+1)</code><span
style="caret-color: rgb(104, 108, 110); color: rgb(104, 108,
110); font-family: "Helvetica Neue", Helvetica,
Arial, sans-serif; font-size: 12px; -webkit-text-size-adjust:
100%; background-color: rgb(250, 250, 251);">can then elide
this </span><code style="box-sizing: inherit; margin: 0px 1px;
padding: 0px 2px; border: 0px; font-family: Consolas, Menlo,
Monaco, "Lucida Console", "Liberation
Mono", "DejaVu Sans Mono", "Bitstream Vera
Sans Mono", "Courier New", monospace,
sans-serif; font-stretch: inherit; line-height: inherit;
font-size: 11px; vertical-align: baseline; word-break:
break-all; background-color: rgba(0, 0, 0, 0.0745098);
display: inline-block; caret-color: rgb(104, 108, 110); color:
rgb(104, 108, 110); -webkit-text-size-adjust: 100%;">x + 1 - 1</code><span
style="caret-color: rgb(104, 108, 110); color: rgb(104, 108,
110); font-family: "Helvetica Neue", Helvetica,
Arial, sans-serif; font-size: 12px; -webkit-text-size-adjust:
100%; background-color: rgb(250, 250, 251);"> step and
preserve the full precision</span></div>
<div dir="ltr"><br>
<br>
<blockquote type="cite">Le 3 mai 2020 à 08:52, Federico Miyara
<a class="moz-txt-link-rfc2396E" href="mailto:fmiyara@fceia.unr.edu.ar"><fmiyara@fceia.unr.edu.ar></a> a écrit :<br>
<br>
</blockquote>
</div>
<blockquote type="cite">
<div dir="ltr">
<meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<font face="Courier New"><br>
Dear all,<br>
<br>
I was comparing the accuracy of FFT and two exact formulas
for the FFT of a complex exponential and I was first
surprised by a relative accuracy of only 10^-13 for N =
4096, but on second thought it may be related to arithmetic
errors due to about N*log2(N) sums and products. <br>
<br>
But I was much more surprised to detect similar errors
between different exact formulas. These formulas involve a
few instances of exponentials so I conjectured that the
problem may be related to the exponential accuracy. When
trying to find some information</font><font face="Courier
New"> about accuracy</font><font face="Courier New"> in the
documentation I found none. <br>
<br>
The only mention in the elementary function set to accuracy
appears in log1p(), a strange function equal to log(1+x),
which is seemingly included to fix some accuracy problem of
the natural logarithm very close to 1. Intuition suggests
that near 1 the Taylor approximation for log(1+x) should
work very well. I guess that is what log1p() does, so I
wonder why a function such as log1p is really necessary. It
seems more reasonable to internally detect the favorable
situation and switch the algorithm to get the maximum
attainable accuracy. So if one needs an accurate log(1+x)
function, one would</font><font face="Courier New"> just</font><font
face="Courier New"> type log(1+x)!<br>
<br>
But regardless of this discusion, I think it would very
useful some hints about accuracy in the help pages of
elementary and other functions.<br>
<br>
For instance, with format(25)<br>
<br>
--> exp(10) <br>
ans =<br>
22026.4657948067<u>1</u>7894971<br>
<br>
while the Windows calculator (which is generally accurate to
the last shown digit) yields<br>
<br>
22026.4657948067<u>1</u>6516957900645284<br>
<br>
The underlined digits are the least significant ones common
to both solutions. Scilab shows up to 25 digits, but only
the first 16 of them are accurate.<br>
<br>
Regards, <br>
<br>
Federico Miyara<br>
<br>
</font> <span>_______________________________________________</span><br>
<span>users mailing list</span><br>
<span><a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a></span><br>
<span><a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users">https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users</a></span><br>
</div>
</blockquote>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
</body>
</html>