<div dir="ltr">Hi Nicholas,<div><br></div><div>    I&#39;ll take a look as soon as time allows.  I&#39;m debugging a Newspeak issue right now.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Dec 19, 2012 at 1:34 PM, Nicolas Cellier <span dir="ltr">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
I just tried this a latest cog:<br>
<br>
(1 to: 300) collect: [:i | (10.0 raisedTo: i) sin squared + (10.0<br>
raisedTo: i) cos squared - 1 / Float epsilon]<br>
-&gt; #(1.0 -21.0 -215.0 1951.0 -825.0 164322.0 2.991826e6 ...<br>
<br>
It sounds like incredibly high errors so soon...<br>
<br>
The sine is OK:<br>
(1 to: 300) collect: [:i | (10.0 raisedTo: i) sin - ((10.0 raisedTo:<br>
i) asArbitraryPrecisionFloatNumBits: 53) sin asFloat / ((10.0<br>
raisedTo: i) asArbitraryPrecisionFloatNumBits: 53) sin asFloat ulp]<br>
-&gt;  #(-1.0 0.0 1.0 0.0 0.0 0.0 ...<br>
<br>
This is due to cosine:<br>
(1 to: 300) collect: [:i | (10.0 raisedTo: i) cos - ((10.0 raisedTo:<br>
i) asArbitraryPrecisionFloatNumBits: 53) cos asFloat / ((10.0<br>
raisedTo: i) asArbitraryPrecisionFloatNumBits: 53) cos asFloat ulp]<br>
-&gt; #(-1.0 -24.0 -383.0 -2049.0 825.0 175417.0 -3.297612e6 ...<br>
<br>
Though, MacOSX math library is very robust and accurate even for Float<br>
fmax, this one works well:<br>
<br>
#include &lt;stdio.h&gt;<br>
#include &lt;math.h&gt;<br>
int main()<br>
{<br>
    int i;<br>
    double d,y;<br>
    for(i=1;i&lt;301;i++) {<br>
        d=pow(10.0,i);<br>
        y=(cos(d)*cos(d)+sin(d)*sin(d)-1)/ldexp(1.0,-52);<br>
        printf(&quot;i=%d y=%.17f\n&quot;,i,y);<br>
    }<br>
    return 0;<br>
}<br>
<br>
$ gcc --version<br>
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)<br>
Copyright (C) 2007 Free Software Foundation, Inc.<br>
<br>
It sounds like sin is taken from one accurate library while cos is<br>
taken from an inacurrate one !!!<br>
For example it sounds like cos might well be using broken x86 fcos<br>
How can it be so?<br>
Can someone explain ?<br>
<br>
Virtual Machine<br>
---------------<br>
/Users/nicolas/Smalltalk/Squeak/Cog.app/Contents/MacOS/Croquet<br>
Croquet Closure Cog VM [CoInterpreter VMMaker.oscog-eem.238] Croquet<br>
Cog 4.0.2637<br>
Mac OS X built on Dec 17 2012 19:54:57 Compiler: 4.2.1 (Apple Inc.<br>
build 5666) (dot 3)<br>
platform sources revision VM: r2637<br>
<a href="http://www.squeakvm.org/svn/squeak/branches/Cog" target="_blank">http://www.squeakvm.org/svn/squeak/branches/Cog</a> Plugins: r2545<br>
<a href="http://squeakvm.org/svn/squeak/trunk/platforms/Cross/plugins" target="_blank">http://squeakvm.org/svn/squeak/trunk/platforms/Cross/plugins</a><br>
CoInterpreter VMMaker.oscog-eem.238 uuid:<br>
a3d10eab-6079-4c91-99f6-3dcf58d1446f Dec 17 2012<br>
StackToRegisterMappingCogit VMMaker.oscog-eem.234 uuid:<br>
66acafd1-cad0-4f20-b786-ab8f48201d82 Dec 17 2012<br>
<br>
Loaded VM Modules<br>
-----------------<br>
B2DPlugin VMMaker.oscog-eem.235 (i)<br>
BitBltPlugin VMMaker.oscog-eem.235 (i)<br>
DropPlugin VMMaker.oscog-eem.235 (i)<br>
FilePlugin VMMaker.oscog-eem.235 (i)<br>
FloatArrayPlugin VMMaker.oscog-eem.235 (e)<br>
InternetConfigPlugin VMMaker.oscog-eem.235 (i)<br>
LargeIntegers v1.5 VMMaker.oscog-eem.235 (i)<br>
Matrix2x3Plugin VMMaker.oscog-eem.235 (i)<br>
MiscPrimitivePlugin VMMaker.oscog-eem.235 (i)<br>
SecurityPlugin VMMaker.oscog-eem.235 (i)<br>
SocketPlugin VMMaker.oscog-eem.235 (i)<br>
ZipPlugin VMMaker.oscog-eem.235 (i)<br>
Same results with old VM<br>
<br>
<br>
Same result with old 4.2.5 VM !!!<br>
<br>
Virtual Machine<br>
---------------<br>
/Users/nicolas/Smalltalk/Squeak/Squeak<br>
4.2.5beta1U.app/Contents/MacOS/Squeak VM Opt<br>
Squeak4.1 of 17 April 2010 [latest update: #9957] Squeak VM 4.2.5b1<br>
Mac Carbon 4.2.5b1 15-Jun-10 &gt;85D9C693-2A2A-4C33-B05C-C20B2A63B166&lt;<br>
VMMaker versionString 4.2.4<br>
<br>
Loaded VM Modules<br>
-----------------<br>
B2DPlugin 15 June 2010 (i)<br>
BitBltPlugin 15 June 2010 (i)<br>
DropPlugin 15 June 2010 (i)<br>
FilePlugin 15 June 2010 (i)<br>
FloatArrayPlugin 15 June 2010 (i)<br>
InternetConfigPlugin 15 June 2010 (i)<br>
LargeIntegers v1.5 15 June 2010 (i)<br>
Matrix2x3Plugin 15 June 2010 (i)<br>
MiscPrimitivePlugin 15 June 2010 (i)<br>
SecurityPlugin 15 June 2010 (i)<br>
SocketPlugin 15 June 2010 (i)<br>
ZipPlugin 15 June 2010 (i)<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>
</div>