<div dir="auto">Hi all,<div dir="auto">No time to answer to the whole thread now...</div><div dir="auto">FYI, Eliot has resurrected fdlibm math library for Terf, so we should benefit from platform independent results and faithfully rounded results soon... It's not perfect, but it's good enough.</div><div dir="auto"><br></div><div dir="auto">For ratio:/residue: I agree, i fall short of vocabulary... It would be named remainder: and quotient: to ressemble iso names, but proximity to quo/rem disqualified this choice.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mar. 26 mai 2020 à 04:45, Andres Valloud via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st">cuis-dev@lists.cuis.st</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yeah, it's bad.  For example,<br>
<br>
        Float halfPi successor cos<br>
<br>
is positive, and therefore (since there's no tan primitive either)<br>
<br>
        Float halfPi successor tan<br>
<br>
is positive.  Sample C programs produce sensible output instead.<br>
<br>
Some experiments show that doing argument reduction towards zero <br>
minimizes error.  However, this is just a hack that illustrates the <br>
brittleness of the system: improving the argument reduction for cos <br>
causes the arcTan test to never finish because its iteration no longer <br>
converges.  This shows the poor behavior of cos is baked in already.<br>
<br>
On the one hand, who cares about a few ulps, right?  On the other hand, <br>
whoever is careless with the truth in small matters cannot be trusted <br>
with important matters.<br>
<br>
Short of reimplementing a math library from scratch, the best way to do <br>
transcendentals is with primitives that call the platform libraries <br>
everyone else uses.  Doing this properly should not be hard.<br>
<br>
On 5/25/20 16:35, Andres Valloud via Cuis-dev wrote:<br>
> Hi,<br>
> <br>
>> It is also the implementation in Cuis :( . I guess we need a new <br>
>> primitive right? Maybe some simple math trick could give us the <br>
>> correct result?<br>
> <br>
> OMG :facepalm:.  Yeah, that's bad.  The only correct way is to write a <br>
> primitive (other than implementing the C library in Smalltalk).<br>
> <br>
> Not only you lose ulps that way, also some results will become zero when <br>
> they shouldn't.  Plus, there is the issue of argument reduction.<br>
> <br>
>> Still, it is not obvious to me. How far is this from the correct result?<br>
> <br>
> Without properly massaging the arguments given to trigonometric <br>
> transcendentals, and without knowing what is really going on, you can <br>
> get a mantissa consisting of 15 leading non-zero bits, followed by 38 <br>
> zero bits.<br>
> <br>
> This is why *nobody* should be using the x87 anymore, and for the sake <br>
> of compatibility the best way is to delegate to some base math library <br>
> that everybody else uses (because then you get the optimized numerical <br>
> algorithm that will cause your answers to match their answers, and then <br>
> you have sanity).  Unless of course you want to reimplement all of that <br>
> from scratch, and then Gilad's arguments start rising over the horizon <br>
> unless you have very good reasons.<br>
> <br>
> Andres.<br>
-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank" rel="noreferrer">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
</blockquote></div>